1/* 2 Theme Name: houzez 3 Description: houzez 4 Author: Favethemes 5 Version: 1.0 6 */ 7 var houzezThemeGlobal = {}; 8 9(function ($) { 10 "use strict"; 11 12 /* ------------------------------------------------------------------------ */ 13 /* global variables 14 /* ------------------------------------------------------------------------ */ 15 var $win = $(window); 16 var popupSliderLoaded = false; 17 var houzezStickyTop = 0; 18 var adminBarHeight = 0; 19 var ajaxurl = houzez_vars.admin_url+ 'admin-ajax.php'; 20 var compare_url = houzez_vars.compare_url; 21 var houzez_rtl = houzez_vars.houzez_rtl; 22 var userID = houzez_vars.user_id; 23 var wp_is_mobile = houzez_vars.wp_is_mobile; 24 var houzez_is_splash = houzez_vars.houzez_is_splash; 25 var prop_detail_nav = houzez_vars.prop_detail_nav; 26 var search_position = houzez_vars.search_position; 27 var is_singular_property = houzez_vars.is_singular_property; 28 var transparent_logo = houzez_vars.transparent_logo; 29 var is_transparent = houzez_vars.is_transparent; 30 var is_top_header = houzez_vars.is_top_header; 31 var houzez_date_language = houzez_vars.houzez_date_language; 32 var compare_add_icon = houzez_vars.compare_add_icon; 33 var add_compare_text = houzez_vars.add_compare_text; 34 var compare_remove_icon = houzez_vars.compare_remove_icon; 35 var remove_compare_text = houzez_vars.remove_compare_text; 36 var compare_limit = houzez_vars.compare_limit; 37 var compare_page_not_found = houzez_vars.compare_page_not_found; 38 var g_recaptha_version = houzez_vars.g_recaptha_version; 39 var for_rent = houzez_vars.for_rent; 40 var for_rent_price_slider = houzez_vars.for_rent_price_slider; 41 var search_price_range_min = parseInt( houzez_vars.search_min_price_range ); 42 var search_price_range_max = parseInt( houzez_vars.search_max_price_range ); 43 var search_price_range_min_rent = parseInt( houzez_vars.search_min_price_range_for_rent ); 44 var search_price_range_max_rent = parseInt( houzez_vars.search_max_price_range_for_rent ); 45 var get_min_price = parseInt( houzez_vars.get_min_price ); 46 var get_max_price = parseInt( houzez_vars.get_max_price ); 47 var currency_position = houzez_vars.currency_position; 48 var decimals = houzez_vars.decimals; 49 var decimal_point_separator = houzez_vars.decimal_point_separator; 50 var thousands_separator = houzez_vars.thousands_separator; 51 var currency_symb = houzez_vars.currency_symbol; 52 var is_halfmap = parseInt(houzez_vars.is_halfmap); 53 var houzez_reCaptcha = parseInt(houzez_vars.houzez_reCaptcha); 54 var prev_text = houzez_vars.prev_text 55 var next_text = houzez_vars.next_text 56 var keyword_search_field = houzez_vars.keyword_search_field; 57 var keyword_autocomplete = houzez_vars.keyword_autocomplete; 58 var autosearch_text = houzez_vars.autosearch_text; 59 var login_redirect_type = houzez_vars.redirect_type 60 var login_redirect = houzez_vars.login_redirect 61 var login_loading = houzez_vars.login_loading 62 var paypal_connecting = houzez_vars.paypal_connecting; 63 var processing_text = houzez_vars.processing_text; 64 var is_edit_property = houzez_vars.is_edit_property; 65 var property_gallery_popup_type = houzez_vars.property_gallery_popup_type; 66 67 var simple_logo = houzez_vars.simple_logo; 68 var retina_logo = houzez_vars.retina_logo; 69 var mobile_logo = houzez_vars.mobile_logo; 70 var retina_logo_mobile = houzez_vars.retina_logo_mobile; 71 var retina_logo_mobile_splash = houzez_vars.retina_logo_mobile_splash; 72 var custom_logo_splash = houzez_vars.custom_logo_splash; 73 var retina_logo_splash = houzez_vars.retina_logo_splash; 74 var calDoughnutChart; 75 var is_listing_gallery_slider = false;
76 77 var top_banner_wrap_height = 0; 78 var top_banner_wrap = $('.top-banner-wrap '); 79 80 var header_area = $('.header-main-wrap'); 81 var advanced_search_nav = $('.advanced-search-nav'); 82 var desktop_header_search_enabled = advanced_search_nav.data('sticky'); 83 84 var elementor_location_header = $('.elementor-location-header'); 85 var header_area_height = header_area.innerHeight(); 86 var elementor_location_header_height = elementor_location_header.innerHeight(); 87 var advanced_search_nav_height = advanced_search_nav.innerHeight(); 88 89 var header_nav = $('#header-section'); 90 var houzez_nav_sticky_height = header_nav.innerHeight(); 91 var only_nav_sticky = header_nav.data('sticky'); 92 93 houzezThemeGlobal.$body = $('body'); 94 houzezThemeGlobal.$document = $(document); 95 houzezThemeGlobal.$window = $(window); 96 97 houzezThemeGlobal.houzezEleAddAction = function(name, callback) { 98 houzezThemeGlobal.$window.on('elementor/frontend/init', function() { 99 if ( !elementorFrontend.isEditMode() ) { 100 return; 101 } 102 103 elementorFrontend.hooks.addAction(name, callback); 104 }); 105 } 106 107 var houzez_is_mobile = /ipad|iphone|ipod|android|blackberry|webos|iemobile|windows phone/i.test(navigator.userAgent.toLowerCase()); 108 109 if( prop_detail_nav == 'yes' && is_singular_property) { 110 only_nav_sticky = 0; 111 } 112 113 if(elementor_location_header_height == null) { 114 elementor_location_header_height = 0; 115 } 116 117 if(header_area_height == null) { 118 header_area_height = 0; 119 } 120 121 if(advanced_search_nav_height == null) { 122 advanced_search_nav_height = 0; 123 } 124 125 if( houzez_rtl == 'yes' ) { 126 houzez_rtl = true; 127 } else { 128 houzez_rtl = false; 129 } 130 131 if(only_nav_sticky === 1) { 132 houzezStickyTop = houzez_nav_sticky_height; 133 if( !wp_is_mobile ) { 134 desktop_header_search_enabled = 0; 135 } 136 } 137 138 var make_search_sticky_position = header_area_height + advanced_search_nav_height; 139 var searchStickyPlus = 100; 140 var search_under_navigation = true; 141 if( wp_is_mobile ) { 142 make_search_sticky_position = make_search_sticky_position + 40; 143 } 144 145 $(document).ready(function() { 146 top_banner_wrap_height = top_banner_wrap.innerHeight(); 147 148 if(search_position == 'under_banner') { 149 make_search_sticky_position = header_area_height + top_banner_wrap_height; 150 searchStickyPlus = 0; 151 if( wp_is_mobile ) { 152 searchStickyPlus = 60; 153 } 154 if( is_transparent ) { 155 searchStickyPlus = 60; 156 } 157 search_under_navigation = false; 158 } 159 160 adminBarHeight = $('#wpadminbar').innerHeight(); 161 if(adminBarHeight != null) { 162 houzezStickyTop = houzezStickyTop + adminBarHeight; 163 } 164 165 }); 166 167 function HouzezDebounce(func, delay) { 168 let debounceTimer; 169 return function() { 170 const context = this; 171 const args = arguments; 172 clearTimeout(debounceTimer); 173 debounceTimer = setTimeout(() => func.apply(context, args), delay); 174 }; 175 } 176 177 function parseBool(str) { 178 if( str == 'true' ) { return true; } else { return false; } 179 } 180 181 /* ------------------------------------------------------------------------ */ 182 /* force video background to play on safari 11 183 /* ------------------------------------------------------------------------ */ 184 $(document).ready(function() { 185 if( $('#video-background').length > 0 ) { 186 $('#video-background').data('vide').getVideoObject().play(); 187 } 188 }); 189 190 function adjustMegaMenu(megaMenuSelector, containerSelector, fullwidthClass, customWidthClass, customWidthPx) { 191 jQuery(megaMenuSelector).each(function() { 192 var windowWidth = jQuery(window).width(); 193 var isRTL = jQuery('html').attr('dir') === 'rtl'; // Check if the page is RTL 194 195 if (jQuery(this).closest(fullwidthClass).length > 0) { 196 // Full viewport width 197 jQuery(this).css('width', '100vw'); 198 var position = jQuery(this).offset().left * -1; 199 //jQuery(this).css(isRTL ? 'right' : 'left', position + 'px'); 200 201 if (isRTL) { 202 jQuery(this).css('right', position * -1 + 'px'); 203 } else { 204 jQuery(this).css('left', position + 'px'); 205 } 206 207 } else if (jQuery(this).closest(customWidthClass).length > 0) { 208 // Set custom width 209 jQuery(this).css('width', customWidthPx + 'px'); 210 211 var menuItem = jQuery(this).closest('.nav-item'); 212 var menuItemOffset = menuItem.offset().left; 213 var position = menuItemOffset - jQuery(this).parent().offset().left; 214 215 // Check if the dropdown goes outside the window 216 if (menuItemOffset + customWidthPx > windowWidth) { 217 // Open towards the left (or right in RTL) side of the menu item 218 position -= (customWidthPx - menuItem.width()); 219 } 220 221 if (isRTL) { 222 jQuery(this).css('right', position * -1 + 'px'); 223 } else { 224 jQuery(this).css('left', position + 'px'); 225 } 226 227 } else {
228 // Width of the nearest container 229 var containerWidth = jQuery(this).closest(containerSelector).width(); 230 jQuery(this).css('width', containerWidth); 231 // Positioning relative to container 232 var containerOffset = jQuery(this).closest(containerSelector).offset().left; 233 var megamenuOffset = jQuery(this).closest('.nav-item').offset().left; 234 var position = containerOffset - megamenuOffset; 235 //jQuery(this).css(isRTL ? 'right' : 'left', position + 'px'); 236 237 if (isRTL) { 238 jQuery(this).css('right', position * -1 + 'px'); 239 } else { 240 jQuery(this).css('left', position + 'px'); 241 } 242 } 243 }); 244 } 245 246 function setMenuFullWidthEle() { 247 if ($('#houzez_toggle').length > 0) { 248 var isRTL = $('html').attr('dir') === 'rtl'; // Check if the page is RTL 249 250 var leftDistance; 251 leftDistance = $('#houzez_toggle').offset().left; 252 //alert(leftDistance); 253 $('.houzez-nav-mobile-menu-fullwidth .main-mobile-nav').css('left', 'calc(50vw - ' + leftDistance + 'px)'); 254 255 console.log('Distance from the left:', leftDistance); 256 } 257 } 258 259 // Call the function with specific class names 260 $(window).on('load', function () { 261 adjustMegaMenu('.houzez-elementor-menu .dropdown-menu.megamenu', '.e-con-inner', '.menu-item-design-full-width', '.menu-item-design-custom-size', 200); 262 setTimeout(setMenuFullWidthEle, 500); // Delay of 1000 milliseconds (1 second) 263 264 }); 265 266 // Re-adjust the megamenu on window resize 267 $(window).resize(function() { 268 adjustMegaMenu('.houzez-elementor-menu .dropdown-menu.megamenu', '.e-con-inner', '.menu-item-design-full-width', '.menu-item-design-custom-size', 200); 269 setMenuFullWidthEle(); 270 }); 271 272 273 /* ------------------------------------------------------------------------ */ 274 /* lazy load 275 /* ------------------------------------------------------------------------ */ 276 document.addEventListener("DOMContentLoaded", function() { 277 var lazyImages = [].slice.call(document.querySelectorAll(".houzez-lazyload")); 278 279 if ("IntersectionObserver" in window) { 280 let lazyImageObserver = new IntersectionObserver(function(entries, observer) { 281 entries.forEach(function(entry) { 282 if (entry.isIntersecting) { 283 let lazyImage = entry.target; 284 lazyImage.src = lazyImage.dataset.src; 285 if(lazyImage.dataset.srcset) { 286 lazyImage.srcset = lazyImage.dataset.srcset; 287 } 288 lazyImage.classList.remove("houzez-lazyload"); 289 lazyImageObserver.unobserve(lazyImage); 290 } 291 }); 292 }); 293 294 lazyImages.forEach(function(lazyImage) { 295 lazyImageObserver.observe(lazyImage); 296 }); 297 } else { 298 // Possibly fall back to a more compatible method here 299 } 300 }); 301 302 303 /* ------------------------------------------------------------------------ */ 304 /* Retina logo 305 /* ------------------------------------------------------------------------ */ 306 if ( retina_logo !== '' || retina_logo_splash != '' || retina_logo_mobile != '' || retina_logo_mobile_splash != '' ) { 307 if (window.devicePixelRatio == 2) { 308 309 if( retina_logo != '' ) { 310 $(".logo-desktop img").attr("src", retina_logo); 311 } 312 313 if( retina_logo_splash != '' ) { 314 $(".logo-splash img").attr("src", retina_logo_splash); 315 } 316 317 if( retina_logo_mobile != '' ) { 318 $(".logo-mobile img").attr("src", retina_logo_mobile); 319 } 320 } 321 } 322 323 324 $('.all-reviews').on('click', function(e) { 325 $('.hz-review-tab').trigger('click'); 326 }); 327 328 /*-----------------------------------------------------------------------------------*/ 329 /* Scroll to Top 330 /*-----------------------------------------------------------------------------------*/ 331 $(function () { 332 var scroll_anchor = $('#scroll-top'); 333 334 $(window).on('scroll', function () { 335 if ($(this).scrollTop() > 300) { 336 scroll_anchor.fadeIn('fast').css("display","block"); 337 return; 338 } 339 // } 340 scroll_anchor.fadeOut('fast'); 341 }); 342 343 scroll_anchor.on('click', function (event) { 344 event.preventDefault(); 345 $('html, body').animate({ scrollTop: 0 }, 'slow'); 346 }); 347 }); 348 349 /* ------------------------------------------------------------------------ */ 350 /* Schedule tour v2 351 /* ------------------------------------------------------------------------ */ 352 353 /*$('.tour-day-form-slide-arrow.next').click(function (e) { 354 $('.property-schedule-tour-day-form-slide').addClass("end"); 355 $('.property-schedule-tour-day-form-slide').removeClass("start"); 356 }); 357 $('.tour-day-form-slide-arrow.prev').click(function (e) { 358 $('.property-schedule-tour-day-form-slide').addClass("start"); 359 $('.property-schedule-tour-day-form-slide').removeClass("end"); 360 });*/ 361 362 /*------------------------------------------------------------------- 363 * Properties ajax tabs 364 *-------------------------------------------------------------------*/ 365 /*$.each([ 366 'frontend/element_ready/houzez_properties_tabs.default', 367 ], function(index, value) { 368 houzezThemeGlobal.houzezEleAddAction(value, function() { alert('1111'); 369 houzezThemeGlobal.houzezProductsTabs(); 370 }); 371 });*/ 372 373 //houzezThemeGlobal.houzezProductsTabs(); 374 375 var houzezProductsTabs = function() { 376 var alreadyProcessed = false;
377 378 $('.houzez-products-tabs-js').each(function() { 379 var $this = $(this); 380 var $html_container = $this.find('.houzez-tab-content'); 381 var $products_cache = []; 382 383 $this.find('ul.property-nav-tabs li').on('click', function(e) { 384 e.preventDefault(); 385 386 var $this = $(this); 387 var settings = $this.data('json'); 388 var data_index = $this.index(); 389 390 if ( alreadyProcessed || $this.find('a').hasClass('active') ) { 391 return; 392 } 393 394 alreadyProcessed = true; 395 396 if ($products_cache[data_index]) { 397 setTimeout(function() { 398 $html_container.html($products_cache[data_index].html); 399 alreadyProcessed = false; 400 }, 300); 401 return; 402 } 403 404 $.ajax({ 405 url : ajaxurl, 406 data : { 407 action: 'houzez_get_properties_tab_content', 408 settings : settings 409 }, 410 dataType: 'json', 411 method : 'POST', 412 beforeSend: function( ) { 413 414 $html_container.empty().append('' 415 +'<div id="houzez-map-loading">' 416 +'<div class="mapPlaceholder">' 417 +'<div class="loader-ripple spinner">' 418 +'<div class="bounce1"></div>' 419 +'<div class="bounce2"></div>' 420 +'<div class="bounce3"></div>' 421 +'</div>' 422 +'</div>' 423 +'</div>' 424 ); 425 }, 426 success : function(data) { 427 $products_cache[data_index] = data; 428 $html_container.html(data.html); 429 430 houzez_init_add_favorite(ajaxurl, userID); 431 houzez_init_remove_favorite(ajaxurl, userID); 432 houzez_listing_lightbox(ajaxurl, processing_text, houzez_rtl, userID); 433 houzez_grid_image_gallery(); 434 houzez_grid_call_to_action(); 435 compare_for_ajax(); 436 $('[data-toggle="tooltip"]').tooltip(); 437 }, 438 error: function(xhr, status, error) { 439 var err = eval("(" + xhr.responseText + ")"); 440 console.log(err.Message); 441 }, 442 complete: function() { 443 alreadyProcessed = false; 444 } 445 }); 446 447 }); 448 449 }); 450 }; 451 houzezProductsTabs(); 452 453 /*------------------------------------------------------------------- 454 * Photo Swipe 455 *-------------------------------------------------------------------*/ 456 var initPhotoSwipeFromDOM = function(gallerySelector) { 457 458 // parse slide data (url, title, size ...) from DOM elements 459 // (children of gallerySelector) 460 var parseThumbnailElements = function(el) { 461 var thumbElements = el.childNodes, 462 numNodes = thumbElements.length, 463 items = [], 464 figureEl, 465 linkEl, 466 size, 467 item; 468 469 for(var i = 0; i < numNodes; i++) { 470 471 figureEl = thumbElements[i]; // <figure> element 472 473 // include only element nodes 474 if(figureEl.nodeType !== 1) { 475 continue; 476 } 477 478 479 480 linkEl = figureEl.children[0]; // <a> element 481 482 size = linkEl.getAttribute('data-size').split('x'); 483 484 // create slide object 485 item = { 486 src: linkEl.getAttribute('href'), 487 w: parseInt(size[0], 10), 488 h: parseInt(size[1], 10) 489 }; 490 491 492 493 if(figureEl.children.length > 1) { 494 // <figcaption> content 495 item.title = figureEl.children[1].innerHTML; 496 } 497 498 if(linkEl.children.length > 0) { 499 // <img> thumbnail element, retrieving thumbnail url 500 item.msrc = linkEl.children[0].getAttribute('src'); 501 } 502 503 item.el = figureEl; // save link to element for getThumbBoundsFn 504 items.push(item); 505 } 506 507 return items; 508 }; 509 510 // find nearest parent element 511 var closest = function closest(el, fn) { 512 return el && ( fn(el) ? el : closest(el.parentNode, fn) ); 513 }; 514 515 // triggers when user clicks on thumbnail 516 var onThumbnailsClick = function(e) { 517 e = e || window.event; 518 e.preventDefault ? e.preventDefault() : e.returnValue = false;
519 520 var eTarget = e.target || e.srcElement; 521 522 // find root element of slide 523 var clickedListItem = closest(eTarget, function(el) { 524 return (el.tagName && ( el.tagName.toUpperCase() === 'FIGURE' || el.tagName.toUpperCase() === 'DIV' ) ); 525 }); 526 527 if(!clickedListItem) { 528 return; 529 } 530 531 // find index of clicked item by looping through all child nodes 532 // alternatively, you may define index via data- attribute 533 var clickedGallery = clickedListItem.parentNode, 534 childNodes = clickedListItem.parentNode.childNodes, 535 numChildNodes = childNodes.length, 536 nodeIndex = 0, 537 index; 538 539 for (var i = 0; i < numChildNodes; i++) { 540 if(childNodes[i].nodeType !== 1) { 541 continue; 542 } 543 544 if(childNodes[i] === clickedListItem) { 545 index = nodeIndex; 546 break; 547 } 548 nodeIndex++; 549 } 550 551 552 553 if(index >= 0) { 554 // open PhotoSwipe if valid index found 555 openPhotoSwipe( index, clickedGallery ); 556 } 557 return false; 558 }; 559 560 // parse picture index and gallery index from URL (#&pid=1&gid=2) 561 var photoswipeParseHash = function() { 562 var hash = window.location.hash.substring(1), 563 params = {}; 564 565 if(hash.length < 5) { 566 return params; 567 } 568 569 var vars = hash.split('&'); 570 for (var i = 0; i < vars.length; i++) { 571 if(!vars[i]) { 572 continue; 573 } 574 var pair = vars[i].split('='); 575 if(pair.length < 2) { 576 continue; 577 } 578 params[pair[0]] = pair[1]; 579 } 580 581 if(params.gid) { 582 params.gid = parseInt(params.gid, 10); 583 } 584 585 return params; 586 }; 587 588 var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) { 589 var pswpElement = document.querySelectorAll('.pswp')[0], 590 gallery, 591 options, 592 items; 593 594 items = parseThumbnailElements(galleryElement); 595 596 // define options (if needed) 597 options = { 598 599 // define gallery index (for URL) 600 galleryUID: galleryElement.getAttribute('data-pswp-uid'), 601 602 getThumbBoundsFn: function(index) { 603 // See Options -> getThumbBoundsFn section of documentation for more info 604 var thumbnail = items[index].el.getElementsByTagName('img')[0], // find thumbnail 605 pageYScroll = window.pageYOffset || document.documentElement.scrollTop, 606 rect = thumbnail.getBoundingClientRect(); 607 608 return {x:rect.left, y:rect.top + pageYScroll, w:rect.width}; 609 } 610 611 }; 612 613 options.closeOnScroll = false; 614 options.bgOpacity = 0.95; 615 options.showHideOpacity = false; 616 options.history = false 617 618 // PhotoSwipe opened from URL 619 if(fromURL) { 620 if(options.galleryPIDs) { 621 // parse real index when custom PIDs are used 622 // http://photoswipe.com/documentation/faq.html#custom-pid-in-url 623 for(var j = 0; j < items.length; j++) { 624 if(items[j].pid == index) { 625 options.index = j; 626 break; 627 } 628 } 629 } else { 630 // in URL indexes start from 1 631 options.index = parseInt(index, 10) - 1; 632 } 633 } else { 634 options.index = parseInt(index, 10); 635 } 636 637 // exit if index not found 638 if( isNaN(options.index) ) { 639 return; 640 } 641 642 if(disableAnimation) { 643 options.showAnimationDuration = 0; 644 } 645 646 // Pass data to PhotoSwipe and initialize it 647 gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options); 648 gallery.init(); 649 }; 650 651 // loop through all gallery elements and bind events 652 var galleryElements = document.querySelectorAll( gallerySelector ); 653 654 for(var i = 0, l = galleryElements.length; i < l; i++) { 655 galleryElements[i].setAttribute('data-pswp-uid', i+1); 656 galleryElements[i].onclick = onThumbnailsClick; 657 } 658 659 // Parse URL and open gallery if it contains #&pid=3&gid=1 660 var hashData = photoswipeParseHash(); 661 if(hashData.pid && hashData.gid) { 662 openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true ); 663 } 664 }; 665 666 // execute above function 667 if( property_gallery_popup_type == 'photoswipe' && is_singular_property ) { 668 initPhotoSwipeFromDOM('.houzez-photoswipe'); 669 } 670 671 672 /* ------------------------------------------------------------------------ */ 673 /* STICKY HEADER 674 /* ------------------------------------------------------------------------ */ 675 if (window.devicePixelRatio == 2) { 676 677 if(transparent_logo) { 678 if(retina_logo_splash != '') { 679 custom_logo_splash = retina_logo_splash; 680 } 681 if(retina_logo != '') { 682 simple_logo = retina_logo; 683 } 684 } 685 } 686 687 688 if( only_nav_sticky && !wp_is_mobile ) { 689 houzez_sticky_nav(); 690 691 if( $('.compare-table').length > 0 ) { 692 var compare_top_margin = advanced_search_nav.outerHeight(); 693 $('.compare-table thead th').css('top', compare_top_margin + 25); 694 } 695 } 696 697 function houzez_sticky_nav() { 698 $(window).scroll(function() { 699 var scroll = $(window).scrollTop(); 700 var admin_nav = $('#wpadminbar').height(); 701 var top_banner_margin = 0; 702 var thisHeight = header_nav.outerHeight(); 703 top_banner_margin = thisHeight; 704 705 if(is_top_header != 0) { 706 var top_bar_wrap = $('.top-bar-wrap').height(); 707 top_banner_margin = top_banner_margin + top_bar_wrap; 708 } 709 710 if(only_nav_sticky === 0) { 711 return; 712 } 713 714 if(transparent_logo) { 715 $('.logo-splash img').attr('src', simple_logo); 716 } 717 718 if( admin_nav == 'null' ) { admin_nav = 0; } 719 720 if (scroll > header_area_height ) { 721 header_nav.addClass('sticky-nav-area'); 722 header_nav.css('top', admin_nav); 723 if(transparent_logo){ 724 header_area.removeClass('header-transparent-wrap'); 725 $('.top-banner-wrap').css('margin-top', "-"+top_banner_margin+"px"); 726 $('body.houzez-header-elementor .content-wrap').css('margin-top', "-"+top_banner_margin+"px"); 727 $('#main-wrap > div.elementor').css('margin-top', "-"+top_banner_margin+"px"); 728 } 729 730 if (scroll >= header_area_height + 20 ) { 731 header_nav.addClass('houzez-in-view'); 732 $('#main-wrap').css('margin-top', thisHeight); 733 } 734 735 } else { 736 header_nav.removeClass('sticky-nav-area'); 737 header_nav.removeAttr("style"); 738 if(transparent_logo){ 739 header_area.addClass('header-transparent-wrap'); 740 $('.top-banner-wrap').css('margin-top', 0); 741 $('body.houzez-header-elementor .content-wrap').css('margin-top', 0); 742 $('#main-wrap > div.elementor').css('margin-top', 0); 743 $('.logo-splash img').attr('src', custom_logo_splash); 744 } 745 746 if (scroll <= header_area_height + 20 ) { 747 header_nav.removeClass('houzez-in-view'); 748 } 749 $('#main-wrap').css('margin-top', 0); 750 } 751 }); 752 } 753 754 /* ------------------------------------------------------------------------ */ 755 /* STICKY Header Search 756 /* ------------------------------------------------------------------------ */ 757 if( desktop_header_search_enabled ) { 758 houzez_sticky_search(); 759 } 760 761 function houzez_sticky_search() { 762 $(window).scroll(function() { 763 var scroll = $(window).scrollTop(); 764 var admin_nav = $('#wpadminbar').height(); 765 var thisHeight = advanced_search_nav.outerHeight(); 766 var hidden_data = advanced_search_nav.data('hidden'); 767 768 if( admin_nav == 'null' ) { admin_nav = 0; } 769 770 if (scroll >= make_search_sticky_position ) { 771 772 advanced_search_nav.addClass('sticky-search-area'); 773 if(hidden_data) { 774 advanced_search_nav.removeClass('search-hidden'); 775 } 776 777 if( !wp_is_mobile ) { 778 advanced_search_nav.css('top', admin_nav); 779 } 780 781 if (scroll >= make_search_sticky_position + searchStickyPlus ) { 782 advanced_search_nav.addClass('houzez-in-view'); 783 784 if( !hidden_data ) { 785 $('#main-wrap').css('padding-top',thisHeight); 786 } 787 788 } 789 } else { 790 advanced_search_nav.removeClass('sticky-search-area'); 791 advanced_search_nav.removeAttr("style"); 792 if (scroll <= make_search_sticky_position + 20 ) { 793 advanced_search_nav.removeClass('houzez-in-view'); 794 } 795 if(hidden_data) { 796 advanced_search_nav.addClass('search-hidden'); 797 } 798 if( !hidden_data ) { 799 $('#main-wrap').css('padding-top', 0); 800 } 801 802 } 803 }); 804 } 805 806 /*var header_mobile = $('#header-mobile'); 807 var mobile_sticky_nav = header_mobile.data('sticky'); 808 if( mobile_sticky_nav && wp_is_mobile ) { 809 houzez_mobile_sticky_nav(); 810 }*/ 811 function houzez_mobile_sticky_nav() { 812 $(window).scroll(function() { 813 var scroll = $(window).scrollTop(); 814 var admin_nav = 0;//$('#wpadminbar').height(); 815 var top_banner_margin = 0; 816 var thisHeight = header_mobile.outerHeight(); 817 top_banner_margin = thisHeight; 818 819 if(is_top_header) { 820 var top_bar_wrap = $('.top-bar-wrap').height(); 821 top_banner_margin = top_banner_margin + top_bar_wrap; 822 } 823 824 if(mobile_sticky_nav === 0) { 825 return; 826 } 827 828 829 if( admin_nav == 'null' ) { admin_nav = 0; } 830 831 if (scroll > header_area_height ) { 832 header_mobile.addClass('sticky-nav-area'); 833 //header_mobile.css('top', admin_nav); 834 835 if (scroll >= header_area_height + 20 ) { 836 header_mobile.addClass('houzez-in-view'); 837 $('#main-wrap').css('margin-top', thisHeight); 838 } 839 840 } else { 841 header_mobile.removeClass('sticky-nav-area'); 842 header_mobile.removeAttr("style"); 843 844 if (scroll <= header_area_height + 20 ) { 845 header_mobile.removeClass('houzez-in-view'); 846 } 847 $('#main-wrap').css('margin-top', 0); 848 } 849 }); 850 } 851 852 /* ------------------------------------------------------------------------ */ 853 /* Add Comma to value 854 /* ------------------------------------------------------------------------ */ 855 var addCommas = function (nStr) { 856 nStr += ''; 857 var x = nStr.split('.'); 858 var x1 = x[0]; 859 var x2 = x.length > 1 ? '.' + x[1] : ''; 860 var rgx = /(\d+)(\d{3})/; 861 while (rgx.test(x1)) { 862 x1 = x1.replace(rgx, '$1' + ',' + '$2'); 863 } 864 return x1 + x2; 865 } 866 867 var thousandSeparator = (n) => { 868 if (typeof n === 'number') { 869 n += ''; 870 var x = n.split('.'); 871 var x1 = x[0]; 872 var x2 = x.length > 1 ? '.' + x[1] : ''; 873 var rgx = /(\d+)(\d{3})/; 874 while (rgx.test(x1)) { 875 x1 = x1.replace(rgx, '$1' + thousands_separator + '$2'); 876 } 877 return x1 + x2; 878 } else { 879 return n; 880 } 881 } 882 883 /* ------------------------------------------------------------------------ */ 884 /* Number format 885 /* ------------------------------------------------------------------------ */ 886 function number_format( number ) { 887 888 var decimals, dec_point, thousands_sep; 889 890 dec_point = decimal_point_separator; 891 thousands_sep = thousands_separator; 892 893 var i, j, kw, kd, km; 894 895 // input sanitation & defaults 896 if( isNaN( decimals = Math.abs( decimals ) ) ) { 897 decimals = 2; 898 } 899 900 dec_point = dec_point || ","; 901 thousands_sep = thousands_sep || "."; 902 903 i = parseInt(number = (+number || 0).toFixed(decimals)) + ""; 904 j = ( j = i.length ) > 3 ? j % 3 : 0; 905 906 km = (j ? i.substr(0, j) + thousands_sep : ""); 907 kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep); 908 909 kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : ""); 910 911 return km + kw + kd; 912 } 913 914 if( $('#houzez-calculator-form').length > 0 ) { 915 916 $('#houzez-calculator-form input').on('input', () => {
917 mortgage_calucaltion_section(); 918 }); 919 920 mortgage_calucaltion_section(); 921 } 922 923 function calculateMonthlyPayment(principal, annualInterestRate, loanTermInYears) { 924 const monthlyInterestRate = annualInterestRate / 12 / 100; 925 const numberOfMonths = loanTermInYears * 12; 926 927 if (monthlyInterestRate === 0) { 928 return principal / numberOfMonths; 929 } 930 931 return principal * (monthlyInterestRate * Math.pow((1 + monthlyInterestRate), numberOfMonths)) / (Math.pow((1 + monthlyInterestRate), numberOfMonths) - 1); 932 } 933 934 // Define a helper function to parse and validate our inputs 935 function parseInput(selector) { 936 const rawValue = $(selector).val(); 937 938 if (!rawValue) return 0; // if value is empty or undefined, return 0 939 940 // Remove any non-digit character except the decimal point 941 const cleanedValue = rawValue.replace(/[^0-9.]/g, ''); 942 943 // Parsing to number 944 const parsedValue = parseFloat(cleanedValue); 945 946 // if parsedValue is NaN, return 0, otherwise return the parsed number 947 return isNaN(parsedValue) ? 0 : parsedValue; 948 } 949 950 951 function mortgage_calucaltion_section() { 952 const homePrice = parseInput('#homePrice'); 953 const downPaymentPercentage = parseInput('#downPaymentPercentage'); 954 const annualInterestRate = parseInput('#annualInterestRate'); 955 const loanTermInYears = parseInput('#loanTermInYears'); 956 const annualPropertyTaxRate = parseInput('#annualPropertyTaxRate'); 957 const annualHomeInsurance = parseInput('#annualHomeInsurance'); 958 const monthlyHOAFees = parseInput('#monthlyHOAFees'); 959 const pmi = parseInput('#pmi'); 960 961 const downPayment = homePrice * (downPaymentPercentage / 100); 962 const principal = homePrice - downPayment; 963 const monthlyPayment = calculateMonthlyPayment(principal, annualInterestRate, loanTermInYears); 964 const monthlyPropertyTax = (homePrice * (annualPropertyTaxRate / 100)) / 12; 965 const monthlyHomeInsurance = annualHomeInsurance / 12; 966 967 const pmiRequired = (downPayment / homePrice) < 0.2; 968 969 const monthlyPMI = pmiRequired ? (principal * (pmi / 100)) / 12 : 0; 970 971 const totalMonthlyPayment = monthlyPayment + monthlyPropertyTax + monthlyHomeInsurance + monthlyHOAFees + monthlyPMI; 972 973 const loanAmount = homePrice - downPayment; 974 975 const formattedDownPayment = number_format(downPayment); 976 const formattedLoanAmount = number_format(loanAmount); 977 const formattedMonthlyPayment = number_format(monthlyPayment); 978 const formattedPropertyTax = number_format(monthlyPropertyTax); 979 const formattedHomeInsurance = number_format(monthlyHomeInsurance); 980 const formattedPMI = pmiRequired ? number_format(monthlyPMI) : ''; 981 const formattedHOAFees = number_format(monthlyHOAFees); 982 const formattedTotalMonthlyPayment = number_format(totalMonthlyPayment); 983 984 $('#downPaymentResult').html( currencyFormate(formattedDownPayment) ); 985 $('#loadAmountResult').html( currencyFormate(formattedLoanAmount) ); 986 $('#monthlyMortgagePaymentResult').html( currencyFormate(formattedMonthlyPayment) ); 987 $('#monthlyPropertyTaxResult').html( currencyFormate(formattedPropertyTax) ); 988 $('#monthlyHomeInsuranceResult').html( currencyFormate(formattedHomeInsurance) ); 989 990 if (pmiRequired) { 991 $('.rslt-pmi').show(); 992 $('#monthlyPMIResult').html( currencyFormate(formattedPMI) ); 993 } else { 994 $('.rslt-pmi').hide(); 995 } 996 997 $('#monthlyHOAResult').html( currencyFormate(formattedHOAFees) ); 998 $('#m_monthly_val').html( currencyFormate(formattedTotalMonthlyPayment) ); 999 1000 const chartData = [ 1001 { label: 'Monthly Mortgage Payment', value: monthlyPayment, color: '#ff6384' }, 1002 { label: 'Property Tax', value: monthlyPropertyTax, color: '#36a2eb' }, 1003 { label: 'Home Insurance', value: monthlyHomeInsurance, color: '#ffce56' }, 1004 { label: 'HOA', value: monthlyHOAFees, color: '#c2d500' }, 1005 ]; 1006 1007 if (pmiRequired) { 1008 chartData.push({ label: 'PMI', value: monthlyPMI, color: '#4bc0c0' }); 1009 } 1010 1011 updateChart(chartData); 1012 } 1013 1014 const inputElements = document.querySelectorAll('#calculator-form input');
1015 inputElements.forEach(input => { 1016 input.addEventListener('input', () => { 1017 formatInputValue(input); 1018 updateResults(); 1019 }); 1020 }); 1021 1022 function updateChart(chartData) { 1023 const ctx = $('#mortgage-calculator-chart')[0].getContext('2d'); 1024 1025 if (window.myChart) { 1026 window.myChart.destroy(); 1027 } 1028 1029 window.myChart = new Chart(ctx, { 1030 type: 'doughnut', 1031 data: { 1032 //labels: chartData.map(item => item.label), 1033 datasets: [{ 1034 data: chartData.map(item => item.value), 1035 backgroundColor: chartData.map(item => item.color), 1036 }], 1037 }, 1038 options: { 1039 cutoutPercentage: 85, 1040 responsive: false, 1041 tooltips: false, 1042 }, 1043 }); 1044 } 1045 1046 /*if( $('#calculate_loan').length > 0 ) { 1047 1048 $('#calculate_loan').on('click', function(e) { 1049 e.preventDefault(); 1050 1051 var total_amount = $('#total_amount').val(); 1052 var down_payment = $('#down_payment').val(); 1053 var interest_rate = $('#interest_rate').val(); 1054 var loan_term = $('#loan_term').val(); 1055 var property_tax = $('#property_tax').val(); 1056 var home_insurance = $('#home_insurance').val(); 1057 var pmi = $('#pmi').val(); 1058 1059 mortgage_calucaltion_section(total_amount, down_payment, interest_rate, loan_term, property_tax, home_insurance, pmi); 1060 1061 }); 1062 1063 $(document).ready(function() { 1064 var total_amount = $('#total_amount').val(); 1065 var down_payment = $('#down_payment').val(); 1066 var interest_rate = $('#interest_rate').val(); 1067 var loan_term = $('#loan_term').val(); 1068 var property_tax = $('#property_tax').val(); 1069 var home_insurance = $('#home_insurance').val(); 1070 var pmi = $('#pmi').val(); 1071 1072 mortgage_calucaltion_section(total_amount, down_payment, interest_rate, loan_term, property_tax, home_insurance, pmi); 1073 }) 1074 }*/ 1075 1076 function currencyFormate(price_value) { 1077 1078 var value; 1079 1080 if( currency_position == '' || currency_symb == '' ) { 1081 return price_value; 1082 } 1083 1084 value = 'after' === currency_position ? price_value + '' + currency_symb : currency_symb + '' + price_value; 1085 return value; 1086 1087 } 1088 1089 /*function mortgage_calucaltion_section(total_amount, down_payment, interest_rate, loan_term, property_tax, home_insurance, pmi) { 1090 1091 if( isNaN( down_payment = Math.abs( down_payment ) ) ) { 1092 down_payment = 0; 1093 } 1094 1095 if( isNaN( interest_rate = Math.abs( interest_rate ) ) ) { 1096 interest_rate = 0; 1097 } 1098 1099 if( isNaN( loan_term = Math.abs( loan_term ) ) ) { 1100 loan_term = 0; 1101 } 1102 1103 if( isNaN( property_tax = Math.abs( property_tax ) ) ) { 1104 property_tax = 0; 1105 } 1106 1107 if( isNaN( home_insurance = Math.abs( home_insurance ) ) ) { 1108 home_insurance = 0; 1109 } 1110 1111 if( isNaN( pmi = Math.abs( pmi ) ) ) { 1112 pmi = 0; 1113 } 1114 1115 var load_amount = total_amount - down_payment; 1116 var qty_payments = loan_term * 12; 1117 var rate = interest_rate / 100 / 12; 1118 1119 //Present value interest factor. 1120 var pvif = Math.pow( 1 + rate, qty_payments ); 1121 var pmt = Math.round( rate / ( pvif - 1 ) * - ( load_amount * pvif ) ); 1122 1123 var interest_in_absolute = -pmt; 1124 var home_insurance = Math.round( home_insurance / 12 * 100 ) / 100; 1125 var property_tax = Math.round( property_tax / 12 * 100 ) / 100; 1126 var payment_total = interest_in_absolute + property_tax + home_insurance + parseInt(pmi); 1127 1128 1129 var interest_in_absolute2 = number_format(interest_in_absolute); 1130 interest_in_absolute2 = currencyFormate(interest_in_absolute2); 1131 1132 var property_tax2 = number_format(property_tax); 1133 property_tax2 = currencyFormate(property_tax2); 1134 1135 var home_insurance2 = number_format(home_insurance); 1136 home_insurance2 = currencyFormate(home_insurance2); 1137 1138 var pmi2 = number_format(pmi); 1139 pmi2 = currencyFormate(pmi2); 1140 1141 var payment_total2 = number_format(payment_total); 1142 payment_total2 = currencyFormate(payment_total2); 1143 1144 $('#principal_interest_val').html(interest_in_absolute2); 1145 $('#property_tax_val').html(property_tax2); 1146 $('#home_insurance_val').html(home_insurance2); 1147 $('#pmi_val').html(pmi2); 1148 $('#m_monthly_val').html(payment_total2); 1149 1150 var ctx = document.getElementById('mortgage-calculator-chart').getContext('2d'); 1151 1152 if (typeof calDoughnutChart !== 'undefined') { 1153 calDoughnutChart.destroy(); 1154 } 1155 1156 calDoughnutChart = new Chart(ctx, { 1157 type: 'doughnut', 1158 data: { 1159 datasets: [{ 1160 data: [interest_in_absolute, property_tax, home_insurance, pmi], 1161 backgroundColor: [ 1162 'rgba(255, 99, 132, 0.5)', 1163 'rgba(54, 162, 235, 0.5)', 1164 'rgba(255, 206, 86, 0.5)', 1165 'rgba(75, 192, 192, 0.5)' 1166 ], 1167 borderColor: [ 1168 'rgba(255 ,99, 132, 1)', 1169 'rgba(54, 162, 235, 1)', 1170 'rgba(255, 206, 86, 1)', 1171 'rgba(75, 192, 192, 1)' 1172 ], 1173 borderWidth: 1 1174 }] 1175 }, 1176 options: { 1177 cutoutPercentage: 85, 1178 responsive: false, 1179 tooltips: false, 1180 } 1181 }); 1182 }*/ 1183 1184 /* ------------------------------------------------------------------------ */ 1185 /* Listing Preview 1186 /* ------------------------------------------------------------------------ */ 1187 houzez_listing_lightbox(ajaxurl, processing_text, houzez_rtl, userID); 1188 1189 /* ------------------------------------------------------------------------ */ 1190 /* Listing Gallery 1191 /* ------------------------------------------------------------------------ */ 1192 $(window).on('load', function() { 1193 houzez_grid_image_gallery(); 1194 houzez_grid_call_to_action(); 1195 }); 1196 1197 /* ------------------------------------------------------------------------ */ 1198 /* Cities chart for agent and agency 1199 /* ------------------------------------------------------------------------ */ 1200 if( $('#stats-property-cities').length > 0 ) { 1201 var chartData = $('#stats-property-cities').data('chart'); 1202 var ctx = document.getElementById('stats-property-cities').getContext('2d'); 1203 var myDoughnutChart = new Chart(ctx, { 1204 type: 'doughnut', 1205 data: { 1206 datasets: [{ 1207 data: chartData, 1208 backgroundColor: [ 1209 'rgba(255, 99, 132, 0.5)', 1210 'rgba(54, 162, 235, 0.5)', 1211 'rgba(255, 206, 86, 0.5)', 1212 'rgba(75, 192, 192, 0.5)' 1213 ], 1214 borderColor: [ 1215 'rgba(255 ,99, 132, 1)', 1216 'rgba(54, 162, 235, 1)', 1217 'rgba(255, 206, 86, 1)', 1218 'rgba(75, 192, 192, 1)' 1219 ], 1220 borderWidth: 1 1221 }] 1222 }, 1223 options: { 1224 cutoutPercentage: 60, 1225 responsive: false, 1226 tooltips: false, 1227 } 1228 }); 1229 } 1230 1231 /* ------------------------------------------------------------------------ */ 1232 /* Status chart for agent and agency 1233 /* ------------------------------------------------------------------------ */ 1234 if( $('#stats-property-status').length > 0 ) { 1235 var chartData = $('#stats-property-status').data('chart'); 1236 var ctx = document.getElementById('stats-property-status').getContext('2d'); 1237 var myDoughnutChart = new Chart(ctx, { 1238 type: 'doughnut', 1239 data: { 1240 datasets: [{ 1241 data: chartData, 1242 backgroundColor: [ 1243 'rgba(255, 99, 132, 0.5)', 1244 'rgba(54, 162, 235, 0.5)', 1245 'rgba(255, 206, 86, 0.5)', 1246 'rgba(75, 192, 192, 0.5)' 1247 ], 1248 borderColor: [ 1249 'rgba(255 ,99, 132, 1)', 1250 'rgba(54, 162, 235, 1)', 1251 'rgba(255, 206, 86, 1)', 1252 'rgba(75, 192, 192, 1)' 1253 ], 1254 borderWidth: 1 1255 }] 1256 }, 1257 options: { 1258 cutoutPercentage: 60, 1259 responsive: false, 1260 tooltips: false, 1261 } 1262 }); 1263 } 1264 1265 /* ------------------------------------------------------------------------ */ 1266 /* Types chart for agent and agency 1267 /* ------------------------------------------------------------------------ */ 1268 if( $('#stats-property-types').length > 0 ) { 1269 var chartData = $('#stats-property-types').data('chart'); 1270 var ctx = document.getElementById('stats-property-types').getContext('2d'); 1271 var myDoughnutChart = new Chart(ctx, { 1272 type: 'doughnut', 1273 data: { 1274 datasets: [{ 1275 data: chartData, 1276 backgroundColor: [ 1277 'rgba(255, 99, 132, 0.5)', 1278 'rgba(54, 162, 235, 0.5)', 1279 'rgba(255, 206, 86, 0.5)', 1280 'rgba(75, 192, 192, 0.5)' 1281 ], 1282 borderColor: [ 1283 'rgba(255 ,99, 132, 1)', 1284 'rgba(54, 162, 235, 1)', 1285 'rgba(255, 206, 86, 1)', 1286 'rgba(75, 192, 192, 1)' 1287 ], 1288 borderWidth: 1 1289 }] 1290 }, 1291 options: { 1292 cutoutPercentage: 60, 1293 responsive: false, 1294 tooltips: false, 1295 } 1296 }); 1297 } 1298 1299 1300 /* ------------------------------------------------------------------------ */ 1301 /* Fave login and regsiter 1302 /* ------------------------------------------------------------------------ */ 1303 var houzez_login_modal = function() { 1304 jQuery('#login-register-form').modal('show'); 1305 jQuery('.login-form-tab').addClass('active show');
1306 jQuery('.modal-toggle-1.nav-link').addClass('active'); 1307 } 1308 1309 $('#houzez-login-btn').on('click', function(e){ 1310 e.preventDefault(); 1311 var currnt = $(this); 1312 houzez_login( currnt ); 1313 }); 1314 1315 $('#houzez-register-btn').on('click', function(e){ 1316 e.preventDefault(); 1317 var currnt = $(this); 1318 houzez_register( currnt ); 1319 }); 1320 1321 $('#houzez-create-account-btn').on('click', function(e){ 1322 e.preventDefault(); 1323 var currnt = $(this); 1324 houzez_social_create_account( currnt ); 1325 }); 1326 1327 var houzez_login = function( currnt ) { 1328 var $form = currnt.parents('form'); 1329 var $messages = $('#hz-login-messages'); 1330 1331 $.ajax({ 1332 type: 'post', 1333 url: ajaxurl, 1334 dataType: 'json', 1335 data: $form.serialize(), 1336 beforeSend: function( ) { 1337 currnt.find('.houzez-loader-js').addClass('loader-show'); 1338 }, 1339 complete: function(){ 1340 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1341 }, 1342 success: function( response ) { 1343 if( response.success ) { 1344 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1345 1346 window.location.replace( response.redirect_to ); 1347 1348 } else { 1349 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1350 } 1351 1352 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1353 1354 if(houzez_reCaptcha == 1) { 1355 $form.find('.g-recaptcha-response').remove(); 1356 if( g_recaptha_version == 'v3' ) { 1357 houzezReCaptchaLoad(); 1358 } else { 1359 houzezReCaptchaReset(); 1360 } 1361 } 1362 }, 1363 error: function(xhr, status, error) { 1364 console.log("Error Status: " + status); 1365 console.log("Error Thrown: " + error); 1366 console.log("Response Text: " + xhr.responseText); 1367 } 1368 }) 1369 1370 } // end houzez_login 1371 1372 var houzez_register = function ( currnt ) { 1373 1374 var $form = currnt.parents('form'); 1375 var $messages = $('#hz-register-messages'); 1376 1377 $.ajax({ 1378 type: 'post', 1379 url: ajaxurl, 1380 dataType: 'json', 1381 data: $form.serialize(), 1382 beforeSend: function( ) { 1383 currnt.find('.houzez-loader-js').addClass('loader-show'); 1384 }, 1385 complete: function(){ 1386 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1387 }, 1388 success: function( response ) { 1389 if( response.success ) { 1390 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1391 1392 setTimeout(function() { 1393 $('a[href="#login-form-tab"]').tab('show'); 1394 }, 2000); 1395 1396 } else { 1397 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1398 } 1399 1400 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1401 if(houzez_reCaptcha == 1) { 1402 $form.find('.g-recaptcha-response').remove(); 1403 if( g_recaptha_version == 'v3' ) { 1404 houzezReCaptchaLoad(); 1405 } else { 1406 houzezReCaptchaReset(); 1407 } 1408 } 1409 }, 1410 error: function(xhr, status, error) { 1411 console.log("Error Status: " + status); 1412 console.log("Error Thrown: " + error); 1413 console.log("Response Text: " + xhr.responseText); 1414 } 1415 }); 1416 } 1417 1418 var houzez_social_create_account = function ( currnt ) { 1419 1420 var $form = currnt.parents('form'); 1421 var $messages = $('#hz-create-messages'); 1422 1423 $.ajax({ 1424 type: 'post', 1425 url: ajaxurl, 1426 dataType: 'json', 1427 data: $form.serialize(), 1428 beforeSend: function( ) { 1429 currnt.find('.houzez-loader-js').addClass('loader-show'); 1430 }, 1431 complete: function(){ 1432 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1433 }, 1434 success: function( response ) { 1435 if( response.success ) { 1436 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1437 1438 window.location.replace( response.redirect_to ); 1439 1440 } else { 1441 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1442 } 1443 1444 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1445 1446 }, 1447 error: function(xhr, status, error) { 1448 var err = eval("(" + xhr.responseText + ")"); 1449 console.log(err.Message); 1450 } 1451 }); 1452 } 1453 1454 $('#houzez-link-account').on('click', function(e){ 1455 e.preventDefault(); 1456 var currnt = $(this); 1457 houzez_link_account( currnt ); 1458 }); 1459 1460 var houzez_link_account = function ( currnt ) { 1461 1462 var $form = currnt.parents('form'); 1463 var $messages = $('#hz-link-messages'); 1464 1465 $.ajax({ 1466 type: 'post', 1467 url: ajaxurl, 1468 dataType: 'json', 1469 data: $form.serialize(), 1470 beforeSend: function( ) { 1471 currnt.find('.houzez-loader-js').addClass('loader-show'); 1472 }, 1473 complete: function(){ 1474 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1475 }, 1476 success: function( response ) { 1477 if( response.success ) { 1478 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1479 1480 window.location.replace( response.redirect_to ); 1481 1482 } else { 1483 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1484 } 1485 1486 currnt.find('.houzez-loader-js').removeClass('loader-show'); 1487 if(houzez_reCaptcha == 1) { 1488 $form.find('.g-recaptcha-response').remove(); 1489 if( g_recaptha_version == 'v3' ) { 1490 houzezReCaptchaLoad(); 1491 } else { 1492 houzezReCaptchaReset(); 1493 } 1494 } 1495 }, 1496 error: function(xhr, status, error) { 1497 var err = eval("(" + xhr.responseText + ")"); 1498 console.log(err.Message); 1499 } 1500 }); 1501 } 1502 1503 function houzez_social_login_panel() { 1504 var $mainStepWrap = $('.main-step-wrap'); 1505 var $newAccountWrap = $('.new-account-wrap'); 1506 var $linkAccountWrap = $('.link-account-wrap'); 1507 1508 function toggleVisibility(hide1, hide2, show) { 1509 hide1.hide(); 1510 hide2.hide(); 1511 show.show(); 1512 } 1513 1514 $(document).on('click', '.btn-link-account', function(event) { 1515 event.preventDefault(); 1516 toggleVisibility($mainStepWrap, $newAccountWrap, $linkAccountWrap); 1517 }); 1518 1519 $(document).on('click', '.btn-create-account', function(event) { 1520 event.preventDefault(); 1521 toggleVisibility($mainStepWrap, $linkAccountWrap, $newAccountWrap); 1522 }); 1523 1524 $(document).on('click', '.hz-fb-cancel', function(event) { 1525 event.preventDefault(); 1526 toggleVisibility($linkAccountWrap, $newAccountWrap, $mainStepWrap); 1527 }); 1528 } 1529 1530 houzez_social_login_panel(); 1531 1532 $( '#houzez_forgetpass').on('click', function(){ 1533 var user_login = $('#user_login_forgot').val(), 1534 security = $('#fave_resetpassword_security').val(); 1535 1536 var $this = $(this); 1537 var $messages = $('#reset_pass_msg'); 1538 1539 $.ajax({ 1540 type: 'post', 1541 url: ajaxurl, 1542 dataType: 'json', 1543 data: { 1544 'action': 'houzez_reset_password', 1545 'user_login': user_login, 1546 'security': security 1547 }, 1548 beforeSend: function( ) { 1549 $this.find('.houzez-loader-js').addClass('loader-show'); 1550 }, 1551 complete: function(){ 1552 $this.find('.houzez-loader-js').removeClass('loader-show'); 1553 }, 1554 success: function( response ) { 1555 if( response.success ) { 1556 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1557 } else { 1558 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1559 } 1560 }, 1561 error: function(xhr, status, error) { 1562 var err = eval("(" + xhr.responseText + ")"); 1563 console.log(err.Message); 1564 } 1565 }); 1566 1567 }); 1568 1569 1570 if( $('#houzez_reset_password').length > 0 ) { 1571 $('#houzez_reset_password').click( function(e) { 1572 e.preventDefault(); 1573 1574 var $this = $(this); 1575 var rg_login = $('input[name="rp_login"]').val(); 1576 var rp_key = $('input[name="rp_key"]').val(); 1577 var pass1 = $('input[name="pass1"]').val(); 1578 var pass2 = $('input[name="pass2"]').val(); 1579 var security = $('input[name="fave_resetpassword_security"]').val(); 1580 var $messages = $('#reset_pass_msg_2'); 1581 1582 $.ajax({ 1583 type: 'post', 1584 url: ajaxurl, 1585 dataType: 'json', 1586 data: { 1587 'action': 'houzez_reset_password_2', 1588 'rq_login': rg_login, 1589 'password': pass1, 1590 'confirm_pass': pass2, 1591 'rp_key': rp_key, 1592 'security': security 1593 }, 1594 beforeSend: function( ) { 1595 $this.find('.houzez-loader-js').addClass('loader-show'); 1596 }, 1597 complete: function(){ 1598 $this.find('.houzez-loader-js').removeClass('loader-show'); 1599 }, 1600 success: function(response) { 1601 if( response.success ) { 1602 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1603 jQuery('#oldpass, #newpass, #confirmpass').val(''); 1604 } else { 1605 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.msg +'</div>'); 1606 } 1607 }, 1608 error: function(errorThrown) { 1609 1610 } 1611 1612 }); 1613 1614 } ); 1615 } 1616 1617 1618 $('.hz-facebook-login').on('click', function () { 1619 var current = $(this); 1620 houzez_login_via_facebook( current ); 1621 }); 1622 1623 var houzez_login_via_facebook = function ( current ) { 1624 var $messages = $('.hz-social-messages'); 1625 1626 $.ajax({ 1627 type: 'POST', 1628 url: ajaxurl, 1629 dataType: 'json', 1630 data: { 1631 'action' : 'houzez_facebook_login_oauth' 1632 }, 1633 beforeSend: function( ) { 1634 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ login_loading +'</div>'); 1635 current.find('.houzez-loader-js').addClass('loader-show'); 1636 }, 1637 complete: function(){ 1638 current.find('.houzez-loader-js').removeClass('loader-show'); 1639 }, 1640 success: function (response) { 1641 if(response.success) { 1642 window.location.replace( response.url ); 1643 } else { 1644 $messages.empty().append('<div class="alert alert-danger" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ response.message +'</div>'); 1645 } 1646 1647 }, 1648 error: function(xhr, status, error) { 1649 var err = eval("(" + xhr.responseText + ")"); 1650 console.log(err.Message); 1651 } 1652 }); 1653 } 1654 1655 $('.hz-google-login').on('click', function () { 1656 var current = $(this); 1657 houzez_login_via_google( current ); 1658 }); 1659 1660 var houzez_login_via_google = function ( current ) { 1661 var $form = current.parents('form'); 1662 var $messages = $('#hz-login-messages'); 1663 1664 $.ajax({ 1665 type: 'POST', 1666 url: ajaxurl, 1667 data: { 1668 'action' : 'houzez_google_login_oauth' 1669 }, 1670 beforeSend: function( ) { 1671 $messages.empty().append('<div class="alert alert-success" role="alert"><i class="houzez-icon icon-check-circle-1 mr-1"></i>'+ login_loading +'</div>'); 1672 current.find('.houzez-loader-js').addClass('loader-show'); 1673 }, 1674 complete: function(){ 1675 current.find('.houzez-loader-js').removeClass('loader-show'); 1676 }, 1677 success: function (data) { 1678 window.location.replace( data ); 1679 }, 1680 error: function(xhr, status, error) { 1681 var err = eval("(" + xhr.responseText + ")"); 1682 console.log(err.Message); 1683 } 1684 }); 1685 } 1686 1687 /*-------------------------------------------------------------------------- 1688 * Property Module Ajax Pagination 1689 * -------------------------------------------------------------------------*/ 1690 var properties_module_section = $('#properties_module_section'); 1691 if( properties_module_section.length > 0 ) { 1692 1693 $("body").on('click', '.fave-load-more a', function(e) { 1694 e.preventDefault(); 1695 var $this = $(this); 1696 var $wrap = $this.closest('#properties_module_section').find('#module_properties'); 1697 var prop_limit = $this.data('prop-limit'); 1698 var paged = $this.data('paged');
1699 var card_version = $this.data('card'); 1700 var type = $this.data('type'); 1701 var status = $this.data('status'); 1702 var state = $this.data('state'); 1703 var city = $this.data('city'); 1704 var country = $this.data('country'); 1705 var area = $this.data('area'); 1706 var label = $this.data('label'); 1707 var user_role = $this.data('user-role'); 1708 var featured_prop = $this.data('featured-prop'); 1709 var offset = $this.data('offset'); 1710 var sortby = $this.data('sortby'); 1711 1712 $.ajax({ 1713 type: 'POST', 1714 url: ajaxurl, 1715 data: { 1716 'action': 'houzez_loadmore_properties', 1717 'prop_limit': prop_limit, 1718 'paged': paged, 1719 'card_version': card_version, 1720 'type': type, 1721 'status': status, 1722 'state': state, 1723 'city': city, 1724 'country': country, 1725 'area': area, 1726 'label': label, 1727 'user_role': user_role, 1728 'featured_prop': featured_prop, 1729 'sort_by': sortby, 1730 'offset': offset 1731 }, 1732 beforeSend: function( ) { 1733 $this.find('.houzez-loader-js').addClass('loader-show'); 1734 }, 1735 complete: function(){ 1736 $this.find('.houzez-loader-js').removeClass('loader-show'); 1737 }, 1738 success: function (data) { 1739 if(data == 'no_result') { 1740 $this.closest('#properties_module_section').find('.fave-load-more').fadeOut('fast').remove(); 1741 return; 1742 } 1743 var $wrap = $this.closest('#properties_module_section').find('#module_properties'); 1744 $wrap.append(data); 1745 $this.data("paged", paged+1); 1746 $this.find('i').remove(); 1747 1748 houzez_init_add_favorite(ajaxurl, userID); 1749 houzez_init_remove_favorite(ajaxurl, userID); 1750 houzez_listing_lightbox(ajaxurl, processing_text, houzez_rtl, userID); 1751 houzez_grid_image_gallery(); 1752 houzez_grid_call_to_action(); 1753 compare_for_ajax(); 1754 $('[data-toggle="tooltip"]').tooltip(); 1755 1756 }, 1757 error: function (xhr, status, error) { 1758 var err = eval("(" + xhr.responseText + ")"); 1759 console.log(err.Message); 1760 } 1761 1762 }); 1763 1764 }); 1765 1766 } 1767 1768 /*-------------------------------------------------------------------------- 1769 * Property Infinite load 1770 * -------------------------------------------------------------------------*/ 1771 /*$('.houzez-infinite-load').on('click', function(e) { 1772 e.preventDefault(); 1773 //$(window).scroll(function() { 1774 1775 var $nextPageLink = $('.btn-load-more').attr('href'); 1776 var nextPageUrl = $nextPageLink; 1777 1778 if (nextPageUrl) { 1779 1780 //if ($(window).scrollTop() == $(document).height() - $(window).height()) { alert('dg'); 1781 1782 window.history.pushState({HouzezTheme: true}, '', nextPageUrl); 1783 1784 self.filterAjax = $.ajax({ 1785 url: nextPageUrl, 1786 data: { 1787 load_type: 'items' 1788 }, 1789 dataType: 'html', 1790 cache: false, 1791 headers: {'cache-control': 'no-cache'}, 1792 method: 'GET', 1793 error: function(XMLHttpRequest, textStatus, errorThrown) { 1794 console.log('Houzez: AJAX error - houzezAjaxPagination() - ' + errorThrown); 1795 }, 1796 complete: function() { 1797 1798 }, 1799 success: function(response) {
1800 var $response = $('<div>' + response + '</div>'); // Wrap the returned HTML string in a dummy 'div' element we can get the elements 1801 1802 $('.listing-view').append(response); 1803 console.log($response); 1804 // Get the 'next page' URL 1805 nextPageUrl = $response.find('.page-id').attr('data-page'); 1806 alert(nextPageUrl); 1807 if (nextPageUrl) { 1808 $('.btn-load-more').attr('href', nextPageUrl); 1809 } else { 1810 $('#fave-pagination-loadmore').remove(); 1811 } 1812 1813 1814 } 1815 }); 1816 //} 1817 } 1818 });*/ 1819 1820 /*-------------------------------------------------------------------------- 1821 * Change search price on status change 1822 * -------------------------------------------------------------------------*/ 1823 var property_status_changed = function(prop_status, $form) { 1824 1825 if( prop_status == for_rent ) { 1826 $form.find('.prices-for-all').addClass('hide'); 1827 $form.find('.prices-for-all select').attr('disabled','disabled'); 1828 $form.find('.prices-only-for-rent').removeClass('hide'); 1829 $form.find('.prices-only-for-rent select').removeAttr('disabled','disabled'); 1830 $form.find('.prices-only-for-rent select').selectpicker('refresh'); 1831 } else { 1832 $form.find('.prices-only-for-rent').addClass('hide'); 1833 $form.find('.prices-only-for-rent select').attr('disabled','disabled'); 1834 $form.find('.prices-for-all').removeClass('hide'); 1835 $form.find('.prices-for-all select').removeAttr('disabled','disabled'); 1836 $form.find('.prices-for-all select').selectpicker('refresh'); 1837 } 1838 } 1839 $('.status-js').on('change', function(e) { 1840 var selected_status = $(this).val(); 1841 var $form = $(this).parents('form'); 1842 property_status_changed(selected_status, $form); 1843 }); 1844 1845 $('.status-tab-js').on('click', function() { 1846 var tab_selected_status = $(this).data('val'); 1847 var $form = $(this).parents('form'); 1848 property_status_changed(tab_selected_status, $form); 1849 }); 1850 1851 1852 1853 /* On page load*/ 1854 var selected_status = $('.status-js').val(); 1855 if( selected_status == for_rent ) { 1856 var $form = $('.houzez-search-form-js'); 1857 property_status_changed(selected_status, $form); 1858 } else { 1859 var $form = $('.houzez-search-form-js'); 1860 property_status_changed('dummy', $form); 1861 } 1862 1863 /* On page load status tab */ 1864 var selected_status_tab = $('.status-tab-js').val(); 1865 if( selected_status_tab == for_rent ) { 1866 var $tab_form = $('.houzez-search-builder-form-js'); 1867 property_status_changed(selected_status_tab, $tab_form); 1868 } else { 1869 var $tab_form = $('.houzez-search-builder-form-js'); 1870 property_status_changed( selected_status_tab, $tab_form ); 1871 } 1872 1873 /* ------------------------------------------------------------------------ */ 1874 /* Price Range Slider 1875 /* ------------------------------------------------------------------------ */ 1876 var price_range_search = function( min_price, max_price ) { 1877 $(".price-range").slider({ 1878 range: true, 1879 min: min_price, 1880 max: max_price, 1881 values: [min_price, max_price], 1882 slide: function (event, ui) { 1883 if( currency_position == 'after' ) { 1884 var min_price_range = thousandSeparator(ui.values[0]) + currency_symb; 1885 var max_price_range = thousandSeparator(ui.values[1]) + currency_symb; 1886 } else { 1887 var min_price_range = currency_symb + thousandSeparator(ui.values[0]); 1888 var max_price_range = currency_symb + thousandSeparator(ui.values[1]); 1889 } 1890 $(".min-price-range-hidden").val( ui.values[0] ); 1891 $(".max-price-range-hidden").val( ui.values[1] ); 1892 1893 $(".min-price-range").text( min_price_range ); 1894 $(".max-price-range").text( max_price_range ); 1895 }, 1896 stop: function( event, ui ) { 1897 1898 }, 1899 change: function( event, ui ) { } 1900 }); 1901 1902 if( currency_position == 'after' ) { 1903 var min_price_range = thousandSeparator($(".price-range").slider("values", 0)) + currency_symb; 1904 var max_price_range = thousandSeparator($(".price-range").slider("values", 1)) + currency_symb; 1905 } else { 1906 var min_price_range = currency_symb + thousandSeparator($(".price-range").slider("values", 0)); 1907 var max_price_range = currency_symb + thousandSeparator($(".price-range").slider("values", 1)); 1908 } 1909 1910 $(".min-price-range").text(min_price_range); 1911 $(".max-price-range").text(max_price_range); 1912 $(".min-price-range-hidden").val($(".price-range").slider("values", 0)); 1913 $(".max-price-range-hidden").val($(".price-range").slider("values", 1)); 1914 1915 } 1916 1917 if($( ".price-range").length > 0 && is_halfmap != 1) { 1918 var selected_status_adv_search = $('.status-js').val(); 1919 if( selected_status_adv_search == for_rent_price_slider ){ 1920 price_range_search(search_price_range_min_rent, search_price_range_max_rent); 1921 } else { 1922 price_range_search( search_price_range_min, search_price_range_max ); 1923 } 1924 1925 $('.status-js').on('change', function(){ 1926 var search_status = $(this).val(); 1927 if( search_status == for_rent_price_slider ) { 1928 price_range_search(search_price_range_min_rent, search_price_range_max_rent); 1929 } else { 1930 price_range_search( search_price_range_min, search_price_range_max ); 1931 } 1932 }); 1933 1934 $('.status-tab-js').on('click', function() { 1935 var tab_status = $(this).data('val'); 1936 if( tab_status == for_rent_price_slider ) { 1937 price_range_search(search_price_range_min_rent, search_price_range_max_rent); 1938 } else { 1939 price_range_search( search_price_range_min, search_price_range_max ); 1940 } 1941 }); 1942 } 1943 1944 /*-----------------------------------------------------------------------------------*/ 1945 /* Search Status tabs 1946 /*-----------------------------------------------------------------------------------*/ 1947 $('.houzez-status-tabs li a').on('click', function(e) { 1948 e.preventDefault(); 1949 var $this = $(this); 1950 var status = $this.data('val'); 1951 1952 $('#search-tabs').val(status); 1953 1954 var $form = $('.houzez-search-form-js'); 1955 property_status_changed(status, $form); 1956 1957 }); 1958 1959 1960 /*-----------------------------------------------------------------------------------*/ 1961 /* PROPERTIES SORTING 1962 /*-----------------------------------------------------------------------------------*/ 1963 function insertParam(key, value) { 1964 key = encodeURI(key); 1965 value = encodeURI(value); 1966 1967 // get querystring , remove (?) and covernt into array 1968 var qrp = document.location.search.substr(1).split('&'); 1969 1970 // get qrp array length 1971 var i = qrp.length; 1972 var j; 1973 while (i--) { 1974 //covert query strings into array for check key and value 1975 j = qrp[i].split('='); 1976 1977 // if find key and value then join 1978 if (j[0] == key) { 1979 j[1] = value; 1980 qrp[i] = j.join('='); 1981 break; 1982 } 1983 } 1984 1985 if (i < 0) { 1986 qrp[qrp.length] = [key, value].join('='); 1987 } 1988 // reload the page 1989 document.location.search = qrp.join('&'); 1990 1991 } 1992 1993 $('#sort_properties').on('change', function() { 1994 var key = 'sortby'; 1995 var value = $(this).val();
1996 insertParam( key, value ); 1997 }); 1998 1999 $('#insights_filter').on('change', function() { 2000 var key = 'listing_id'; 2001 var value = $(this).val(); 2002 insertParam( key, value ); 2003 }); 2004 2005 $('#houzez-gmap-full').on('click', function() { 2006 var $this = $(this); 2007 if($this.hasClass('active')) { 2008 $this.removeClass('active'); 2009 $this.parents('.map-wrap').removeClass('houzez-fullscreen-map'); 2010 } else { 2011 $this.parents('.map-wrap').addClass('houzez-fullscreen-map'); 2012 $this.addClass('active'); 2013 } 2014 2015 }); 2016 2017 /*-------------------------------------------------------------------------- 2018 * Property Agent Contact Form 2019 * -------------------------------------------------------------------------*/ 2020 $( '.houzez_agent_property_form').on('click', function(e) { 2021 e.preventDefault(); 2022 2023 var $result; 2024 var $this = $(this); 2025 var $form = $this.parents( 'form' ); 2026 var $form_wrap = $this.parents( '.property-form-wrap' ); 2027 $result = $form_wrap.find('.form_messages'); 2028 var $is_bottom = $('.is_bottom').val(); 2029 if($is_bottom == 'bottom') { 2030 $result = $form.find('.form_messages'); 2031 } 2032 $result.empty(); 2033 2034 $.ajax({ 2035 url: ajaxurl, 2036 data: $form.serialize(), 2037 method: $form.attr('method'), 2038 dataType: "JSON", 2039 2040 beforeSend: function( ) { 2041 $this.find('.houzez-loader-js').addClass('loader-show'); 2042 }, 2043 success: function(response) { 2044 if( response.success ) { 2045 2046 $form.find('input[name="name"], input[name="mobile"], input[name="email"]').val(''); 2047 $form.find('textarea').val(''); 2048 if($is_bottom == 'bottom') { 2049 $result.empty().append('<div class="alert alert-success alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2050 } else { 2051 $result.empty().append('<p class="success text-success"><i class="fa fa-check"></i> '+ response.msg +'</p>'); 2052 } 2053 } else { 2054 if($is_bottom == 'bottom') { 2055 $result.empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2056 } else { 2057 $result.empty().append('<p class="error text-danger"><i class="fas fa-times"></i> '+ response.msg +'</p>'); 2058 } 2059 } 2060 2061 $this.find('.houzez-loader-js').removeClass('loader-show'); 2062 2063 if(houzez_reCaptcha == 1) { 2064 $form.find('.g-recaptcha-response').remove(); 2065 if( g_recaptha_version == 'v3' ) { 2066 houzezReCaptchaLoad(); 2067 } else { 2068 houzezReCaptchaReset(); 2069 } 2070 } 2071 2072 if( houzez_vars.agent_redirection != '' && response.success ) { 2073 setTimeout(function(){ 2074 window.location.replace(houzez_vars.agent_redirection); 2075 }, 500); 2076 } 2077 2078 }, 2079 error: function(xhr, status, error) { 2080 var err = eval("(" + xhr.responseText + ")"); 2081 console.log(err.Message); 2082 }, 2083 complete: function(){ 2084 $this.find('.houzez-loader-js').removeClass('loader-show'); 2085 } 2086 }); 2087 }); 2088 2089 /*-------------------------------------------------------------------------- 2090 * Direct message 2091 * -------------------------------------------------------------------------*/ 2092 $('.msg-login-required').on('click', function() { 2093 $('.modal-toggle-1').addClass("active"); 2094 jQuery('.login-form-tab').addClass('active show'); 2095 }); 2096 2097 $( '.houzez-send-message').on('click', function(e) { 2098 e.preventDefault(); 2099 2100 var $result; 2101 var $this = $(this); 2102 var $form = $this.parents( 'form' ); 2103 var $form_wrap = $this.parents( '.property-form-wrap' ); 2104 $result = $form_wrap.find('.form_messages'); 2105 var $is_bottom = $('.is_bottom').val(); 2106 if($is_bottom == 'bottom') { 2107 $result = $form.find('.form_messages'); 2108 } 2109 $result.empty(); 2110 2111 var property_id = $('input[name="listing_id"]').val(); 2112 var message = $form.find('.hz-form-message').val(); 2113 var security = $('input[name="property_agent_contact_security"]').val(); 2114 2115 $.ajax({ 2116 url: ajaxurl, 2117 data: { 2118 'action' : 'houzez_start_thread', 2119 'property_id' : property_id, 2120 'message' : message, 2121 'start_thread_form_ajax' : security, 2122 }, 2123 method: $form.attr('method'), 2124 dataType: "JSON", 2125 2126 beforeSend: function( ) { 2127 $this.find('.houzez-loader-js').addClass('loader-show'); 2128 }, 2129 success: function(response) { 2130 if( response.success ) { 2131 2132 $form.find('input[name="name"], input[name="mobile"], input[name="email"]').val(''); 2133 $form.find('textarea').val(''); 2134 if($is_bottom == 'bottom') { 2135 $result.empty().append('<div class="alert alert-success alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2136 } else { 2137 $result.empty().append('<p class="success text-success"><i class="fa fa-check"></i> '+ response.msg +'</p>'); 2138 } 2139 } else { 2140 if($is_bottom == 'bottom') { 2141 $result.empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2142 } else { 2143 $result.empty().append('<p class="error text-danger"><i class="fas fa-times"></i> '+ response.msg +'</p>'); 2144 } 2145 } 2146 2147 $this.find('.houzez-loader-js').removeClass('loader-show'); 2148 2149 if(houzez_reCaptcha == 1) { 2150 $form.find('.g-recaptcha-response').remove(); 2151 if( g_recaptha_version == 'v3' ) { 2152 houzezReCaptchaLoad(); 2153 } else { 2154 houzezReCaptchaReset(); 2155 } 2156 } 2157 2158 if( houzez_vars.agent_redirection != '' ) { 2159 setTimeout(function(){ 2160 window.location.replace(houzez_vars.agent_redirection); 2161 }, 500); 2162 } 2163 2164 }, 2165 error: function(xhr, status, error) { 2166 var err = eval("(" + xhr.responseText + ")"); 2167 console.log(err.Message); 2168 }, 2169 complete: function(){ 2170 $this.find('.houzez-loader-js').removeClass('loader-show'); 2171 } 2172 }); 2173 }); 2174 2175 2176 /*
2177 * Property Thread Message Form 2178 * -----------------------------*/ 2179 $( '.start_thread_message_form').on('click', function(e) { 2180 2181 e.preventDefault(); 2182 2183 var $this = $(this); 2184 var $form = $this.parents( 'form' ); 2185 var $result = $form.find('.form_messages'); 2186 2187 $.ajax({ 2188 url: ajaxurl, 2189 data: $form.serialize(), 2190 method: $form.attr('method'), 2191 dataType: "JSON", 2192 2193 beforeSend: function( ) { 2194 $this.find('.houzez-loader-js').addClass('loader-show'); 2195 }, 2196 success: function( response ) { 2197 $this.find('.houzez-loader-js').removeClass('loader-show'); 2198 window.location.replace( response.url ); 2199 }, 2200 complete: function(){ 2201 $this.find('.houzez-loader-js').removeClass('loader-show'); 2202 } 2203 }); 2204 2205 }); 2206 2207 /*-------------------------------------------------------------------------- 2208 * Contact agent form on agent detail page 2209 * -------------------------------------------------------------------------*/ 2210 $('#contact_realtor_btn').on('click', function(e) { 2211 e.preventDefault(); 2212 var current_element = $(this); 2213 var $this = $(this); 2214 var $form = $this.parents( 'form' ); 2215 2216 jQuery.ajax({ 2217 type: 'post', 2218 url: ajaxurl, 2219 data: $form.serialize(), 2220 method: $form.attr('method'), 2221 dataType: "JSON", 2222 2223 beforeSend: function( ) { 2224 $this.find('.houzez-loader-js').addClass('loader-show'); 2225 }, 2226 success: function( res ) { 2227 if( res.success ) { 2228 $('.form_messages').empty().append('<div class="alert alert-success alert-dismissible fade show" role="alert">'+res.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2229 } else { 2230 $('.form_messages').empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+res.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2231 } 2232 2233 $this.find('.houzez-loader-js').removeClass('loader-show'); 2234 if(houzez_reCaptcha == 1) { 2235 $form.find('.g-recaptcha-response').remove(); 2236 if( g_recaptha_version == 'v3' ) { 2237 houzezReCaptchaLoad(); 2238 } else { 2239 houzezReCaptchaReset(); 2240 } 2241 } 2242 }, 2243 error: function(xhr, status, error) { 2244 var err = eval("(" + xhr.responseText + ")"); 2245 console.log(err.Message); 2246 }, 2247 complete: function(){ 2248 $this.find('.houzez-loader-js').removeClass('loader-show'); 2249 } 2250 2251 }); 2252 }); 2253 2254 /*-------------------------------------------------------------------------- 2255 * AutoComplete Search 2256 * -------------------------------------------------------------------------*/ 2257 if( keyword_autocomplete != 0 ) { 2258 var houzezAutoComplete = function () { 2259 2260 var ajaxCount = 0; 2261 var auto_complete_container = $('.auto-complete'); 2262 var lastLenght = 0; 2263 2264 $( 'body' ).on('keyup', '.houzez-keyword-autocomplete', HouzezDebounce(function() { 2265 2266 var $this = $( this ); 2267 var $dataType = $this.data('type'); 2268 var $form = $this.parents( 'form'); 2269 2270 if( $dataType == 'banner' ) { 2271 var auto_complete_container = $( '#houzez-auto-complete-banner' ); 2272 } else { 2273 var auto_complete_container = $form.find( '.auto-complete' ); 2274 } 2275 2276 var keyword = $( this ).val(); 2277 2278 keyword = $.trim( keyword ); 2279 var currentLenght = keyword.length; 2280 2281 if ( currentLenght >= 2 && currentLenght != lastLenght ) { 2282 2283 lastLenght = currentLenght; 2284 auto_complete_container.fadeIn(); 2285 2286 $.ajax({ 2287 type: 'POST', 2288 url: ajaxurl, 2289 data: { 2290 'action': 'houzez_get_auto_complete_search', 2291 'key': keyword, 2292 }, 2293 beforeSend: function( ) { 2294 ajaxCount++; 2295 if ( ajaxCount == 1 ) { 2296 auto_complete_container.html('<ul class="list-group"><li class="list-group-item"><i class="fa fa-spinner fa-spin fa-fw"></i> '+autosearch_text+ '</li></ul>'); 2297 } 2298 }, 2299 success: function(data) { 2300 ajaxCount--; 2301 if ( ajaxCount == 0 ) { 2302 auto_complete_container.show(); 2303 if( data != '' ) { 2304 auto_complete_container.empty().html(data).bind(); 2305 } 2306 } 2307 }, 2308 error: function(errorThrown) { 2309 ajaxCount--; 2310 if ( ajaxCount == 0 ) { 2311 auto_complete_container.html('<ul class="list-group"><li class="list-group-item"><i class="fa fa-spinner fa-spin fa-fw"></i> '+autosearch_text+ '</li></ul>'); 2312 } 2313 } 2314 }); 2315 2316 } else { 2317 if ( currentLenght != lastLenght ) { 2318 auto_complete_container.fadeOut(); 2319 } 2320 } 2321 2322 }, 400)); // 500 milliseconds as the delay 2323 auto_complete_container.on( 'click', 'li', function (){ 2324 $('.houzez-keyword-autocomplete').val( $( this ).data( 'text' ) ); 2325 auto_complete_container.fadeOut(); 2326 }).bind(); 2327 } 2328 houzezAutoComplete(); 2329 } 2330 2331 /*-------------------------------------------------------------------------- 2332 * Save Search 2333 * -------------------------------------------------------------------------*/ 2334 $(".save_search_click").on('click', function(e) { 2335 e.preventDefault(); 2336 2337 var $this = $(this); 2338 2339 var search_args = $('input[name="search_args"]').val(); 2340 var security = $('input[name="houzez_save_search_ajax"]').val(); 2341 var search_URI = $('input[name="search_URI"]').val(); 2342 2343 if( parseInt( userID, 10 ) === 0 ) { 2344 houzez_login_modal(); 2345 } else { 2346 $.ajax({ 2347 url: ajaxurl, 2348 data: { 2349 'action': 'houzez_save_search', 2350 'search_args': search_args, 2351 'search_URI': search_URI, 2352 'houzez_save_search_ajax': security, 2353 }, 2354 method: 'POST', 2355 dataType: 'JSON', 2356 2357 beforeSend: function () { 2358 $this.find('.houzez-loader-js').addClass('loader-show'); 2359 }, 2360 success: function (response) { 2361 if (response.success) { 2362 $('.save_search_click').attr('disabled', true); 2363 } 2364 }, 2365 error: function (xhr, status, error) { 2366 var err = eval("(" + xhr.responseText + ")"); 2367 console.log(err.Message); 2368 }, 2369 complete: function () { 2370 $this.find('.houzez-loader-js').removeClass('loader-show'); 2371 } 2372 }); 2373 } 2374 2375 }); 2376 2377 2378 /*-------------------------------------------------------------------------- 2379 * Property Schedule Contact Form 2380 * -------------------------------------------------------------------------*/ 2381 $( '.schedule_contact_form').on('click', function(e) { 2382 e.preventDefault(); 2383 2384 var $this = $(this); 2385 var $form = $this.parents( 'form' ); 2386 var $result = $form.find('.form_messages'); 2387 2388 $.ajax({ 2389 url: ajaxurl, 2390 data: $form.serialize(), 2391 method: $form.attr('method'), 2392 dataType: "JSON", 2393 2394 beforeSend: function( ) { 2395 $this.find('.houzez-loader-js').addClass('loader-show'); 2396 }, 2397 success: function(response) { 2398 if( response.success ) { 2399 $form.find('input[name="name"], input[name="phone"], input[name="email"]').val(''); 2400 $form.find('textarea').val(''); 2401 $result.empty().append('<div class="alert alert-success alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2402 2403 if( typeof response.redirect_to !=='undefined' && response.redirect_to != '' ) { 2404 setTimeout(function(){ 2405 window.location.replace(response.redirect_to); 2406 }, 500); 2407 } 2408 2409 } else { 2410 $result.empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2411 } 2412 }, 2413 error: function(xhr, status, error) { 2414 var err = eval("(" + xhr.responseText + ")"); 2415 console.log(err.Message); 2416 }, 2417 complete: function(){ 2418 $this.find('.houzez-loader-js').removeClass('loader-show'); 2419 } 2420 }); 2421 2422 }); 2423 2424 /* ------------------------------------------------------------------------ */ 2425 /* autocomplete result position 2426 /* ------------------------------------------------------------------------ */ 2427 function setAutoCompleteResultPosition() { 2428 var parallax_banner_inner_height = $('.top-banner-wrap').innerHeight(); 2429 var banner_caption_inner_height = $('.banner-caption').innerHeight(); 2430 var autocomplete_search_position = (parallax_banner_inner_height - (parallax_banner_inner_height - banner_caption_inner_height) / 2); 2431 2432 $('#houzez-auto-complete-banner').css('top', autocomplete_search_position); 2433 } 2434 2435 /* ------------------------------------------------------------------------ */ 2436 /* Elementor Mobile menu trigger 2437 /* ------------------------------------------------------------------------ */ 2438 2439 $('.houzez-nav-menu-main-mobile-wrap .houzez-menu-toggle').click(function (e) { 2440 $('.houzez-nav-menu-main-mobile-wrap .navbar-nav, .houzez-nav-menu-main-mobile-wrap .houzez-menu-toggle').toggleClass('houzez-nav-menu-active'); 2441 }); 2442 2443 2444 $(window).on('load', function(){ 2445 setAutoCompleteResultPosition(); 2446 }); 2447 2448 $win.on('resize', function () { 2449 setAutoCompleteResultPosition(); 2450 }); 2451 2452 /*-----------------------------------------------------------------------------------*/ 2453 /* Print Property 2454 /*-----------------------------------------------------------------------------------*/ 2455 if( $('.houzez-print').length > 0 ) { 2456 $('.houzez-print').on('click', function (e) { 2457 e.preventDefault(); 2458 var propID, printWindow; 2459 2460 propID = $(this).attr('data-propid'); 2461 2462 printWindow = window.open('', 'Print Me', 'width=800 ,height=842'); 2463 $.ajax({ 2464 type: 'POST', 2465 url: ajaxurl, 2466 data: { 2467 'action': 'houzez_create_print', 2468 'propid': propID, 2469 }, 2470 success: function (data) { 2471 printWindow.document.write(data); 2472 printWindow.document.close(); 2473 printWindow.focus(); 2474 }, 2475 error: function (xhr, status, error) { 2476 var err = eval("(" + xhr.responseText + ")"); 2477 console.log(err.Message); 2478 } 2479 2480 }); 2481 }); 2482 } 2483 2484 /*-----------------------------------------------------------------------------------*/ 2485 /* Reviews like dislike 2486 /*-----------------------------------------------------------------------------------*/ 2487 var review_likes = function() { 2488 $('.hz-like-dislike-js').on('click', function(e) { 2489 e.preventDefault(); 2490 var $this = jQuery(this); 2491 var $parent = $this.parents('.likes-container-js'); 2492 2493 if($this.hasClass('already-voted')){ 2494 $parent.find( '.vote-msg' ).text($this.data('msg')).show(); 2495 var hideMessage = function(){ 2496 $parent.find( '.vote-msg' ).hide(); 2497 }; 2498 setTimeout(hideMessage, 3000); 2499 2500 } else { 2501 2502 var review_id = $this.data('id'); 2503 var type = $this.data('type'); 2504 2505 $.ajax({ 2506 type: 'post', 2507 url: ajaxurl, 2508 dataType: "JSON", 2509 data: { 2510 'action': 'reviews_likes_dislikes', 2511 'type': type, 2512 'review_id': review_id, 2513 }, 2514 beforeSend: function( ) { 2515 $parent.find('.vote-msg').empty(); 2516 $parent.find('.houzez-loader-js').addClass('loader-show'); 2517 2518 if(type == 'likes') { 2519 $('.review-dislike-button a').removeClass('already-voted'); 2520 } else if(type == 'dislikes') { 2521 $('.review-like-button a').removeClass('already-voted'); 2522 } 2523 }, 2524 success: function(res) { 2525 if(res.success) { 2526 $parent.find('.likes-count').text(res.likes); 2527 $parent.find('.dislikes-count').text(res.dislikes); 2528 $parent.find('.vote-msg').text(res.msg).show(); 2529 } else { 2530 $parent.find('.vote-msg').text(res.msg).show(); 2531 } 2532 2533 var hideMessage = function(){ 2534 $parent.find( '.vote-msg' ).hide(); 2535 }; 2536 setTimeout(hideMessage, 3000); 2537 $this.addClass('already-voted'); 2538 }, 2539 error: function(xhr, status, error) { 2540 var err = eval("(" + xhr.responseText + ")"); 2541 console.log(err.Message); 2542 }, 2543 complete: function(){ 2544 $parent.find('.houzez-loader-js').removeClass('loader-show'); 2545 } 2546 2547 }); 2548 } 2549 2550 }); 2551 } 2552 review_likes(); 2553 2554 2555 /*-----------------------------------------------------------------------------------*/ 2556 /* Reviews 2557 /*-----------------------------------------------------------------------------------*/ 2558 $('#submit-review').on('click', function(e) { 2559 e.preventDefault(); 2560 2561 var $this = $(this); 2562 var $form = $this.parents( 'form' ); 2563 var $result = $form.find('.form_messages'); 2564 2565 $.ajax({ 2566 url: ajaxurl, 2567 data: $form.serialize(), 2568 method: $form.attr('method'), 2569 dataType: "JSON", 2570 2571 beforeSend: function( ) { 2572 $this.find('.houzez-loader-js').addClass('loader-show'); 2573 }, 2574 success: function(response) { 2575 if( response.success ) { 2576 $result.empty().append('<div class="alert alert-success alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label=
2576"Close"><span aria-hidden="true">×</span></button></div>'); 2577 window.location.replace( response.review_link ); 2578 } else { 2579 $result.empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 2580 } 2581 }, 2582 error: function(xhr, status, error) { 2583 var err = eval("(" + xhr.responseText + ")"); 2584 console.log(err.Message); 2585 }, 2586 complete: function() { 2587 $this.find('.houzez-loader-js').removeClass('loader-show'); 2588 } 2589 }); 2590 }); 2591 2592 var listing_review_ajax = function(sortby, listing_id, paged) { 2593 var review_container = $('#houzez_reviews_container'); 2594 var review_post_type = $('input[name="review_post_type"]').val(); 2595 2596 $.ajax({ 2597 type: 'post', 2598 url: ajaxurl, 2599 data: { 2600 'action': 'houzez_ajax_review', 2601 'sortby': sortby, 2602 'listing_id': listing_id, 2603 'review_post_type': review_post_type, 2604 'paged': paged 2605 }, 2606 beforeSend: function( ) { 2607 2608 review_container.empty().append('' 2609 +'<div id="houzez-map-loading">' 2610 +'<div class="mapPlaceholder">' 2611 +'<div class="loader-ripple spinner">' 2612 +'<div class="bounce1"></div>' 2613 +'<div class="bounce2"></div>' 2614 +'<div class="bounce3"></div>' 2615 +'</div>' 2616 +'</div>' 2617 +'</div>' 2618 ); 2619 2620 $('html, body').animate({ 2621 scrollTop: $("#property-review-wrap").offset().top-50 2622 }, 'slow'); 2623 }, 2624 success: function(data) { 2625 review_container.empty(); 2626 review_container.html(data); 2627 review_likes(); 2628 2629 }, 2630 error: function(xhr, status, error) { 2631 var err = eval("(" + xhr.responseText + ")"); 2632 console.log(err.Message); 2633 }, 2634 complete: function(){ 2635 2636 } 2637 2638 }); 2639 } 2640 2641 if($('#sort_review').length > 0) { 2642 $('#sort_review').on('change', function() { 2643 var sortby = $(this).val(); 2644 var listing_id = $('input[name="listing_id"]').val(); 2645 var paged = 1; 2646 $('#review_paged').val(paged); 2647 $('#review_prev').attr('disabled', true); 2648 $('#review_next').attr('disabled', false); 2649 listing_review_ajax(sortby, listing_id, paged); 2650 return; 2651 }); 2652 } 2653 2654 if($('#review_next').length > 0) { 2655 $('#review_next').on('click', function(e) { 2656 e.preventDefault(); 2657 $('#review_prev').removeAttr('disabled'); 2658 var sortby = $('#sort_review').val(); 2659 var total_pages = $('#total_pages').val(); 2660 var listing_id = $('input[name="listing_id"]').val(); 2661 var paged = $('#review_paged').val(); 2662 paged = Number(paged)+1; 2663 $('#review_paged').val(paged); 2664 2665 if(paged == total_pages) { 2666 $(this).attr('disabled', true); 2667 } 2668 listing_review_ajax(sortby, listing_id, paged); 2669 return; 2670 }); 2671 } 2672 2673 if($('#review_prev').length > 0) { 2674 $('#review_prev').on('click', function(e) { 2675 e.preventDefault(); 2676 $('#review_next').removeAttr('disabled'); 2677 var sortby = $('#sort_review').val(); 2678 var listing_id = $('input[name="listing_id"]').val(); 2679 var paged = $('#review_paged').val(); 2680 paged = Number(paged)-1; 2681 $('#review_paged').val(paged); 2682 if(paged <= 1) { 2683 $(this).attr('disabled', true); 2684 } 2685 listing_review_ajax(sortby, listing_id, paged); 2686 return; 2687 }); 2688 } 2689 2690 /* ------------------------------------------------------------------------ */ 2691 /* Houzez Select Filter 2692 /* ------------------------------------------------------------------------ */ 2693 function houzezSelectFilter($this, $dataRef, $list_num = '', is_on_load = '') { 2694 var e = $this.data("target"), 2695 i = $this.find(":selected").data("ref"); 2696 2697 if( is_on_load == 'yes' ) { 2698 e = $list_num; 2699 i = $dataRef; 2700 } 2701 2702 $("select." + e).val(""), 2703 null == i 2704 ? $("select." + e) 2705 .find("option") 2706 .each(function () { 2707 console.log("inside undefined"), $(this).removeAttr("disabled hidden"); 2708 }) 2709 : $("select." + e) 2710 .find("option") 2711 .each(function () { 2712 var e = $(this).data("belong"), 2713 t = $(this).val(); 2714 2715 i != e && t != '' ? ($(this).prop("disabled", !0), $(this).prop("hidden", !0)) : ($(this).prop("disabled", !1), $(this).prop("hidden", !1)); 2716 //i != e && -1 != t ? ($(this).prop("disabled", !0), $(this).prop("hidden", !0)) : ($(this).prop("disabled", !1), $(this).prop("hidden", !1)); 2717 }); 2718 $("select." + e).selectpicker('refresh'); 2719 } 2720 2721 $(".houzezSelectFilter").on("change", function () { 2722 var $this = $(this); 2723 houzezSelectFilter($this); 2724 }); 2725 2726 if( $('.houzez-search-form-js').length > 0 || $('#location').length > 0 ) { 2727 2728 var countryRef, stateRef, cityRef, areasRef; 2729 if( is_edit_property ) {
2730 countryRef = $('#country').data("country"); 2731 stateRef = $('#countyState').data("state"); 2732 cityRef = $('#city').data("city"); 2733 areasRef = $('#neighborhood').data("area"); 2734 } else { 2735 countryRef = houzez_vars.s_country; 2736 stateRef = houzez_vars.s_state; 2737 cityRef = houzez_vars.s_city; 2738 areasRef = houzez_vars.s_areas; 2739 } 2740 2741 if( ( $('.houzez-country-js').length > 0 || $('#country').length > 0 ) && countryRef != "" ) { 2742 var countryFilter = $('.houzezCountryFilter'); 2743 houzezSelectFilter(countryFilter, countryRef, 'houzezSecondList', 'yes'); 2744 2745 $( window ).load(function() { 2746 $('.houzezSecondList').val(stateRef); 2747 $("select.houzezSecondList").selectpicker('refresh'); 2748 }); 2749 } 2750 2751 if( ( $('.houzez-state-js').length > 0 || $('#countyState').length > 0 ) && stateRef != "" ) { 2752 var stateFilter = $('.houzezStateFilter'); 2753 houzezSelectFilter(stateFilter, stateRef, 'houzezThirdList', 'yes'); 2754 2755 $( window ).load(function() { 2756 $('.houzezThirdList').val(cityRef); 2757 $("select.houzezThirdList").selectpicker('refresh'); 2758 }); 2759 } 2760 2761 if( ( $('.houzez-city-js').length > 0 || $('#city').length > 0 ) && cityRef != "" ) { 2762 var cityFilter = $('.houzezCityFilter'); 2763 houzezSelectFilter(cityFilter, cityRef, 'houzezFourthList', 'yes'); 2764 2765 $( window ).load(function() { 2766 $('.houzezFourthList').val(areasRef); 2767 $("select.houzezFourthList").selectpicker('refresh'); 2768 }); 2769 } 2770 } 2771 2772 2773 2774 /*-----------------------------------------------------------------------------------*/ 2775 /* mortgage calculate by waqas 2776 /*-----------------------------------------------------------------------------------*/ 2777 if( $('#houzez_mortgage_calculate').length > 0 ) { 2778 $('#houzez_mortgage_calculate').click(function(e) { 2779 e.preventDefault(); 2780 2781 var monthly_payment = houzez_vars.monthly_payment; 2782 var weekly_payment = houzez_vars.weekly_payment; 2783 var bi_weekly_payment = houzez_vars.bi_weekly_payment; 2784 var currency_symb = houzez_vars.currency_symbol; 2785 2786 var totalPrice = 0; 2787 var down_payment = 0; 2788 var term_years = 0; 2789 var interest_rate = 0; 2790 var amount_financed = 0; 2791 var monthInterest = 0; 2792 var intVal = 0; 2793 var mortgage_pay = 0; 2794 var annualCost = 0; 2795 var payment_period; 2796 var mortgage_pay_text; 2797 2798 2799 var total_years = $('#mc_term_years').val(); 2800 payment_period = $('#mc_payment_period').val(); 2801 2802 totalPrice = $('#mc_total_amount').val().replace(/,/g, ''); 2803 down_payment = $('#mc_down_payment').val().replace(/,/g, ''); 2804 amount_financed = totalPrice - down_payment; 2805 term_years = parseInt ($('#mc_term_years').val(),10) * payment_period; 2806 interest_rate = parseFloat ($('#mc_interest_rate').val(),10); 2807 monthInterest = interest_rate / (payment_period * 100); 2808 intVal = Math.pow( 1 + monthInterest, -term_years ); 2809 mortgage_pay = amount_financed * (monthInterest / (1 - intVal)); 2810 annualCost = mortgage_pay * payment_period; 2811 2812 if( $('#mc_term_years').val() == '' || $('#mc_total_amount') == '' || $('#mc_down_payment') == '' || $('#mc_interest_rate') == '' ) { 2813 return; 2814 } 2815 2816 var total_mortgage_with_interest = mortgage_pay * total_years * payment_period; 2817 2818 var total_with_down_payment = total_mortgage_with_interest + parseInt(down_payment); 2819 2820 if( payment_period == '12' ) { 2821 mortgage_pay_text = monthly_payment; 2822 2823 } else if ( payment_period == '26' ) { 2824 mortgage_pay_text = bi_weekly_payment; 2825 2826 } else if ( payment_period == '52' ) { 2827 mortgage_pay_text = weekly_payment; 2828 2829 } 2830 2831 2832 if(currency_position == 'after') { 2833 $('#mortgage_mwbi').html("<strong>"+mortgage_pay_text+ "</strong>: <span>"+(Math.round(mortgage_pay * 100)) / 100 + currency_symb + "</span>"); 2834 $('#amount_financed').html(((Math.round(amount_financed * 100)) / 100)+currency_symb); 2835 $('#mortgage_pay').html(((Math.round(mortgage_pay * 100)) / 100)+currency_symb); 2836 $('#annual_cost').html(( (Math.round(annualCost * 100)) / 100)+currency_symb); 2837 $('#balance_payable_with_interest').html(( (Math.round(total_mortgage_with_interest * 100)) / 100)+currency_symb); 2838 $('#total_with_down_payment').html(( (Math.round(total_with_down_payment * 100)) / 100)+currency_symb); 2839 } else { 2840 $('#mortgage_mwbi').html("<strong>"+mortgage_pay_text+ "</strong>: <span>" +currency_symb+ (Math.round(mortgage_pay * 100)) / 100 + "</span>"); 2841 $('#amount_financed').html(currency_symb+(Math.round(amount_financed * 100)) / 100); 2842 $('#mortgage_pay').html(currency_symb+(Math.round(mortgage_pay * 100)) / 100); 2843 $('#annual_cost').html(currency_symb+(Math.round(annualCost * 100)) / 100); 2844 $('#balance_payable_with_interest').html(currency_symb+(Math.round(total_mortgage_with_interest * 100)) / 100); 2845 $('#total_with_down_payment').html(currency_symb+(Math.round(total_with_down_payment * 100)) / 100); 2846 } 2847 2848 $('#cal_years').html(total_years); 2849 $('.mortgage-details').show(); 2850 }); 2851 } 2852 2853 /* ------------------------------------------------------------------------ */ 2854 /* Beds and baths 2855 /* ------------------------------------------------------------------------ */ 2856 var beds_baths = function(btn_action, btn_count, btn_val) { 2857 $('.'+btn_action).on('click', function(e) { 2858 e.preventDefault(); 2859 var current_val = parseInt($('.'+btn_val).val()) || 0; 2860 2861 if(btn_action == 'btn_count_plus' || btn_action == 'btn_beds_plus') { 2862 current_val++; 2863 2864 } else { 2865 if(current_val == 0) 2866 return; 2867 current_val--; 2868 } 2869 2870 $('.'+btn_count).text(current_val); 2871 $('.'+btn_val).val(current_val); 2872 }); 2873 2874 } 2875 beds_baths('btn_count_plus', 'baths_count', 'bathrooms'); 2876 beds_baths('btn_count_minus', 'baths_count', 'bathrooms'); 2877 2878 beds_baths('btn_beds_plus', 'beds_count', 'bedrooms'); 2879 beds_baths('btn_beds_minus', 'beds_count', 'bedrooms'); 2880 2881 $('.btn-apply').on('click', function(e) { 2882 e.preventDefault(); 2883 $('.advanced-search-v3 .btn-group .dropdown-menu').removeClass('show'); 2884 }); 2885 2886 $('.clear-baths').on('click', function(e) { 2887 e.preventDefault(); 2888 $('.baths_count').text('0'); 2889 $('.bathrooms').val(''); 2890 }); 2891 2892 $('.clear-beds').on('click', function(e) { 2893 e.preventDefault(); 2894 $('.beds_count').text('0'); 2895 $('.bedrooms').val(''); 2896 }); 2897 2898 $('.clear-checkboxes').on('click', function(e) { 2899 e.preventDefault(); 2900 $(this).parents('.btn-group').find('input[type="checkbox"]').prop("checked", false).attr('checked', false); 2901 }); 2902 2903 /* ------------------------------------------------------------------------ */ 2904 /* PAYPAL & Stripe OPTIONS 2905 /* ------------------------------------------------------------------------ */ 2906 $('.method-select input').on('change',function () { 2907 if($(this).is(':checked')) {
2908 $('.recurring-payment-wrap').slideUp(); 2909 $(this).parents('.payment-method-block').next('.recurring-payment-wrap').slideDown(); 2910 }else{ 2911 $('.recurring-payment-wrap').slideUp(); 2912 } 2913 }); 2914 function paypal_option(ele){ 2915 if($(ele).attr('checked')) { 2916 $(ele).parents('.payment-method-block').next('.recurring-payment-wrap').slideDown(); 2917 }else{ 2918 $(ele).parents('.payment-method-block').next('.recurring-payment-wrap').slideUp(); 2919 } 2920 } 2921 2922 paypal_option('.paypal-method'); 2923 paypal_option('.stripe-method'); 2924 2925 $('button.stripe-button-el span').prepend('<i class="fa fa-credit-card"></i>'); 2926 $('#stripe_package_recurring').click(function () { 2927 if( $(this).attr('checked') ) { 2928 $('.houzez_payment_form').append('<input type="hidden" name="houzez_stripe_recurring" id="houzez_stripe_recurring" value="1">'); 2929 }else{ 2930 $('#houzez_stripe_recurring').remove(); 2931 } 2932 }); 2933 2934 /* ------------------------------------------------------------------------ */ 2935 /* Change listing fee for featured 2936 /* ------------------------------------------------------------------------ */ 2937 $('.prop_featured').on('change', function() { 2938 2939 var currency_symbol = houzez_vars.currency_symbol; 2940 var currency_position = houzez_vars.currency_position; 2941 var total_price, total_price_with_currency, price_regular_with_currency; 2942 var price_regular = parseFloat( $('#submission_price').text() ); 2943 var price_featured = parseFloat( $('#submission_featured_price').text() ); 2944 2945 total_price = price_regular+price_featured; 2946 2947 if ( currency_position === 'after'){ 2948 price_regular_with_currency = price_regular +''+currency_symbol; 2949 total_price_with_currency = total_price +''+currency_symbol; 2950 }else{ 2951 price_regular_with_currency = currency_symbol +''+price_regular; 2952 total_price_with_currency = currency_symbol+''+total_price; 2953 } 2954 2955 if( $(this).is(':checked') ) { 2956 $('#submission_total_price').text(total_price_with_currency); 2957 $('#featured_pay').val(1); 2958 $('input[name="pay_ammout"]').val(total_price * 100); 2959 $('#houzez_listing_price').val(total_price); 2960 } else { 2961 $('#submission_total_price').text(price_regular_with_currency); 2962 $('#featured_pay').val(0); 2963 $('input[name="pay_ammout"]').val(price_regular * 100); 2964 $('#houzez_listing_price').val(price_regular); 2965 } 2966 return false; 2967 }); 2968 2969 /* ------------------------------------------------------------------------ */ 2970 /* Paypal single listing payment 2971 /* ------------------------------------------------------------------------ */ 2972 $('#houzez_complete_order').on('click', function(e) { 2973 e.preventDefault(); 2974 var hform, relist_mode, payment_gateway, houzez_listing_price, property_id, is_prop_featured, is_prop_upgrade; 2975 2976 payment_gateway = $("input[name='houzez_payment_type']:checked").val(); 2977 is_prop_featured = $("input[name='featured_pay']").val(); 2978 is_prop_upgrade = $("input[name='is_upgrade']").val(); 2979 relist_mode = $("input[name='relist_mode']").val(); 2980 2981 property_id = $('#houzez_property_id').val(); 2982 houzez_listing_price = $('#houzez_listing_price').val(); 2983 2984 if( payment_gateway == 'paypal' ) { 2985 fave_processing_modal( paypal_connecting ); 2986 paypal_per_listing_payment( property_id, is_prop_featured, is_prop_upgrade, relist_mode); 2987 2988 } else if ( payment_gateway == 'stripe' ) { 2989 2990 fave_processing_modal( processing_text ); 2991 stripe_per_listing_payment( property_id, is_prop_featured, is_prop_upgrade, relist_mode); 2992 2993 } else if ( payment_gateway == 'direct_pay' ) { 2994 fave_processing_modal( processing_text ); 2995 bank_transfer_per_listing(property_id, houzez_listing_price); 2996 } 2997 return; 2998 2999 }); 3000 3001 /* ------------------------------------------------------------------------ */ 3002 /* Paypal payment for per listing 3003 /* ------------------------------------------------------------------------ */ 3004 var paypal_per_listing_payment = function( property_id, is_prop_featured, is_prop_upgrade, relist_mode ) { 3005 3006 $.ajax({ 3007 type: 'post', 3008 url: ajaxurl, 3009 data: { 3010 'action': 'houzez_property_paypal_payment', 3011 'prop_id': property_id, 3012 'is_prop_featured': is_prop_featured, 3013 'is_prop_upgrade': is_prop_upgrade, 3014 'relist_mode': relist_mode, 3015 }, 3016 success: function( response ) { 3017 window.location.href = response; 3018 }, 3019 error: function(xhr, status, error) { 3020 var err = eval("(" + xhr.responseText + ")"); 3021 console.log(err.Message); 3022 } 3023 }); 3024 } 3025 3026 /* ------------------------------------------------------------------------ */ 3027 /* Stripe payment for per listing 3028 /* ------------------------------------------------------------------------ */ 3029 var stripe_per_listing_payment = function( property_id, is_prop_featured, is_prop_upgrade, relist_mode ) { 3030 3031 $.ajax({ 3032 type: 'post', 3033 url: ajaxurl, 3034 dataType: 'JSON', 3035 data: { 3036 'action': 'houzez_property_stripe_payment', 3037 'prop_id': property_id, 3038 'is_prop_featured': is_prop_featured, 3039 'is_prop_upgrade': is_prop_upgrade, 3040 'relist_mode': relist_mode, 3041 }, 3042 success: function( response ) { 3043 if( response.status ) { 3044 window.location.href = response.paymeny_link; 3045 } else { 3046 alert(response.message); 3047 } 3048 }, 3049 error: function(xhr, status, error) { 3050 var err = eval("(" + xhr.responseText + ")"); 3051 console.log(err.Message); 3052 } 3053 }); 3054 } 3055 3056 /* ------------------------------------------------------------------------ */ 3057 /* Wire Transfer per listing payment 3058 /* ------------------------------------------------------------------------ */ 3059 var bank_transfer_per_listing = function( prop_id, listing_price ) { 3060 var is_featured = $('input[name="featured_pay"]').val(); 3061 var is_upgrade = $('input[name="is_upgrade"]').val(); 3062 3063 jQuery.ajax({ 3064 type: 'POST', 3065 url: ajaxurl, 3066 data: { 3067 'action' : 'houzez_direct_pay_per_listing', 3068 'prop_id' : prop_id, 3069 'is_featured' : is_featured, 3070 'is_upgrade' : is_upgrade 3071 }, 3072 success: function (data) { 3073 window.location.href = data; 3074 }, 3075 error: function (errorThrown) {} 3076 }); 3077 3078 } 3079 3080 /* ------------------------------------------------------------------------ */ 3081 /* Select Membership payment 3082 /* ------------------------------------------------------------------------ */ 3083 var houzez_stripe_package_payment = function( houzez_package_id, is_stripe_recurring ) { 3084 3085 $.ajax({ 3086 type: 'POST', 3087 url: ajaxurl, 3088 dataType: 'JSON', 3089 data: { 3090 'action' : 'houzez_stripe_package_payment', 3091 'package_id' : houzez_package_id, 3092 'is_stripe_recurring' : is_stripe_recurring 3093 }, 3094 success: function (response) { 3095 if( response.status ) { 3096 window.location.href = response.paymeny_link; 3097 } else { 3098 alert(response.message); 3099 } 3100 }, 3101 error: function(xhr, status, error) { 3102 var err = eval("(" + xhr.responseText + ")"); 3103 console.log(err.Message); 3104 } 3105 }); 3106 } 3107 3108 var houzez_paypal_package_payment = function( houzez_package_price, houzez_package_name, houzez_package_id ) { 3109 3110 $.ajax({ 3111 type: 'POST', 3112 url: ajaxurl, 3113 data: { 3114 'action' : 'houzez_paypal_package_payment', 3115 'houzez_package_price' : houzez_package_price, 3116 'houzez_package_name' : houzez_package_name, 3117 'houzez_package_id' : houzez_package_id 3118 }, 3119 success: function (data) { 3120 window.location.href = data; 3121 }, 3122 error: function(xhr, status, error) { 3123 var err = eval("(" + xhr.responseText + ")"); 3124 console.log(err.Message); 3125 } 3126 }); 3127 } 3128 3129 var houzez_recuring_paypal_package_payment = function( houzez_package_price, houzez_package_name, houzez_package_id ) { 3130 3131 jQuery.ajax({ 3132 type: 'POST', 3133 url: ajaxurl, 3134 data: { 3135 'action' : 'houzez_recuring_paypal_package_payment', 3136 'houzez_package_name' : houzez_package_name, 3137 'houzez_package_id' : houzez_package_id, 3138 'houzez_package_price' : houzez_package_price 3139 }, 3140 success: function (data) { //alert(data); return false;
3141 window.location.href = data; 3142 }, 3143 error: function(xhr, status, error) { 3144 var err = eval("(" + xhr.responseText + ")"); 3145 console.log(err.Message); 3146 } 3147 }); 3148 } 3149 3150 var direct_bank_transfer_package = function( houzez_package_id, houzez_package_price, houzez_package_name ) { 3151 3152 jQuery.ajax({ 3153 type: 'POST', 3154 url: ajaxurl, 3155 data: { 3156 'action' : 'houzez_direct_pay_package', 3157 'selected_package' : houzez_package_id, 3158 }, 3159 success: function (data) { 3160 window.location.href = data; 3161 3162 }, 3163 error: function (errorThrown) {} 3164 }); 3165 } 3166 3167 var houzez_free_membership_package = function ( houzez_package_id ) { 3168 jQuery.ajax({ 3169 type: 'POST', 3170 url: ajaxurl, 3171 data: { 3172 'action' : 'houzez_free_membership_package', 3173 'selected_package' : houzez_package_id, 3174 }, 3175 success: function (data) { 3176 window.location.href = data; 3177 3178 }, 3179 error: function (errorThrown) {} 3180 }); 3181 } 3182 3183 var houzez_membership_data = function(currnt) { 3184 var payment_gateway = $("input[name='houzez_payment_type']:checked").val(); 3185 var houzez_package_price = $("input[name='houzez_package_price']").val(); 3186 var houzez_package_id = $("input[name='houzez_package_id']").val(); 3187 var houzez_package_name = $("#houzez_package_name").text(); 3188 3189 if( payment_gateway == 'paypal' ) { 3190 fave_processing_modal( paypal_connecting ); 3191 if ($('#paypal_package_recurring').is(':checked')) { 3192 houzez_recuring_paypal_package_payment( houzez_package_price, houzez_package_name, houzez_package_id ); 3193 } else { 3194 houzez_paypal_package_payment( houzez_package_price, houzez_package_name, houzez_package_id ); 3195 } 3196 3197 } else if ( payment_gateway == 'stripe' ) { 3198 fave_processing_modal( processing_text ); 3199 var is_stripe_recurring = $('#houzez_stripe_recurring').is(':checked'); 3200 houzez_stripe_package_payment( houzez_package_id, is_stripe_recurring ); 3201 3202 } else if ( payment_gateway == 'direct_pay' ) { 3203 fave_processing_modal( processing_text ); 3204 direct_bank_transfer_package( houzez_package_id, houzez_package_price, houzez_package_name ); 3205 3206 } else { 3207 fave_processing_modal( processing_text ); 3208 houzez_free_membership_package( houzez_package_id ); 3209 } 3210 3211 return false; 3212 } 3213 3214 var houzez_register_user_with_membership = function ( currnt ) { 3215 3216 var $form = currnt.parents('form'); 3217 var $messages = $('#packmem-msgs'); 3218 3219 $.ajax({ 3220 type: 'post', 3221 url: ajaxurl, 3222 dataType: 'json', 3223 data: $form.serialize(), 3224 beforeSend: function( ) { 3225 currnt.find('.houzez-loader-js').addClass('loader-show'); 3226 }, 3227 complete: function(){ 3228 currnt.find('.houzez-loader-js').removeClass('loader-show'); 3229 }, 3230 success: function( response ) { 3231 if( response.success ) { 3232 houzez_membership_data(currnt); 3233 } else { 3234 $('html, body').animate({ 3235 scrollTop: $(".frontend-submission-page").offset().top 3236 }, 'slow'); 3237 $messages.empty().append('<div class="alert alert-danger alert-dismissible fade show" role="alert">'+response.msg+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>'); 3238 } 3239 }, 3240 error: function(xhr, status, error) { 3241 var err = eval("(" + xhr.responseText + ")"); 3242 console.log(err.Message); 3243 } 3244 }); 3245 } 3246 3247 $('#houzez_complete_membership').on('click', function(e) { 3248 e.preventDefault(); 3249 var currnt = $(this); 3250 if( parseInt( userID, 10 ) === 0 || userID == undefined) { 3251 houzez_register_user_with_membership( currnt ); 3252 return; 3253 } 3254 houzez_membership_data(currnt); 3255 } ); 3256 3257 3258 /*-------------------------------------------------------------------------- 3259 * Area Switcher 3260 * -------------------------------------------------------------------------*/ 3261 var areaSwitcherList = $('#area-switcher-list-js'); 3262 if( areaSwitcherList.length > 0 ) { 3263 3264 $('#area-switcher-list-js > li').on('click', function(e) { 3265 //e.stopPropagation(); 3266 3267 var selectedAreaCode = $(this).data( 'area-code' ); 3268 if ( selectedAreaCode ) { 3269 3270 $('#houzez-switch-to-area').val( selectedAreaCode ); 3271 var houzez_switch_to_area = $('#houzez-switch-to-area').val(); 3272 fave_processing_modal(processing_text); 3273 3274 $.ajax({ 3275 url: ajaxurl, 3276 dataType: 'JSON', 3277 method: 'POST', 3278 data: { 3279 'action' : 'houzez_switch_area', 3280 'switch_to_area' : houzez_switch_to_area, 3281 }, 3282 success: function (res) { 3283 if( res.success ) { 3284 window.location.reload( true ); 3285 } else { 3286 console.log( res ); 3287 } 3288 }, 3289 error: function (xhr, status, error) { 3290 var err = eval("(" + xhr.responseText + ")"); 3291 console.log(err.Message); 3292 } 3293 }); 3294 3295 } 3296 3297 }); 3298 } 3299 3300 /*-------------------------------------------------------------------------- 3301 * Currency Switcher 3302 * -------------------------------------------------------------------------*/ 3303 var currencySwitcherList = $('#hz-currency-switcher-list'); 3304 if( currencySwitcherList.length > 0 ) { 3305 3306 $('#hz-currency-switcher-list > li').on('click', function(e) { 3307 3308 var selectedCurrencyCode = $(this).data( 'currency-code' ); 3309 3310 if ( selectedCurrencyCode ) { 3311 3312 $('#houzez-switch-to-currency').val( selectedCurrencyCode ); 3313 var houzez_switch_to_currency = $('#houzez-switch-to-currency').val(); 3314 fave_processing_modal(processing_text); 3315 3316 $.ajax({ 3317 url: ajaxurl, 3318 dataType: 'JSON', 3319 method: 'POST', 3320 data: { 3321 'action' : 'houzez_currency_converter', 3322 'currency_converter' : selectedCurrencyCode 3323 }, 3324 success: function (res) { 3325 if( res.success ) { 3326 window.location.reload( true ); 3327 } else { 3328 console.log( res ); 3329 } 3330 }, 3331 error: function (xhr, status, error) { 3332 var err = eval("(" + xhr.responseText + ")"); 3333 console.log(err.Message); 3334 } 3335 }); 3336 3337 } 3338 3339 }); 3340 } 3341 3342 /* ------------------------------------------------------------------------ */ 3343 /* tooltip 3344 /* ------------------------------------------------------------------------ */ 3345 $('[data-toggle="tooltip"]').tooltip() 3346 3347 /* ------------------------------------------------------------------------ */ 3348 /* prevent advanced search dropdowns from closing on clicks 3349 /* ------------------------------------------------------------------------ */ 3350 $('.advanced-search-dropdown').on('click', function (e) { 3351 e.stopPropagation(); 3352 }); 3353 3354 /* ------------------------------------------------------------------------ */ 3355 /* agent phone number 3356 /* ------------------------------------------------------------------------ */ 3357 $('.agent-show-onClick').on('click', function (e) { 3358 $(this).toggleClass('agent-phone-hidden'); 3359 }); 3360 3361 /* ------------------------------------------------------------------------ */ 3362 /* drop down menus 3363 /* ------------------------------------------------------------------------ */ 3364 $('.dropdown-menu span.dropdown-toggle').on('click', function(e) { 3365 if (!$(this).next().hasClass('show')) { 3366 $(this).parents('.dropdown-menu').first().find('.show').removeClass('show'); 3367 } 3368 var $subMenu = $(this).next('.dropdown-menu'); 3369 $subMenu.toggleClass('show'); 3370 3371 3372 $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) { 3373 $('.dropdown-submenu .show').removeClass('show'); 3374 }); 3375 3376 3377 return false;
3378 }); 3379 3380 /* ------------------------------------------------------------------------ */ 3381 /* avoid zoom when double click on mobile devices 3382 /* ------------------------------------------------------------------------ */ 3383 $.fn.nodoubletapzoom = function () { 3384 $(this).bind('touchstart', function preventZoom(e) { 3385 var t2 = e.timeStamp, 3386 t1 = $(this).data('lastTouch') || t2, 3387 dt = t2 - t1, 3388 fingers = e.originalEvent.touches.length; 3389 $(this).data('lastTouch', t2); 3390 if (!dt || dt > 500 || fingers > 1) return; 3391 3392 e.preventDefault(); 3393 $(this).trigger('click').trigger('click'); 3394 }); 3395 }; 3396 3397 3398 /* ------------------------------------------------------------------------ */ 3399 /* mobile menu 3400 /* ------------------------------------------------------------------------ */ 3401 // disable touch 3402 if($('.nav-mobile-js').length > 0 ) { 3403 3404 var smm_transform = 256; 3405 if ( houzez_rtl ) { 3406 smm_transform = -256; 3407 } 3408 var slideout_left = new Slideout({ 3409 'panel': document.getElementById('main-wrap'), 3410 'menu': document.getElementById('nav-mobile'), 3411 'padding': smm_transform, 3412 'tolerance': 70, 3413 'side': 'left', 3414 'easing': 'cubic-bezier(.32,2,.55,.27)' 3415 }); 3416 slideout_left.disableTouch(); 3417 } 3418 3419 if($('.main-wrap-js').length > 0 ) { 3420 var smd_transform = 256; 3421 if ( houzez_rtl ) { 3422 smd_transform = -256; 3423 } 3424 var slideout_right = new Slideout({ 3425 'panel': document.getElementById('main-wrap'), 3426 'menu': document.getElementById('navi-user'), 3427 'padding': smd_transform, 3428 'tolerance': 70, 3429 'side': 'right', 3430 'easing': 'cubic-bezier(.32,2,.55,.27)' 3431 }); 3432 slideout_right.disableTouch(); 3433 } 3434 3435 // Toggle button 3436 $('.toggle-button-left, #nav-mobile .nav-link:not(.dropdown-toggle)').on('click', function () {
3437 slideout_left.toggle(); 3438 $('.slideout-menu-left').toggleClass('open'); 3439 }); 3440 $('.toggle-button-right').on('click', function () { 3441 slideout_right.toggle(); 3442 $('.slideout-menu-right').toggleClass('open'); 3443 }); 3444 3445 3446 /* ---------------------------------------------------- */ 3447 /* Close Menu when click outside 3448 /* ---------------------------------------------------- */ 3449 $(document).on('mouseup', function (e) { 3450 var mobileNavcontainer = $(".nav-mobile"); 3451 var toggleBtnCloseW = $(".toggle-button-left"); 3452 var mobileMenuDiv = $('#nav-mobile'); 3453 3454 3455 var toggleBtnCloseL = $(".toggle-button-right"); 3456 var mobileMenuDivL = $('#navi-user'); 3457 3458 if (!mobileNavcontainer.is(e.target) && mobileNavcontainer.has(e.target).length === 0 && mobileMenuDiv.hasClass('open') && !toggleBtnCloseW.is(e.target) && toggleBtnCloseW.has(e.target).length === 0 ) { 3459 slideout_left.toggle(); 3460 $('.slideout-menu-left').toggleClass('open'); 3461 } 3462 3463 if (!mobileNavcontainer.is(e.target) && mobileNavcontainer.has(e.target).length === 0 && mobileMenuDivL.hasClass('open') && !toggleBtnCloseL.is(e.target) && toggleBtnCloseL.has(e.target).length === 0 ) { 3464 slideout_right.toggle(); 3465 $('.slideout-menu-right').toggleClass('open'); 3466 } 3467 }); 3468 3469 /* ------------------------------------------------------------------------ */ 3470 /* search distance slider 3471 /* ------------------------------------------------------------------------ */ 3472 $(function () { 3473 if($('.distance-range').length > 0) { 3474 $(".distance-range").slider(); 3475 } 3476 }); 3477 /* ------------------------------------------------------------------------ */ 3478 /* parallax 3479 /* ------------------------------------------------------------------------ */ 3480 var header_parallax = $('.parallax'); 3481 if( header_parallax.length > 0 ) { 3482 header_parallax.parallaxBackground({ 3483 parallaxBgPosition: "center center", 3484 parallaxBgRepeat: "no-repeat", 3485 parallaxBgSize: "cover", 3486 parallaxSpeed: "0.25", 3487 }); 3488 } 3489 3490 /* ------------------------------------------------------------------------ */ 3491 /* mobile search form overlay 3492 /* ------------------------------------------------------------------------ */ 3493 $(document).ready(function () { 3494 $(".mobile-search-nav").click(function () { 3495 $("#overlay-search-advanced-module").toggleClass("open"); 3496 }); 3497 }); 3498 $(document).ready(function () { 3499 $(".overlay-search-module-close, .overly_is_halfmap .half-map-search-js-btn").click(function () { 3500 $("#overlay-search-advanced-module").toggleClass("open"); 3501 }); 3502 }); 3503 3504 /* ------------------------------------------------------------------------ */ 3505 /* half map elements size 3506 /* ------------------------------------------------------------------------ */ 3507 function setSectionHeight() { 3508 var window_height = $(window).innerHeight(); 3509 var sections_height = window_height - header_area_height; 3510 sections_height = sections_height - advanced_search_nav_height; 3511 sections_height = sections_height - elementor_location_header_height; 3512 3513 if ($(window).width() >= 767) { 3514 $('.half-map-left-wrap, .half-map-right-wrap').css('height', sections_height); 3515 } else { 3516 $('.map-on-right .half-map-right-wrap').css('height', sections_height); 3517 $('.map-on-right .half-map-left-wrap').css('height', '100vh'); 3518 $('.map-on-left .half-map-right-wrap').css('height', sections_height); 3519 $('.map-on-left .half-map-left-wrap').css('height', '100vh'); 3520 } 3521 } 3522 setSectionHeight(); 3523 $win.on('resize', function () { 3524 setSectionHeight(); 3525 }); 3526 3527 /* ------------------------------------------------------------------------ */ 3528 /* listing switch view 3529 /* ------------------------------------------------------------------------ */ 3530 $('.switch-btn').on("click", function () { 3531 $('.switch-btn').removeClass('active'); 3532 $(this).addClass('active'); 3533 if ($(this).hasClass('btn-list')) { 3534 $('.listing-view').removeClass('grid-view').addClass('list-view'); 3535 } else if ($(this).hasClass('btn-grid')) { 3536 $('.listing-view').removeClass('list-view').addClass('grid-view'); 3537 } 3538 3539 }); 3540 /* ------------------------------------------------------------------------ */ 3541 /* compare properties 3542 /* ------------------------------------------------------------------------ */ 3543 $(document).ready(function () { 3544 $('.show-compare-panel').click(function () { 3545 $(this).toggleClass('active'); 3546 $('.compare-property-active').addClass('compare-property-active-push-toleft'); 3547 $('#compare-property-panel').addClass('compare-property-panel-open'); 3548 //disableOther( 'show-compare-panel' ); 3549 }); 3550 $('.close-compare-panel').click(function () { 3551 $(this).toggleClass('active'); 3552 $('.compare-property-active').removeClass('compare-property-active-push-toleft'); 3553 $('#compare-property-panel').removeClass('compare-property-panel-open'); 3554 //disableOther( 'show-compare-panel' ); 3555 }); 3556 }); 3557 /* ------------------------------------------------------------------------ */ 3558 /* property slider 3559 /* ------------------------------------------------------------------------ */ 3560 var property_banner_slider = $('.property-slider'); 3561 if( property_banner_slider.length > 0 ) { 3562 3563 var autoplay = property_banner_slider.data('autoplay'); 3564 var slider_loop = property_banner_slider.data('loop'); 3565 var slider_speed = property_banner_slider.data('speed'); 3566 3567 var s_loop = false;
3568 if(slider_loop == 1) { 3569 s_loop = true; 3570 } 3571 3572 property_banner_slider.slick({ 3573 rtl: houzez_rtl, 3574 autoplay: autoplay, 3575 autoplaySpeed: slider_speed, 3576 lazyLoad: 'ondemand', 3577 infinite: s_loop, 3578 speed: 300, 3579 slidesToShow: 1, 3580 arrows: true, 3581 adaptiveHeight: true 3582 }); 3583 } 3584 3585 var property_detail_gallery = $('#property-gallery-js'); 3586 if( property_detail_gallery.length > 0 ) { 3587 property_detail_gallery.lightSlider({ 3588 rtl: houzez_rtl, 3589 gallery:true, 3590 item:1, 3591 thumbItem:8, 3592 slideMargin: 0, 3593 speed:500, 3594 adaptiveHeight: true, 3595 auto:false, 3596 loop:false, 3597 prevHtml: '<button type="button" class="slick-prev slick-arrow"></button>', 3598 nextHtml: '<button type="button" class="slick-next slick-arrow"></button>', 3599 onSliderLoad: function() { 3600 property_detail_gallery.removeClass('cS-hidden'); 3601 } 3602 }); 3603 } 3604 3605 3606 var lightbox_slider_js = $('#lightbox-slider-js'); 3607 if( lightbox_slider_js.length > 0 ) { 3608 3609 lightbox_slider_js.slick({ 3610 rtl: houzez_rtl, 3611 lazyLoad: 'ondemand', 3612 infinite: true, 3613 speed: 300, 3614 slidesToShow: 1, 3615 arrows: true, 3616 adaptiveHeight: true, 3617 }); 3618 3619 $('.houzez-trigger-popup-slider-js').on('click', function (e) { 3620 e.preventDefault(); 3621 3622 var slider_num = parseInt( $(this).data('slider-no') ); 3623 setTimeout(function(){ 3624 lightbox_slider_js.slick('slickGoTo', slider_num - 1); 3625 }, 200); 3626 }); 3627 3628 } 3629 3630 3631 var listing_slider_variable_width = $('.listing-slider-variable-width'); 3632 if( listing_slider_variable_width.length > 0 ) { 3633 listing_slider_variable_width.slick({ 3634 rtl: houzez_rtl, 3635 lazyLoad: 'ondemand', 3636 infinite: true, 3637 speed: 300, 3638 slidesToShow: 1, 3639 centerMode: true, 3640 variableWidth: true, 3641 arrows: true, 3642 adaptiveHeight: true 3643 }); 3644 3645 $('.property-detail-v5 #pills-gallery-tab').on('click', function() { 3646 if (!listing_slider_variable_width.hasClass('hz-slick-refreshed')) { 3647 setTimeout(function() { 3648 listing_slider_variable_width.slick('setPosition'); 3649 listing_slider_variable_width.slick('refresh'); 3650 listing_slider_variable_width.addClass('hz-slick-refreshed'); 3651 }, 0); 3652 } 3653 }); 3654 } 3655 3656 3657 /* ------------------------------------------------------------------------ */ 3658 /* testimonial slider 3659 /* ------------------------------------------------------------------------ */ 3660 var testimonials_slider_v1 = $('.testimonials-slider-wrap-v1'); 3661 if( testimonials_slider_v1.length > 0 ) { 3662 3663 testimonials_slider_v1.slick({ 3664 rtl: houzez_rtl, 3665 lazyLoad: 'ondemand', 3666 infinite: true, 3667 autoplay: true, 3668 speed: 300, 3669 slidesToShow: 1, 3670 arrows: true, 3671 adaptiveHeight: true, 3672 dots: true, 3673 appendArrows: '.testimonials-module-slider-v1', 3674 prevArrow: '<button type="button" class="slick-prev btn-primary-outlined">'+prev_text+'</button>', 3675 nextArrow: '<button type="button" class="slick-next btn-primary-outlined">'+next_text+'</button>', 3676 }); 3677 } 3678 3679 var testimonials_slider_v2 = $('.testimonials-slider-wrap-v2'); 3680 if( testimonials_slider_v2.length > 0 ) { 3681 testimonials_slider_v2.slick({ 3682 rtl: houzez_rtl, 3683 lazyLoad: 'ondemand', 3684 infinite: true, 3685 autoplay: true, 3686 speed: 300, 3687 slidesToShow: 3, 3688 arrows: true, 3689 adaptiveHeight: true, 3690 dots: true, 3691 appendArrows: '.testimonials-module-slider-v2', 3692 prevArrow: '<button type="button" class="slick-prev btn-primary-outlined">'+prev_text+'</button>', 3693 nextArrow: '<button type="button" class="slick-next btn-primary-outlined">'+next_text+'</button>', 3694 responsive: [{ 3695 breakpoint: 992, 3696 settings: { 3697 slidesToShow: 2, 3698 slidesToScroll: 2 3699 } 3700 }, 3701 { 3702 breakpoint: 769, 3703 settings: { 3704 slidesToShow: 1, 3705 slidesToScroll: 1 3706 } 3707 } 3708 ] 3709 }); 3710 } 3711 3712 /* ------------------------------------------------------------------------ */ 3713 /* partners slider 3714 /* ------------------------------------------------------------------------ */ 3715 var partners_carousel = $('.partners-slider-wrap'); 3716 if( partners_carousel.length > 0 ) { 3717 partners_carousel.slick({ 3718 rtl: houzez_rtl, 3719 lazyLoad: 'ondemand', 3720 infinite: true, 3721 speed: 300, 3722 slidesToShow: 4, 3723 arrows: true, 3724 adaptiveHeight: true, 3725 dots: true, 3726 appendArrows: '.partners-module-slider', 3727 prevArrow: $('.partner-prev-js'), 3728 nextArrow: $('.partner-next-js'), 3729 responsive: [{ 3730 breakpoint: 992, 3731 settings: { 3732 slidesToShow: 2, 3733 slidesToScroll: 2 3734 } 3735 }, 3736 { 3737 breakpoint: 769, 3738 settings: { 3739 slidesToShow: 1, 3740 slidesToScroll: 1 3741 } 3742 } 3743 ] 3744 }); 3745 } 3746 3747 /* ------------------------------------------------------------------------ */ 3748 /* Schedule your dates 3749 /* ------------------------------------------------------------------------ */ 3750 var schedule_tour_day = $('.property-schedule-tour-day-form-slide-v2'); 3751 if( schedule_tour_day.length > 0 ) { 3752 schedule_tour_day.slick({ 3753 rtl: houzez_rtl, 3754 lazyLoad: 'ondemand', 3755 infinite: false, 3756 speed: 300, 3757 slidesToShow: 3, 3758 slidesToScroll: 3, 3759 arrows: true, 3760 adaptiveHeight: false, 3761 dots: false, 3762 prevArrow: $('.tour-day-form-slide-arrow.sche-tabs-prev-js'), 3763 nextArrow: $('.tour-day-form-slide-arrow.sche-tabs-next-js'), 3764 responsive: [{ 3765 breakpoint: 992, 3766 settings: { 3767 slidesToShow: 3, 3768 slidesToScroll: 3 3769 } 3770 }, 3771 { 3772 breakpoint: 769, 3773 settings: { 3774 slidesToShow: 3, 3775 slidesToScroll: 3 3776 } 3777 } 3778 ] 3779 }); 3780 } 3781 3782 var schedule_tour_day2 = $('.property-schedule-tour-day-form-slide-v2-bottom'); 3783 if( schedule_tour_day2.length > 0 ) { 3784 schedule_tour_day2.slick({ 3785 rtl: houzez_rtl, 3786 lazyLoad: 'ondemand', 3787 infinite: false, 3788 speed: 300, 3789 slidesToShow: 4, 3790 slidesToScroll: 4, 3791 arrows: true, 3792 adaptiveHeight: false, 3793 dots: false, 3794 prevArrow: $('.tour-day-form-slide-arrow.sche-prev-js'), 3795 nextArrow: $('.tour-day-form-slide-arrow.sche-next-js'), 3796 responsive: [{ 3797 breakpoint: 992, 3798 settings: { 3799 slidesToShow: 4, 3800 slidesToScroll: 4 3801 } 3802 }, 3803 { 3804 breakpoint: 769, 3805 settings: { 3806 slidesToShow: 3, 3807 slidesToScroll: 3 3808 } 3809 } 3810 ] 3811 }); 3812 } 3813 3814 3815 /* ------------------------------------------------------------------------ */ 3816 /* featured property widget 3817 /* ------------------------------------------------------------------------ */ 3818 var widget_featured_carousel = $('.widget-featured-property-slider'); 3819 if( widget_featured_carousel.length > 0 ) { 3820 widget_featured_carousel.slick({ 3821 rtl: houzez_rtl, 3822 speed: 300, 3823 slidesToShow: 1, 3824 arrows: true, 3825 adaptiveHeight: true, 3826 dots: true, 3827 responsive: [{ 3828 breakpoint: 992, 3829 settings: { 3830 slidesToShow: 1, 3831 slidesToScroll: 1 3832 } 3833 }, 3834 { 3835 breakpoint: 769, 3836 settings: { 3837 slidesToShow: 1, 3838 slidesToScroll: 1 3839 } 3840 } 3841 ] 3842 }); 3843 } 3844 3845 3846 /* ------------------------------------------------------------------------ */ 3847 /* half maps listing layout 3848 /* ------------------------------------------------------------------------ */ 3849 // function homy_half_map_switch_listing_layout() { 3850 // if ($(window).width() < 1200) { 3851 // $('.half-map-wrap .listing-view').removeClass('list-view').addClass('grid-view'); 3852 // } else if ($(window).width() > 1200) { 3853 // $('.half-map-wrap .listing-view').removeClass('grid-view').addClass('list-view'); 3854 // } 3855 // } 3856 // if(houzez_vars.halfmap_layout == 'list-view') { 3857 // homy_half_map_switch_listing_layout(); 3858 // $win.on('resize', function () { 3859 // homy_half_map_switch_listing_layout(); 3860 // }); 3861 // $win.bind('load', function () { 3862 // homy_half_map_switch_listing_layout(); 3863 // }); 3864 // } 3865 3866 /* ------------------------------------------------------------------------ */ 3867 /* property lightbox 3868 /* ------------------------------------------------------------------------ */ 3869 $(document).ready(function () { 3870 $('.btn-expand').click(function () { 3871 $('.lightbox-gallery-wrap').toggleClass("lightbox-gallery-full-wrap"); 3872 $('#lightbox-slider-js').slick('refresh'); 3873 }); 3874 $('.btn-email').click(function () { 3875 $('.lightbox-form-wrap').toggleClass("lightbox-form-wrap-show"); 3876 }); 3877 }); 3878 3879 /* ------------------------------------------------------------------------ */ 3880 /* property navigation 3881 /* ------------------------------------------------------------------------ */ 3882 var houzez_listing_nav = $('.property-navigation-wrap'); 3883 3884 if( houzez_listing_nav.length > 0 ) { 3885 $(document).scroll(function() { 3886 var y = $(this).scrollTop(); 3887 3888 houzez_listing_nav.css('top', houzezStickyTop); 3889 if (y > 300) { 3890 houzez_listing_nav.fadeIn(250); 3891 } else { 3892 houzez_listing_nav.fadeOut(0); 3893 } 3894 }); 3895 3896 $(".property-navigation-item a.target").click(function (event) { 3897 event.preventDefault(); 3898 $("html, body").animate({ 3899 scrollTop: $($(this).attr("href")).offset().top - 84 3900 }, 500); 3901 }); 3902 3903 $(window).on('scroll', function () { 3904 $('.property-section-wrap').each(function () { 3905 if ($(window).scrollTop() >= $(this).offset().top - 86) { 3906 var id = $(this).attr('id'); 3907 $('.target').removeClass('active'); 3908 $('.target[href="#' + id + '"]').addClass('active'); 3909 } else if ($(window).scrollTop() <= 0) { 3910 $('.target').removeClass('active'); 3911 } 3912 }); 3913 }); 3914 } 3915 3916 /* ------------------------------------------------------------------------ */ 3917 /* availability calendar cells height 3918 /* ------------------------------------------------------------------------ */ 3919 function setCalendarCellHeight() { 3920 var calendarCellWidth = $('.block-availability-calendars .search-calendar li').innerWidth(); 3921 $('.block-availability-calendars .search-calendar li').css('height', calendarCellWidth); 3922 $('.block-availability-calendars .search-calendar li').css('line-height', calendarCellWidth + 'px'); 3923 } 3924 setCalendarCellHeight(); 3925 $win.on('resize', function () { 3926 setCalendarCellHeight(); 3927 }); 3928 3929 /* ------------------------------------------------------------------------ */ 3930 /* login and register links 3931 /* ------------------------------------------------------------------------ */ 3932 $('.login-link a').on('click', function () { 3933 $('.modal-toggle-1').addClass("active"); 3934 $('.modal-toggle-2').removeClass("active"); 3935 $('.register-form-tab').removeClass("active").removeClass("show"); 3936 $('.login-form-tab').addClass("active").addClass("show"); 3937 }); 3938 $('.register-link a').click(function () { 3939 $('.modal-toggle-2').addClass("active"); 3940 $('.modal-toggle-1').removeClass("active"); 3941 $('.register-form-tab').addClass("active").addClass("show"); 3942 $('.login-form-tab').removeClass("active").removeClass("show"); 3943 }); 3944 3945 /* ------------------------------------------------------------------------ */ 3946 /* datepicker 3947 /* ------------------------------------------------------------------------ */ 3948 if($('.db_input_date').length > 0) { 3949 $('.db_input_date').datepicker({ 3950 format : "yyyy-mm-dd", 3951 clearBtn: true, 3952 autoclose: true, 3953 language: houzez_date_language 3954 }); 3955 } 3956 3957 3958 /* ------------------------------------------------------------------------ */ 3959 /* custom scroll bars 3960 /* ------------------------------------------------------------------------ */ 3961 if (houzez_is_mobile) { 3962 //console.log('You are using a mobile device!'); 3963 } else { 3964 3965 if( $('.deals-table-wrap').length > 0 ) { 3966 $('.deals-table-wrap').overlayScrollbars({ 3967 overflowBehavior: { 3968 x: "scroll", 3969 y: "scroll" 3970 }, 3971 }); 3972 } 3973 3974 } 3975 3976 /* ------------------------------------------------------------------------ */
3977 /* sticky search bar 3978 /* ------------------------------------------------------------------------ */ 3979 var listing_nav_area_height = $('.property-navigation-wrap').innerHeight(); 3980 if( listing_nav_area_height == null ) { 3981 listing_nav_area_height = 0; 3982 } 3983 if( $('.houzez_sticky').length > 0 ) { 3984 $('.houzez_sticky').theiaStickySidebar({ 3985 additionalMarginTop: houzezStickyTop + advanced_search_nav_height + listing_nav_area_height, 3986 minWidth: 768, 3987 updateSidebarHeight: false 3988 }); 3989 } 3990 3991 3992 /* ------------------------------------------------------------------------ */ 3993 /* masonry blog 3994 /* ------------------------------------------------------------------------ */ 3995 3996 /** 3997 * Set appropriate spanning to any masonry item 3998 * 3999 * Get different properties we already set for the masonry, calculate 4000 * height or spanning for any cell of the masonry grid based on its 4001 * content-wrapper's height, the (row) gap of the grid, and the size 4002 * of the implicit row tracks. 4003 * 4004 * @param item Object A brick/tile/cell inside the masonry 4005 */ 4006 function resizeMasonryItem(item) { 4007 /* Get the grid object, its row-gap, and the size of its implicit rows */ 4008 var grid = document.getElementsByClassName('masonry')[0], 4009 rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap')), 4010 rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows')); 4011 4012 /* 4013 * Spanning for any brick = S 4014 * Grid's row-gap = G 4015 * Size of grid's implicitly create row-track = R 4016 * Height of item content = H 4017 * Net height of the item = H1 = H + G 4018 * Net height of the implicit row-track = T = G + R 4019 * S = H1 / T 4020 */ 4021 var rowSpan = Math.ceil((item.querySelector('.masonry-content').getBoundingClientRect().height + rowGap) / (rowHeight + rowGap)); 4022 4023 /* Set the spanning as calculated above (S) */ 4024 item.style.gridRowEnd = 'span ' + rowSpan; 4025 } 4026 4027 /** 4028 * Apply spanning to all the masonry items 4029 * 4030 * Loop through all the items and apply the spanning to them using 4031 * `resizeMasonryItem()` function. 4032 * 4033 * @uses resizeMasonryItem 4034 */ 4035 function resizeAllMasonryItems() { 4036 // Get all item class objects in one list 4037 var allItems = document.getElementsByClassName('masonry-brick'); 4038 4039 /* 4040 * Loop through the above list and execute the spanning function to 4041 * each list-item (i.e. each masonry item) 4042 */ 4043 for (var i = 0; i > allItems.length; i++) { 4044 resizeMasonryItem(allItems[i]); 4045 } 4046 } 4047 4048 /** 4049 * Resize the items when all the images inside the masonry grid 4050 * finish loading. This will ensure that all the content inside our 4051 * masonry items is visible. 4052 * 4053 * @uses ImagesLoaded 4054 * @uses resizeMasonryItem 4055 */ 4056 4057 if( $('.page-template-blog-masonry').length > 0 ) { 4058 var waitForImages = function() { 4059 var allItems = document.getElementsByClassName('masonry-brick'); 4060 for (var i = 0; i < allItems.length; i++) { 4061 imagesLoaded(allItems[i], function (instance) { 4062 var item = instance.elements[0]; 4063 resizeMasonryItem(item); 4064 }); 4065 } 4066 } 4067 4068 /* Resize all the grid items on the load and resize events */ 4069 var masonryEvents = ['load', 'resize']; 4070 masonryEvents.forEach(function (event) { 4071 window.addEventListener(event, resizeAllMasonryItems); 4072 }); 4073 4074 /* Do a resize once more when all the images finish loading */ 4075 waitForImages(); 4076 } 4077 4078 /* ------------------------------------------------------------------------ */ 4079 /* splash page slider 4080 /* ------------------------------------------------------------------------ */ 4081 var splash_slider_wrap = $('.splash-slider-wrap'); 4082 if(splash_slider_wrap.length > 0) { 4083 splash_slider_wrap.slick({ 4084 rtl: houzez_rtl, 4085 lazyLoad: 'ondemand', 4086 adaptiveHeight: true, 4087 autoplay: true, 4088 infinite: true, 4089 speed: 300, 4090 fade: true, 4091 slidesToShow: 1,
4092 arrows: false, 4093 }); 4094 } 4095 4096 /*-------------------------------------------------------------------------- 4097 * Add or remove favorites 4098 * -------------------------------------------------------------------------*/ 4099 houzez_init_add_favorite(ajaxurl, userID); 4100 houzez_init_remove_favorite(ajaxurl, userID); 4101 houzez_check_favourites(userID); 4102 4103 /* ------------------------------------------------------------------------ */ 4104 /* GET WINDOWS WIDTH HEIGHT 4105 /* ------------------------------------------------------------------------ */ 4106 function getWindowWidth() { 4107 return Math.max( $(window).width(), window.innerWidth); 4108 } 4109 4110 function getWindowHeight() { 4111 return Math.max( $(window).height(), window.innerHeight); 4112 } 4113 4114 /* ------------------------------------------------------------------------ */ 4115 /* WooCommerce Pay 4116 /* ------------------------------------------------------------------------ */ 4117 $('.houzez-woocommerce-pay').on('click', function(e) { 4118 e.preventDefault(); 4119 4120 let listID = $(this).data('listid'); 4121 let is_featured = $(this).data('featured'); 4122 4123 fave_processing_modal( processing_text ); 4124 4125 $.ajax({ 4126 type: 'POST', 4127 url: ajaxurl, 4128 data: { 4129 'action': 'houzez_perlist_woo_pay', 4130 'listing_id': listID, 4131 'is_featured': is_featured, 4132 }, 4133 success: function(data) { 4134 if ( data.success != false ) { 4135 window.location.href= houzez_vars.woo_checkout_url; 4136 } else { 4137 jQuery('#fave_modal').modal('hide'); 4138 } 4139 }, 4140 error: function(errorThrown) { 4141 4142 } 4143 }); // $.ajax 4144 4145 }); 4146 4147 /* ------------------------------------------------------------------------ */ 4148 /* WooCommerce Pay Package 4149 /* ------------------------------------------------------------------------ */ 4150 $('.houzez-woocommerce-package').on('click', function(e) { 4151 e.preventDefault(); 4152 4153 if( parseInt( userID, 10 ) === 0 || userID == undefined) { 4154 4155 jQuery('#login-register-form').modal('show'); 4156 jQuery('.login-form-tab').addClass('active show'); 4157 jQuery('.modal-toggle-1.nav-link').addClass('active'); 4158 4159 } else { 4160 let packid = $(this).data('packid'); 4161 4162 fave_processing_modal( processing_text ); 4163 4164 $.ajax({ 4165 type: 'POST', 4166 url: ajaxurl, 4167 data: { 4168 'action': 'houzez_woo_pay_package', 4169 'package_id': packid 4170 }, 4171 success: function(data) { 4172 if ( data.success != false ) { 4173 window.location.href= houzez_vars.woo_checkout_url; 4174 } else { 4175 jQuery('#fave_modal').modal('hide'); 4176 } 4177 }, 4178 error: function(errorThrown) { 4179 4180 } 4181 }); // $.ajax 4182 4183 } // login 4184 4185 }); 4186 4187 /* ------------------------------------------------------------------------ */ 4188 /* Top Banner Full Screen 4189 /* ------------------------------------------------------------------------ */ 4190 var setTopBannerFullScreen = function() { 4191 var totalTopBarsHeight = 0; 4192 var searchH = 0; 4193 var topBarH = 0; 4194 var totalBannerHeight = 0; 4195 var window_height = $(window).innerHeight(); 4196 var admin_bar = $('#wpadminbar'); 4197 var topBarB = $('.top-bar-wrap'); 4198 var admin_bar_height = admin_bar.outerHeight(); 4199 searchH = (window_height-header_area_height); 4200 4201 if( header_area.hasClass('header-transparent-wrap') ) { 4202 if( topBarB.length ) { 4203 topBarH = topBarB.outerHeight(); 4204 } 4205 totalBannerHeight = getWindowHeight() - (topBarH + admin_bar_height); 4206 4207 } else { 4208 4209 if( header_area.length && advanced_search_nav.length && !advanced_search_nav.hasClass('search-hidden')) { 4210 totalTopBarsHeight = parseInt(header_area_height) + parseInt(advanced_search_nav_height); 4211 4212 } else if(header_area.length) { 4213 totalTopBarsHeight = parseInt(header_area_height); 4214 4215 } 4216 totalBannerHeight = getWindowHeight() - (totalTopBarsHeight + admin_bar_height); 4217 } 4218 4219 $('.top-banner-wrap-fullscreen').css( 'height', totalBannerHeight ); 4220 } 4221 4222 if( !houzez_is_splash && $('.top-banner-wrap-fullscreen').length > 0 ) { 4223 $(document).ready(function() { 4224 setTopBannerFullScreen(); 4225 }); 4226 4227 $(window).on('resize', function () { 4228 setTopBannerFullScreen(); 4229 }); 4230 } 4231 4232 4233 /* ------------------------------------------------------------------------ */ 4234 /* compare Listings 4235 /* ------------------------------------------------------------------------ */ 4236 $(document).ready(function() { 4237 $('.compare-property-label').on('click', function() { 4238 $(this).toggleClass('active'); 4239 $('.compare-property-active').addClass('compare-property-active-push-toleft' ); 4240 $('#compare-property-panel').addClass('compare-property-panel-open'); 4241 }); 4242 $('.close-compare-panel').on('click', function() { 4243 $(this).toggleClass('active'); 4244 $('.compare-property-active').removeClass('compare-property-active-push-toleft' ); 4245 $('#compare-property-panel').removeClass('compare-property-panel-open'); 4246 }); 4247 var listings_compare = houzezGetCookie('houzez_compare_listings'); 4248 4249 var limit_item_compare = 4; 4250 add_to_compare(compare_url, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text, compare_limit, listings_compare, limit_item_compare ); 4251 remove_from_compare(listings_compare, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text); 4252 4253 }); 4254 4255 /*-------------------------------------------------------------------------- 4256 * Compare for ajax 4257 * -------------------------------------------------------------------------*/ 4258 function compare_for_ajax() { 4259 var listings_compare = houzezGetCookie('houzez_compare_listings'); 4260 var limit_item_compare = 4; 4261 add_to_compare(compare_url, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text, compare_limit, listings_compare, limit_item_compare ); 4262 remove_from_compare(listings_compare, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text); 4263 } 4264 4265 /*--------------------------------------------------------------------------- 4266 * One Page push state 4267 * -------------------------------------------------------------------------*/ 4268 $('.houzez-onepage-mode .header-main-wrap .main-nav li.nav-item a.nav-link').on( 'click', function(e) { 4269 4270 var currentUrl = $(this).attr('href'); 4271 window.history.pushState({houzezTheme: true}, '', currentUrl); 4272 4273 } ); 4274 4275 /*--------------------------------------------------------------------------- 4276 * Render compare data on page load 4277 * -------------------------------------------------------------------------*/ 4278 houzez_render_compare_properties_data(); 4279 function houzez_render_compare_properties_data() { 4280 let compare_listings = JSON.parse(localStorage.getItem('houzez_compare_listings')); 4281 4282 // Check if 'compare_listings' is not null and not empty before processing 4283 if (compare_listings && compare_listings.length > 0) { 4284 let properties_array = '';
4285 compare_listings.forEach(function(item) { 4286 let img = item.image; // Image URL from the local storage array 4287 let listingId = item.id; // Listing ID from the local storage array 4288 4289 properties_array += '<div class="compare-item remove-' + listingId + '">' + 4290 '<a href="#" class="remove-compare remove-icon" data-listing_id="' + listingId + '">' + 4291 '<i class="houzez-icon icon-remove-circle"></i></a>' + 4292 '<img class="img-fluid" src="' + img + '" width="200" height="150" alt="Thumb">' + 4293 '</div>'; 4294 }); 4295 4296 jQuery('.compare-wrap').html(properties_array); 4297 } 4298 } 4299 4300 4301 4302})(jQuery); 4303 4304/* ------------------------------------------------------------------------ */ 4305/* houzez Cookie 4306/* ------------------------------------------------------------------------ */ 4307function houzezSetCookie(cname, cvalue, exdays) { 4308 var d = new Date(); 4309 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 4310 var expires = "expires="+ d.toUTCString(); 4311 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 4312}; 4313 4314function houzezGetCookie(cname) { 4315 var name = cname + "="; 4316 var decodedCookie = decodeURIComponent(document.cookie); 4317 var ca = decodedCookie.split(';'); 4318 for(var i = 0; i <ca.length; i++) { 4319 var c = ca[i]; 4320 while (c.charAt(0) == ' ') { 4321 c = c.substring(1); 4322 } 4323 if (c.indexOf(name) == 0) { 4324 return c.substring(name.length, c.length); 4325 } 4326 } 4327 return ""; 4328}; 4329 4330function fave_processing_modal( msg ) { 4331 var process_modal ='<div class="modal fade" id="fave_modal" tabindex="-1" role="dialog" aria-labelledby="faveModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-body houzez_messages_modal">'+msg+'</div></div></div></div></div>'; 4332 jQuery('body').append(process_modal); 4333 jQuery('#fave_modal').modal(); 4334} 4335 4336function fave_processing_modal_close( ) { 4337 jQuery('#fave_modal').modal('hide'); 4338} 4339 4340/*-------------------------------------------------------------------------- 4341* Listing Gallery 4342* -------------------------------------------------------------------------*/ 4343 4344function houzez_grid_image_gallery() { 4345 if( houzez_vars.disable_property_gallery == 1 ) { 4346 4347 var gallery_behaviour = houzez_vars.grid_gallery_behaviour; 4348 var houzez_rtl = houzez_vars.houzez_rtl; 4349 4350 if( houzez_rtl == 'yes' ) { 4351 houzez_rtl = true; 4352 } else { 4353 houzez_rtl = false; 4354 } 4355 4356 jQuery('.hz-item-gallery-js').each( function() { 4357 4358 if ( !jQuery(this).hasClass('houzez-gallery-loaded') && jQuery(this).data('images') ) { 4359 var $this = jQuery(this); 4360 var href = jQuery(this).find('a.listing-featured-thumb').attr('href'); 4361 var link_target = jQuery(this).find('a.listing-featured-thumb').attr('target'); 4362 var images = jQuery(this).data('images'); 4363 4364 var html = '<div class="listing-gallery-wrap '+gallery_behaviour+'"><div class="houzez-listing-carousel">'; 4365 images.forEach(function(image, index){ 4366 html += '<div class="item"><a target="'+ link_target +'" href="'+ href +'"><img src="'+image.image+'" alt="'+image.alt+'" width="'+image.width+'" height="'+image.height+'" class="img-fluid"></a></div>'; 4367 }); 4368 html += '</div></div>'; 4369 jQuery(this).find('.listing-image-wrap .listing-thumb').append(html); 4370 4371 var listing_slider = $this.find('.houzez-listing-carousel'); 4372 4373 listing_slider.slick({ 4374 rtl: houzez_rtl, 4375 autoplay: false, 4376 lazyLoad: 'ondemand', 4377 infinite: false, 4378 speed: 300, 4379 slidesToShow: 1, 4380 arrows: true, 4381 prevArrow: '<button type="button" class="slick-prev slick-arrow"></button>', 4382 nextArrow: '<button type="button" class="slick-next slick-arrow"></button>', 4383 adaptiveHeight: false 4384 }); 4385 4386 is_listing_gallery_slider = true; 4387 4388 jQuery(this).addClass('houzez-gallery-loaded'); 4389 } 4390 4391 }); 4392 } 4393 4394 jQuery('.switch-btn').on("click", function () { 4395 jQuery('.hz-item-gallery-js .houzez-listing-carousel').slick('refresh'); 4396 }); 4397} 4398 4399/*-------------------------------------------------------------------------- 4400* Listing Preview 4401* -------------------------------------------------------------------------*/ 4402function houzez_listing_lightbox(ajaxurl, processing_text, houzez_rtl, userID) { 4403 4404 jQuery('.hz-show-lightbox-js').on('click', function() { 4405 4406 var listing_id = jQuery(this).data('listid'); 4407 var $parents = jQuery(this).parents('.item-wrap'); 4408 var preview_loader = $parents.find('.preview_loader'); 4409 4410 jQuery.ajax({ 4411 type: 'post', 4412 url: ajaxurl, 4413 data: { 4414 'action': 'load_lightbox_content', 4415 'listing_id': listing_id 4416 }, 4417 beforeSend: function( ) { 4418 preview_loader.empty().append('' 4419 +'<div class="houzez-overlay-loading">' 4420 +'<div class="overlay-placeholder">' 4421 +'<div class="loader-ripple spinner">' 4422 +'<div class="bounce1"></div>' 4423 +'<div class="bounce2"></div>' 4424 +'<div class="bounce3"></div>' 4425 +'</div>' 4426 +'</div>' 4427 +'</div>' 4428 ); 4429 }, 4430 complete: function(){ 4431 preview_loader.empty(); 4432 }, 4433 success: function( response ) { 4434 4435 jQuery('#hz-listing-model-content').html(response); 4436 4437 jQuery('#houzez-listing-lightbox').modal('show'); 4438 4439 jQuery('.lightbox-slider').not('.slick-initialized').slick({ 4440 rtl: houzez_rtl, 4441 lazyLoad: 'ondemand', 4442 infinite: true, 4443 speed: 300, 4444 slidesToShow: 1, 4445 arrows: true, 4446 adaptiveHeight: true, 4447 }); 4448 4449 jQuery('#houzez-listing-lightbox').on('shown.bs.modal', function (e) { 4450 jQuery('.lightbox-slider').slick('setPosition'); 4451 jQuery('.lightbox-slider').slick('refresh'); 4452 }); 4453 4454 4455 jQuery('.btn-expand').on('click', function () { 4456 jQuery('.lightbox-gallery-wrap').toggleClass("lightbox-gallery-full-wrap"); 4457 jQuery('.lightbox-slider').slick('setPosition'); 4458 4459 }); 4460 4461 jQuery('.btn-email').on('click', function () { 4462 jQuery('.lightbox-form-wrap').toggleClass("lightbox-form-wrap-show"); 4463 }); 4464 4465 houzez_init_add_favorite(ajaxurl, userID); 4466 houzez_init_remove_favorite(ajaxurl, userID); 4467 4468 }, 4469 error: function(xhr, status, error) { 4470 var err = eval("(" + xhr.responseText + ")"); 4471 console.log(err.Message); 4472 } 4473 }) 4474 4475 }); 4476} 4477 4478/*-------------------------------------------------------------------------- 4479* Add or remove favorites 4480* -------------------------------------------------------------------------*/ 4481function houzez_init_add_favorite(ajaxurl, userID) { 4482 jQuery(".add-favorite-js").on('click', function (e) { 4483 e.preventDefault(); 4484 var curnt = jQuery(this); 4485 var listID = jQuery(this).attr('data-listid'); 4486 add_to_favorite( ajaxurl, listID, curnt, userID ); 4487 return false;
4488 }); 4489} 4490 4491function houzez_init_remove_favorite(ajaxurl, userID) { 4492 jQuery(".remove_fav").on('click', function () { 4493 var curnt = jQuery(this); 4494 var listID = jQuery(this).attr('data-listid'); 4495 add_to_favorite( ajaxurl, listID, curnt, userID ); 4496 var itemWrap = curnt.parents('tr').remove(); 4497 }); 4498} 4499 4500function add_to_favorite( ajaxurl, listID, curnt, userID ) { 4501 if( parseInt( userID, 10 ) === 0 || userID == undefined) { 4502 4503 var add_to_favorite_login_required = houzez_vars.add_to_favorite_login_required; 4504 4505 if ( add_to_favorite_login_required != 0 ) { 4506 jQuery('#login-register-form').modal('show'); 4507 jQuery('.login-form-tab').addClass('active show'); 4508 jQuery('.modal-toggle-1.nav-link').addClass('active'); 4509 } else { 4510 add_to_favorite_without_login(curnt); 4511 } 4512 4513 } else { 4514 var $parents = curnt.parents('.item-wrap'); 4515 var preview_loader = $parents.find('.preview_loader'); 4516 4517 jQuery.ajax({ 4518 type: 'post', 4519 url: ajaxurl, 4520 dataType: 'json', 4521 data: { 4522 'action': 'houzez_add_to_favorite', 4523 'listing_id': listID 4524 }, 4525 beforeSend: function( ) { 4526 preview_loader.empty().append('' 4527 +'<div class="houzez-overlay-loading">' 4528 +'<div class="overlay-placeholder">' 4529 +'<div class="loader-ripple spinner">' 4530 +'<div class="bounce1"></div>' 4531 +'<div class="bounce2"></div>' 4532 +'<div class="bounce3"></div>' 4533 +'</div>' 4534 +'</div>' 4535 +'</div>' 4536 ); 4537 }, 4538 complete: function(){ 4539 preview_loader.empty(); 4540 }, 4541 success: function( data ) { 4542 if( data.added ) { 4543 curnt.children('i').addClass('text-danger'); 4544 } else { 4545 curnt.children('i').removeClass('text-danger'); 4546 } 4547 preview_loader.empty(); 4548 }, 4549 complete: function(){ 4550 4551 }, 4552 error: function(xhr, status, error) { 4553 var err = eval("(" + xhr.responseText + ")"); 4554 console.log(err.Message); 4555 } 4556 }); 4557 } // End else 4558} 4559 4560// Add to Favourite without login 4561function add_to_favorite_without_login(curnt) { 4562 4563 var listings_favorite = houzezGetCookie('houzez_favorite_listings'); 4564 4565 if ( listings_favorite && listings_favorite.length ) { 4566 listings_favorite = listings_favorite.split(','); 4567 } else { 4568 listings_favorite = []; 4569 } 4570 4571 var listing_id = curnt.data('listid'); 4572 var index = listings_favorite.indexOf( listing_id.toString() ); 4573 4574 if ( index == -1 ) { 4575 listings_favorite.push(listing_id.toString()); 4576 houzezSetCookie('houzez_favorite_listings', listings_favorite.join(','), 30); 4577 4578 jQuery("span.frvt-count").html(""); 4579 jQuery("span.frvt-count").html(listings_favorite.length); 4580 4581 for (var i = 0 ; i < listings_favorite.length; i++) { 4582 jQuery('.add-favorite-js[data-listid="' + listings_favorite[i] + '"] i').addClass("text-danger"); 4583 jQuery('.add-favorite-js[data-listid="' + listings_favorite[i] + '"]').addClass('remove-favorite'); 4584 } 4585 4586 } else { 4587 listings_favorite.splice(index, 1); 4588 houzezSetCookie('houzez_favorite_listings', listings_favorite.join(','), 30); 4589 jQuery("span.frvt-count").html("") 4590 jQuery("span.frvt-count").html(listings_favorite.length); 4591 jQuery('.add-favorite-js[data-listid="' + listing_id.toString() + '"] i').removeClass("text-danger"); 4592 jQuery('.add-favorite-js[data-listid="' + listing_id.toString() + '"]').removeClass("remove-favorite"); 4593 } 4594 4595 jQuery('a.favorite-btn').attr('href', houzez_vars.favorite_url + '?ids=' + listings_favorite); 4596 4597 return false; 4598 4599} 4600 4601function houzez_check_favourites( userID ) { 4602 4603 if( parseInt( userID, 10 ) === 0 || userID == undefined) { 4604 var listings_favorite = houzezGetCookie('houzez_favorite_listings'); 4605 4606 jQuery('a.favorite-btn').attr('href', houzez_vars.favorite_url + '?ids=' + listings_favorite); 4607 4608 if ( listings_favorite && listings_favorite.length ) { 4609 listings_favorite = listings_favorite.split(','); 4610 4611 if ( listings_favorite.length ) { 4612 for (var i = 0 ; i < listings_favorite.length; i++) { 4613 jQuery('.add-favorite-js[data-listid="' + listings_favorite[i] + '"] i').addClass("text-danger"); 4614 jQuery('.add-favorite-js[data-listid="' + listings_favorite[i] + '"]').addClass('remove-favorite'); 4615 } 4616 4617 jQuery("span.frvt-count").html(""); 4618 jQuery("span.frvt-count").html(listings_favorite.length); 4619 } 4620 } else { 4621 listings_favorite = []; 4622 } 4623 } 4624} 4625 4626function add_to_compare(compare_url, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text, compare_limit, listings_compare, limit_item_compare) { 4627 var storedData = localStorage.getItem('houzez_compare_listings'); 4628 var listings_compare = storedData ? JSON.parse(storedData) : []; 4629 4630 jQuery('a.compare-btn').attr('href', compare_url + '?ids=' + listings_compare.map(item => item.id).join(',')); 4631 4632 if (listings_compare.length > 0) { 4633 jQuery('.compare-property-label').fadeIn(1000); 4634 } 4635 4636 if(listings_compare.length){ 4637 for(var i = 0 ; i < listings_compare.length; i++) { 4638 jQuery( '.houzez_compare[data-listing_id="'+listings_compare[i].id+'"] i').removeClass('icon-add-circle').addClass('icon-subtract-circle'); 4639 jQuery( '.houzez_compare[data-listing_id="'+listings_compare[i].id+'"]').attr('title', remove_compare_text); 4640 jQuery( '.houzez_compare[data-listing_id="'+listings_compare[i].id+'"]').tooltip('hide').attr('data-original-title', remove_compare_text); 4641 } 4642 jQuery('.compare-property-label').find('.compare-count').html(listings_compare.length); 4643 } 4644 4645 jQuery('.houzez_compare').on('click', function(e) { 4646 e.preventDefault(); 4647 4648 var storedData = localStorage.getItem('houzez_compare_listings'); 4649 var listings_compare = storedData ? JSON.parse(storedData) : []; 4650 4651 var listing_id = jQuery(this).data('listing_id'); 4652 var index = listings_compare.findIndex(item => item.id === listing_id.toString()); 4653 var image_div = jQuery(this).parents('.item-wrap'); 4654 var thumb_url = image_div.find('img').attr('src'); 4655 4656 if(index == -1){ 4657 if(listings_compare.length >= limit_item_compare){ 4658 alert(compare_limit); 4659 }else{ 4660 jQuery('.compare-wrap').append('<div class="compare-item remove-'+listing_id+'"><a href="" class="remove-compare remove-icon" data-listing_id="'+listing_id+'"><i class="houzez-icon icon-remove-circle"></i></a><img class="img-fluid" src="'+thumb_url+'" width="200" height="150" alt="Thumb"></div>'); 4661 4662 listings_compare.push({id: listing_id.toString(), image: thumb_url}); 4663 localStorage.setItem('houzez_compare_listings', JSON.stringify(listings_compare)); 4664 jQuery(this).attr('title', remove_compare_text); 4665 jQuery(this).find('i').removeClass('icon-add-circle').addClass('icon-subtract-circle'); 4666 jQuery('.compare-property-label').find('.compare-count').html(listings_compare.length); 4667 jQuery('a.compare-btn').attr('href', compare_url + '?ids=' + listings_compare.map(item => item.id).join(',')); 4668 jQuery('.compare-property-label').fadeIn(1000); 4669 jQuery(this).toggleClass('active'); 4670 jQuery('.compare-property-active').addClass('compare-property-active-push-toleft'); 4671 jQuery('#compare-property-panel').addClass('compare-property-panel-open'); 4672 jQuery(this).tooltip('dispose').tooltip('show'); 4673 remove_from_compare(listings_compare, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text); 4674 } 4675 } else { 4676 jQuery('div.remove-'+listing_id).remove(); 4677 jQuery(this).attr('title', add_compare_text); 4678 jQuery(this).find('i').removeClass('icon-subtract-circle').addClass('icon-add-circle'); 4679 listings_compare.splice(index, 1); 4680 localStorage.setItem('houzez_compare_listings', JSON.stringify(listings_compare)); 4681 jQuery('.compare-property-label').find('.compare-count').html(listings_compare.length); 4682 jQuery('a.compare-btn').attr('href', compare_url + '?ids=' + listings_compare.map(item => item.id).join(',')); 4683 jQuery(this).tooltip('dispose').tooltip('show'); 4684 4685 if (listings_compare.length > 0) { 4686 jQuery('.compare-property-label').fadeIn(1000); 4687 jQuery(this).toggleClass('active'); 4688 jQuery('.compare-property-active').addClass('compare-property-active-push-toleft'); 4689 jQuery('#compare-property-panel').addClass('compare-property-panel-open'); 4690 } else { 4691 jQuery('.compare-property-label').fadeOut(1000); 4692 } 4693 } 4694 return false;
4695 }); 4696} 4697 4698function remove_from_compare(listings_compare, compare_add_icon, compare_remove_icon, add_compare_text, remove_compare_text) { 4699 // Moved the event binding outside of this function to prevent multiple bindings 4700 // This should be called once, outside and independently from this function 4701 jQuery('.remove-compare').off('click').on('click', function(e) { 4702 e.preventDefault(); 4703 var compare_url = houzez_vars.compare_url; // Ensure houzez_vars is globally available 4704 var storedData = localStorage.getItem('houzez_compare_listings'); 4705 listings_compare = storedData ? JSON.parse(storedData) : []; 4706 4707 var listing_id = jQuery(this).data('listing_id'); 4708 var index = listings_compare.findIndex(item => item.id === listing_id.toString()); 4709 4710 if (index !== -1) { // Only proceed if the item was found 4711 listings_compare.splice(index, 1); 4712 localStorage.setItem('houzez_compare_listings', JSON.stringify(listings_compare)); 4713 4714 jQuery('.compare-property-label').find('.compare-count').html(listings_compare.length); 4715 4716 // Update UI elements if they exist 4717 var compareElement = jQuery('.compare-' + listing_id); 4718 if (compareElement.length) { 4719 compareElement.attr('title', add_compare_text); 4720 compareElement.tooltip('hide').attr('data-original-title', add_compare_text); 4721 compareElement.find('i').removeClass('icon-subtract-circle').addClass('icon-add-circle'); 4722 } 4723 4724 jQuery(this).parents('.compare-item').remove(); 4725 4726 // Update the compare URL 4727 jQuery('a.compare-btn').attr('href', compare_url + '?ids=' + listings_compare.map(item => item.id).join(',')); 4728 } 4729 }); 4730} 4731 4732 4733 4734/* ------------------------------------------------------------------------ */ 4735/* mobile popup js 4736/* ------------------------------------------------------------------------ */ 4737 4738function houzez_grid_call_to_action() { 4739 jQuery('.hz-call-popup-js').on('click', function() { 4740 var call_model_id = jQuery(this).data('model-id'); 4741 jQuery('#'+call_model_id).appendTo("body"); 4742 jQuery('#'+call_model_id).modal("show"); 4743 4744 }); 4745 4746 jQuery('.hz-email-popup-js').on('click', function() { 4747 var email_model_id = jQuery(this).data('model-id'); 4748 jQuery('#'+email_model_id).appendTo("body"); 4749 jQuery('#'+email_model_id).modal("show"); 4750 4751 }); 4752} 4753
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.