jQuery(function($) { /* ----------------------------------------- Preloader ----------------------------------------- */ $('#preloader').delay(1000).fadeOut(); $('#loader').delay(1000).fadeOut("slow"); /* ----------------------------------------- Navigation ----------------------------------------- */ $('.menu-toggle').click(function() { $(this).toggleClass('open'); }); /* ----------------------------------------- Keyboard Navigation ----------------------------------------- */ $(window).on('load resize', aster_real_estate_navigation) function aster_real_estate_navigation(event) { if ($(window).width() < 1200) { $('.main-navigation').find("li").last().bind('keydown', function(e) { if (e.shiftKey && e.which === 9) { if ($(this).hasClass('focus')) { } } else if (e.which === 9) { e.preventDefault(); $('#masthead').find('.menu-toggle').focus(); } }) } else { $('.main-navigation').find("li").unbind('keydown') } } aster_real_estate_navigation() var aster_real_estate_primary_menu_toggle = $('#masthead .menu-toggle'); aster_real_estate_primary_menu_toggle.on('keydown', function(e) { var tabKey = e.keyCode === 9; var shiftKey = e.shiftKey; if (aster_real_estate_primary_menu_toggle.hasClass('open')) { if (shiftKey && tabKey) { e.preventDefault(); const $the_last_li = $('.main-navigation').find("li").last() $the_last_li.find('a').focus() if (!$the_last_li.hasClass('focus')) { const $is_parent_on_top = true let $the_parent_ul = $the_last_li.closest('ul.sub-menu') let count = 0 while (!!$the_parent_ul.length) { ++count const $the_parent_li = $the_parent_ul.closest('li') if (!!$the_parent_li.length) { $the_parent_li.addClass('focus') $the_parent_ul = $the_parent_li.closest('ul.sub-menu') // Blur the cross $(this).blur() $the_last_li.addClass('focus') } if (!$the_parent_ul.length) { break; } } } }; } }) /* ----------------------------------------- Scroll Top ----------------------------------------- */ var aster_real_estate_scrollToTopBtn = $('.aster-real-estate-scroll-to-top'); $(window).scroll(function() { if ($(window).scrollTop() > 400) { aster_real_estate_scrollToTopBtn.addClass('show'); } else { aster_real_estate_scrollToTopBtn.removeClass('show'); } }); aster_real_estate_scrollToTopBtn.on('click', function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: 0 }, '300'); }); //search js $(".input").focus(function() { $(".form").addClass("move"); }); $(".input").focusout(function() { $(".form").removeClass("move"); $(".input").val(""); }); $(".search-main .btn").click(function() { $(".input").toggleClass("active"); $(".form").toggleClass("active"); }); }); // Video Popup jQuery(document).ready(function($){ $('.openBtn').on('click', function() { $(this).closest('.video-btn').find('.videoOverlay').css('display', 'flex'); }); $('.close-btn').on('click', function() { $(this).closest('.videoOverlay').hide(); }); }); document.addEventListener('DOMContentLoaded', function() { const aster_real_estate_header = document.querySelector('.sticky-header'); if (aster_real_estate_header) { window.addEventListener('scroll', function() { if (window.scrollY > 0) { aster_real_estate_header.classList.add('is-sticky'); } else { aster_real_estate_header.classList.remove('is-sticky'); } }); } }); document.addEventListener("DOMContentLoaded", function() { const aster_real_estate_tabs = document.querySelectorAll(".tab-link"); const aster_real_estate_statusInput = document.getElementById("property-status"); aster_real_estate_tabs.forEach(tab => { tab.addEventListener("click", function(e) { e.preventDefault(); aster_real_estate_tabs.forEach(t => t.classList.remove("active")); this.classList.add("active"); aster_real_estate_statusInput.value = this.getAttribute("data-status"); }); }); });