1////////////////////// 2// Global Functions // 3////////////////////// 4 5// Loader for Buttons 6if ($('.btn-loader').length) { 7 $('.btn-loader').on('click', function(e){ 8 if (e.ctrlKey || e.metaKey) { 9 // Don't Show Loader 10 } else { 11 // Show Loader 12 var loadingText = $(this).data('btn-loader-loading-text'); 13 $(this).addClass('loading').text(loadingText); 14 } 15 }); 16 // Reset Button Loader 17 function btnLoaderReset(btnLoader) { 18 var loaderText = btnLoader.data('btn-loader-text'); 19 btnLoader.removeClass('loading').text(loaderText); 20 } 21 // Reset Button Loader if Back Button is pressed 22 var count = 0; 23 window.onload = function () { 24 if (typeof history.pushState === "function") { 25 history.pushState("back", null, null); 26 window.onpopstate = function () { 27 history.pushState('back', null, null); 28 if(count == 1){ 29 $('.btn-loader').each(function(){ 30 btnLoaderReset($(this)); 31 }); 32 } 33 }; 34 } 35 } 36 setTimeout(function(){count = 1;},200);
37} 38 39//////////////////// 40// Document Ready // 41//////////////////// 42$(document).ready(function(){ 43 44 // Header Height - Measures the headers height, used by CSS for height calculations under the header 45 headerElement = $('.i-header')[0]; 46 announcementElement = $('.announcement-bar-wrap')[0]; 47 qsElement = $('.hero-quick-search')[0]; 48 let resizeObserver = new ResizeObserver(() => { 49 var headerHeight = $('.i-header').outerHeight(); 50 document.documentElement.style.setProperty('--headerHeight', headerHeight + 'px'); 51 52 var announcementHeight = $('.announcement-bar-wrap').outerHeight(); 53 if ($('.announcement-bar-wrap').length) { 54 document.documentElement.style.setProperty('--announcementHeight', announcementHeight + 'px'); 55 } else { 56 document.documentElement.style.setProperty('--announcementHeight', '100px'); 57 } 58 59 var qsHeight = $('.hero-quick-search').outerHeight(); 60 document.documentElement.style.setProperty('--qsHeight', qsHeight + 'px'); 61 }); 62 resizeObserver.observe(headerElement,announcementElement,qsElement); 63 64 // Main Navigation Toggle Mobile 65 $('.i-header-navigation-toggle').on('click', function () { 66 $('.i-header-navigation-container').toggleClass('open'); 67 $('html').addClass('i-header-navigation-container-open'); 68 if ($('.pdp-sidebar-footer').hasClass('show')) { 69 $('.pdp-sidebar-footer').removeClass('show'); 70 $('.pdp-sidebar-footer').addClass('navigation-show'); 71 } 72 }); 73 $('.i-header-navigation-close').on('click', function () { 74 $('.i-header-navigation-container').toggleClass('open'); 75 $('html').removeClass('i-header-navigation-container-open'); 76 if ($('.pdp-sidebar-footer').hasClass('navigation-show')) { 77 $('.pdp-sidebar-footer').addClass('show'); 78 $('.pdp-sidebar-footer').removeClass('navigation-show'); 79 } 80 }); 81 $('.i-header-navigation-sub-toggle').on('click', function () { 82 var subNav = $(this).next('.i-header-navigation-sub'); 83 var subHeight = subNav[0].scrollHeight; 84 var subParent = $(this).closest('.i-header-navigation-sub'); 85 if (!$(this).hasClass('toggled')) { 86 // Open Sub Nav 87 $(this).addClass('toggled'); 88 $(this).next('.i-header-navigation-sub').addClass('open'); 89 subNav.css({ 'max-height': subHeight + 'px' }); 90 if (subParent.length == 1) { 91 subParent.css({ 'max-height': 'none' }); 92 setTimeout(function () { 93 var subParentHeight = subParent[0].scrollHeight; 94 subParent.css({ 'max-height': subParentHeight + 'px' }); 95 }, 450); // 50 milliseconds after the 400ms (0.4s) CSS transition animation 96 } 97 } else { 98 // Close Sub Nav 99 $(this).removeClass('toggled'); 100 $(this).next('.i-header-navigation-sub').removeClass('open'); 101 subNav.css({ 'max-height': '0' }); 102 if (subParent.length == 1) { 103 var subParentHeight = subParent[0].scrollHeight; 104 subParent.css({ 'max-height': subParentHeight + 'px' }); 105 } 106 } 107 }); 108 109 // Add class to last child of Nav 110 $(window).on('resize',function(){ 111 if ($(window).outerWidth() >= 1025) { 112 $('.i-header-navigation-item:last-child:has(.i-header-navigation-sub)').addClass('i-header-navigation-item-end'); 113 } 114 }).resize(); 115 116 // BE - Header Action Toggles 117 $('.i-header-actions-toggle').on('click', function () { 118 $(this).tooltip('hide'); 119 if (!$(this).hasClass('active')) { 120 $('.i-header-actions-toggle').not(this).removeClass('active'); 121 $('.i-header-actions-toggled').not(this).removeClass('open'); 122 $(this).addClass('active'); 123 $(this).parent().find('.i-header-actions-toggled').addClass('open'); 124 } else { 125 $(this).removeClass('active'); 126 $(this).parent().find('.i-header-actions-toggled').removeClass('open'); 127 } 128 // Recently Viewed - Overflow management for desktop and mobile 129 if ($(this).hasClass('i-header-recently-viewed-be-toggle')) { 130 if ($('html').hasClass('recently-viewed-toggled')) { 131 $('html').removeClass('recently-viewed-toggled'); 132 } else { 133 $('html').addClass('recently-viewed-toggled'); 134 } 135 $('html').removeClass('srp-map-open'); 136 $('html').removeClass('favorites-toggled'); 137 } 138 if ($(this).hasClass('i-header-recently-viewed-mls-toggle')) { 139 if ($('html').hasClass('recently-viewed-toggled')) { 140 $('html').removeClass('recently-viewed-toggled'); 141 } else { 142 $('html').addClass('recently-viewed-toggled'); 143 } 144 $('html').removeClass('srp-map-open'); 145 $('html').removeClass('favorites-toggled'); 146 } 147 // Favorites - Overflow management for desktop and mobile 148 if ($(this).hasClass('i-header-favorites-be-toggle')) { 149 if ($('html').hasClass('favorites-toggled')) { 150 $('html').removeClass('favorites-toggled'); 151 } else { 152 $('html').addClass('favorites-toggled'); 153 } 154 $('html').removeClass('srp-map-open'); 155 $('html').removeClass('recently-viewed-toggled'); 156 } 157 if ($(this).hasClass('i-header-favorites-mls-toggle')) { 158 if ($('html').hasClass('favorites-toggled')) { 159 $('html').removeClass('favorites-toggled'); 160 } else { 161 $('html').addClass('favorites-toggled'); 162 } 163 $('html').removeClass('srp-map-open'); 164 $('html').removeClass('recently-viewed-toggled'); 165 } 166 }); 167 168 // BE - Header Action Close 169 $('.i-header-action-dropdown-close').on('click', function () { 170 $('html').removeClass('favorites-toggled'); 171 $('html').removeClass('srp-map-open'); 172 $('html').removeClass('recently-viewed-toggled'); 173 $(this).closest('.i-header-actions-toggled').prev('.i-header-actions-toggle').removeClass('active'); 174 $(this).closest('.i-header-actions-toggled').toggleClass('open'); 175 }); 176 177 // BE - Favorites Dropdown Container 178 var favoritesDropdownContainer = $('.i-header-favorites .i-header-action-dropdown-main-container'); 179 180 // BE - Favorites Header Toggle - Click and load favorites if they aren't already shown 181 $('.i-header-favorites-be-toggle').on('click',function(){ 182 if ( !favoritesDropdownContainer.find('.be-header-dropdown-list').length ) { 183 $.ajax({
184 type: 'GET', 185 url: siteFolder + 'ajax/favorites/', 186 cache: false, 187 success: function(data) { 188 favoritesDropdownContainer.html(data); 189 } 190 }); 191 } 192 }); 193 $('.i-header-favorites-mls-toggle').on('click',function(){ 194 if ( !favoritesDropdownContainer.find('.mls-header-dropdown-list').length ) { 195 $.ajax({ 196 type: 'GET', 197 url: siteFolder + 'ajax/mls/favorites/', 198 cache: false, 199 success: function(data) { 200 favoritesDropdownContainer.html(data); 201 } 202 }); 203 } 204 }); 205 206 // BE - Update Favorites List Function - saveFavorites 207 function updateFavoritesList(thisElement, propDataHolder, action) { 208 // Get Property Data 209 var property = thisElement.closest(propDataHolder); 210 var propertyID = property.data('unitcode'); 211 var propWidget = $('[data-unitcode='+ propertyID +']'); 212 var propTitle = propWidget.data('unitshortname') || property.find('.i-header-dropdown-list-item-title').text(); 213 var propWidgetFavorite = propWidget.find('.be-property-widget-img-area-favorite'); 214 if (action == 'add') { 215 var favAction = 1; 216 } 217 if (action == 'remove') { 218 var favAction = 0; 219 // Remove from Favorites 220 propWidgetFavorite.removeClass('favorite'); 221 // Toast Notification 222 $.fn.beToast({ 223 icon: 'heart-regular', 224 iconColor: 'body-font-color', 225 title: 'Removed from Favorites', 226 body: propTitle 227 }); 228 } 229 // Save Favorites 230 $.ajax({
231 type: 'GET', 232 url: siteFolder + 'ajax/saveFavorites/?propertyID='+propertyID+'&favAdded='+favAction, 233 success: function(data) { 234 //console.log(data); 235 // If Zero Favories are saved then hide the badge 236 if (data == -1) { 237 openModal('favorites-requires-login'); 238 } else if (data == 0) { 239 $('.i-header-favorites-toggle .badge').addClass('d-none'); 240 } else { 241 if (action == 'add') { 242 // Add to Favorites 243 propWidgetFavorite.addClass('favorite'); 244 // Toast Notification 245 $.fn.beToast({ 246 icon: 'heart-solid', 247 iconColor: 'true-red', 248 title: 'Added to Favorites', 249 body: propTitle 250 }); 251 } 252 // Update the number count on the fly in the header if more than 0 253 $('.i-header-favorites-toggle .badge').html(data).removeClass('d-none'); 254 } 255 // Now load the data into the top right view via ajax 256 $.ajax({ 257 type: 'GET', 258 url: siteFolder + 'ajax/favorites/', 259 cache: false, 260 success: function(data) { 261 // Load Returned Data 262 favoritesDropdownContainer.html(data); 263 } 264 }); 265 } 266 }); 267 } 268 269 // MLS - Update Favorites List Function - saveFavorites 270 function updateMLSFavoritesList(thisElement, propDataHolder, action) { 271 // Get Property Data 272 var property = thisElement.closest(propDataHolder); 273 var propertyID = property.data('unitcode'); 274 var propWidget = $('[data-unitcode='+ propertyID +']'); 275 var propTitle = propWidget.data('unitshortname') || property.find('.i-header-dropdown-list-item-title').text(); 276 var propWidgetFavorite = propWidget.find('.mls-property-widget-img-area-favorite'); 277 if (action == 'add') { 278 var favAction = 1; 279 } 280 if (action == 'remove') { 281 var favAction = 0; 282 // Remove from Favorites 283 propWidgetFavorite.removeClass('favorite'); 284 // Toast Notification 285 $.fn.beToast({ 286 icon: 'heart-regular', 287 iconColor: 'body-font-color', 288 title: 'Removed from Favorites', 289 body: propTitle 290 }); 291 } 292 // Save Favorites 293 $.ajax({
294 type: 'GET', 295 url: siteFolder + 'ajax/mls/saveFavorites/?mlsPropertyID='+propertyID+'&favAdded='+favAction, 296 success: function(data) { 297 // If Zero Favories are saved then hide the badge 298 if (data == -1) { 299 openModal('mls-favorites-requires-login'); 300 } else if (data == 0) { 301 $('.i-header-favorites-toggle .badge').addClass('d-none'); 302 // Update the Compare Favorites Number on the Compare Favorites Page 303 if ($('#favTotal').length) { 304 $('#favTotal').html(0); 305 $('.compare-wrap .container') 306 .html('<h1 class="site-color-1">Compare Your Favorites</h1>') 307 .append(alertMessage('alert-warning','You do not have any Favorites now!')); 308 } 309 $('.mls-header-bar-sub-send-and-print button').prop('disabled',true); 310 } else { 311 if (action == 'add') { 312 // Add to Favorites 313 propWidgetFavorite.addClass('favorite'); 314 // Toast Notification 315 $.fn.beToast({ 316 icon: 'heart-solid', 317 iconColor: 'true-red', 318 title: 'Added to Favorites', 319 body: propTitle 320 }); 321 } 322 // Update the number count on the fly in the header if more than 0 323 $('.i-header-favorites-toggle .badge').html(data).removeClass('d-none'); 324 // Update the Compare Favorites Number on the Compare Favorites Page 325 if ($('#favTotal').length) { 326 $('#favTotal').html(data); 327 } 328 } 329 // Now load the data into the top right view via ajax 330 $.ajax({
331 type: 'GET', 332 url: siteFolder + 'ajax/mls/favorites/', 333 cache: false, 334 success: function(data) { 335 // Load Returned Data 336 favoritesDropdownContainer.html(data); 337 } 338 }); 339 } 340 }); 341 } 342 343 // BE - Property Widget - Favorites Heart Click - Shows a Toast and adds it to Favorites list 344 $(document).on('click', '.be-property-widget-img-area-favorite', function () { 345 if (!$(this).hasClass('favorite')) { 346 // Add to Favorites List 347 updateFavoritesList($(this), '.be-property-widget', 'add'); 348 } else { 349 // Remove from Favorites List 350 updateFavoritesList($(this), '.be-property-widget', 'remove'); 351 } 352 }); 353 $(document).on('click', '.mls-property-widget-img-area-favorite', function () { 354 if (!$(this).hasClass('favorite')) { 355 // Add to Favorites List 356 updateMLSFavoritesList($(this), '.mls-property-widget', 'add'); 357 } else { 358 // Remove from Favorites List 359 updateMLSFavoritesList($(this), '.mls-property-widget', 'remove'); 360 } 361 }); 362 363 // BE - Remove From Favorites List 364 $(document).on('click', '.be-header-dropdown-list-remove-from-favs', function(){ 365 // Remove from Favorites List 366 updateFavoritesList($(this), '.be-header-dropdown-list-item', 'remove'); 367 }); 368 $(document).on('click', '.mls-header-dropdown-list-remove-from-favs', function(){ 369 // Remove from Favorites List 370 updateMLSFavoritesList($(this), '.mls-header-dropdown-list-item', 'remove'); 371 }); 372 373 // BE - Recently Viewed List Dropdown 374 $(document).on('click','.i-header-recently-viewed-toggle',function(){ 375 if ( !$('.i-header-recently-viewed .i-header-action-dropdown-main-container').find('.i-header-dropdown-list').length ) { 376 // Load the recently viewed data 377 $.ajax({
378 type: 'GET', 379 url: siteFolder + 'ajax/recentlyViewed/', 380 cache: false, 381 success: function(data) { 382 $('.i-header-recently-viewed .i-header-action-dropdown-main-container').html(data); 383 } 384 }); 385 } 386 }); 387 $(document).on('click','.i-header-recently-viewed-mls-toggle',function(){ 388 if ( !$('.i-header-recently-viewed .i-header-action-dropdown-main-container').find('.i-header-dropdown-list').length ) { 389 // Load the recently viewed data 390 $.ajax({ 391 type: 'GET', 392 url: siteFolder + 'ajax/mls/recentlyViewed/', 393 cache: false, 394 success: function(data) { 395 $('.i-header-recently-viewed .i-header-action-dropdown-main-container').html(data); 396 } 397 }); 398 } 399 }); 400 401 // Header Site Search 402 if ($('.site-search-trigger').length) { 403 $('.site-search-trigger').on('click', function(){ 404 $('.site-search-form-wrap').toggleClass('active'); 405 }); 406 } 407 408 // Selectpicker 409 if ($('.selectpicker').length) { 410 $('.selectpicker').selectpicker(); 411 412 $('.selectpicker').on('change', function () { 413 $(this).next('.error').hide(); 414 }); 415 } 416 417 // Lazy Load 418 if ($('.lazy').length) { 419 $('.lazy').lazy({ 420 effect: 'fadeIn', 421 effectTime: 1000, 422 threshold: 0, 423 afterLoad: function(element) { 424 var lazyElement = element.get(0); 425 // Add a Class to set the placeholder background to transparent 426 $(lazyElement).addClass('loaded'); 427 } 428 }); 429 } 430 431 // Swiper 432 if ($('.swiper-container').length) { 433 434 // Homepage Accommodations Swiper 435 if ($('.accommodations-home-img-swiper').length) { 436 var accommodationsSwiperImg = new Swiper('.accommodations-home-img-swiper', { 437 loop: true, 438 parallax: true, 439 watchSlidesProgress: true, 440 spaceBetween: 0, 441 pagination: { 442 el: '.accommodations-pagination', 443 clickable: true, 444 } 445 }); 446 } 447 448 // ADA Compliance for Swiper Carousels 449 setTimeout(function(){ 450 if ($('.swiper-pagination').length) { 451 if (!$('.swiper-pagination-bullet .hidden').length) { 452 $('.swiper-pagination-bullet').append('<div class="hidden">Slide Dot</div>'); 453 } 454 } 455 if ($('.swiper-button-prev').length) { 456 if (!$('.swiper-button-prev .hidden').length) { 457 $('.swiper-button-prev').append('<div class="hidden">Prev</div>'); 458 } 459 } 460 if ($('.swiper-button-next').length) { 461 if (!$('.swiper-button-next .hidden').length) { 462 $('.swiper-button-next').append('<div class="hidden">Next</div>'); 463 } 464 } 465 }, 500); 466 } 467 468 // Fancybox 469 if ($('[data-fancybox]').length) { 470 if ( $('.swiper-container').length ) { 471 $('.swiper-slide:not(.swiper-slide-duplicate) [data-fancybox]').fancybox({ 472 infobar: true, 473 arrows: true, 474 protect: true, 475 backFocus: true, 476 thumbs: { 477 autoStart: true, 478 }, 479 mobile: { 480 thumbs: { 481 autoStart: false 482 } 483 }, 484 idleTime: false, 485 toolbar: true, 486 buttons: [ 487 'zoom', 488 'thumbs', 489 'slideShow', 490 'close' 491 ] 492 }); 493 } else { 494 $('[data-fancybox]').fancybox({ 495 infobar: true, 496 arrows: true, 497 protect: true, 498 thumbs: { 499 autoStart: true, 500 }, 501 mobile: { 502 thumbs: { 503 autoStart: false 504 } 505 }, 506 idleTime: false, 507 toolbar: true, 508 buttons: [ 509 'zoom', 510 'thumbs', 511 'slideShow', 512 'close' 513 ] 514 }); 515 } 516 } 517 518 // Tooltips 519 if ($('[data-toggle="tooltip"]').length) { 520 $('[data-toggle="tooltip"]').tooltip(); 521 } 522 523 // Slide Up Alert 524 if ($('[data-toggle="slideUp"]').length) { 525 // Timeout to add class active 526 setTimeout(function(){ 527 $('[data-toggle="slideUp"]').addClass('active'); 528 }, 750); 529 530 $(window).on('resize', function(){ 531 // Identify the Alert 532 var slideUp = $('[data-toggle="slideUp"]'); 533 // Find the Alert Height 534 var slideUpHeight = slideUp.outerHeight(); 535 //console.log(slideUpHeight); 536 // If there are sibling alerts, take the height and push it above the one before it 537 $(slideUp).next().css('bottom', slideUpHeight); 538 // Button to remove class active - If there are sibling alerts, reset the Alert positioning 539 $('[data-dismiss="slideUp"]').on('click', function(){ 540 $(this).parent(slideUp).removeClass('active'); 541 $(slideUp).next().css('bottom', 'auto'); 542 }) 543 }).resize(); 544 } 545 546 // Return to Top 547 if ($('#returnToTop').length) { 548 $('#returnToTop').on('click', function(){ 549 $('html, body').animate({scrollTop : 0},300); 550 return false; 551 });
552 } 553 554 // DataTables - All Properties Page 555 if ($('#aZPropertiesTable').length) { 556 $('#aZPropertiesTable').DataTable({ 557 paging: false, 558 "oLanguage": { 559 "sSearch": "Search By Name:" 560 }, 561 columnDefs: [ 562 { 563 targets: [4], // 4 is the column item to target 564 render: function( data, type, row, meta ) { 565 if (type == "sort" || type == "type") 566 return parseFloat(data.replace(/[$,]/g, '')); 567 else 568 return data; 569 } 570 } 571 ] 572 }); 573 } 574 575 // Form Reset/Clear button 576 if ($('[type=reset]').length) { 577 $('[type=reset]').on('click', function(){ 578 $('input.required').removeClass('error'); 579 $('label.error').remove(); 580 grecaptcha.reset(); 581 }); 582 } 583 584 // Recaptcha - Time to wait to check if it's valid 585 setInterval(function() { 586 verifyGoogleRecaptcha(); 587 }, 3000); 588 589 // Recaptcha - Verify Google Recaptcha Function 590 function verifyGoogleRecaptcha() { 591 if ($('#g-recaptcha-response').length) { 592 var isVerified = grecaptcha.getResponse(); 593 if(!isVerified.length == 0){ 594 $('.g-recaptcha-error').remove(); 595 } 596 } 597 } 598 599 // Validation - Contact page 600 if ($('form#contactform').length) { 601 $('form#contactform').validate({ 602 invalidHandler: function(event, validator) { 603 var errors = validator.numberOfInvalids(); 604 if (errors) { 605 btnLoaderReset($('form#contactform .btn-loader')); 606 } 607 }, 608 submitHandler: function(form){ 609 $.ajax({
610 type: "POST", 611 url: siteFolder + "ajax/contactUs/", 612 data: $('form#contactform').serialize(), 613 dataType: "text", 614 success: function (response) { 615 response = $.trim(response); 616 if(response === "success") { 617 $('form#contactform').hide(); 618 $('#contactformMSG').html(`<div class="alert alert-success mb-3">Thanks! Your email has been sent!</div>`); 619 } else { 620 btnLoaderReset($('form#contactform .btn-loader')); 621 $("form#contactform div.g-recaptcha-error").html(`<div class="alert alert-danger mb-3">You must complete the reCAPTCHA</div>`); 622 } 623 } 624 }); 625 return false; 626 } 627 }); 628 } 629 630 // Validation - Footer form 631 if ($('form#footerform').length) { 632 $('form#footerform').validate({ 633 invalidHandler: function(event, validator) { 634 var errors = validator.numberOfInvalids(); 635 if (errors) { 636 btnLoaderReset($('form#footerform .btn-loader')); 637 } 638 }, 639 submitHandler: function(form){ 640 $.ajax({
641 type: "POST", 642 url: siteFolder + "ajax/footerSignup/", 643 data: $('form#footerform').serialize(), 644 dataType: "text", 645 success: function (response) { 646 response = $.trim(response); 647 if(response === "success") { 648 $('form#footerform').hide(); 649 $('#footerformMSG').html(`<div class="alert alert-success mb-3">Thanks! Your email has been sent!</div>`); 650 } else { 651 btnLoaderReset($('form#footerform .btn-loader')); 652 $("form#footerform div.g-recaptcha-error").html(`<div class="alert alert-danger mb-3">You must complete the reCAPTCHA</div>`); 653 } 654 } 655 }); 656 return false; 657 } 658 }); 659 } 660 661 // Fix for SEO Lighthouse Audit & ADA 662 setTimeout(function () { 663 // Datepicker 664 $('.ui-datepicker-prev').attr('title', 'Prev Calendar').attr('href', '#'); 665 $('.ui-datepicker-next').attr('title', 'Next Calendar').attr('href', '#'); 666 $(document).on('click','.ui-datepicker-prev, .ui-datepicker-next', function(e) { 667 e.stopPropagation(); 668 return false; 669 }); 670 // Selectpicker 671 $('.dropdown-toggle').attr('role', ''); 672 }, 500); 673 674});
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.