PageSourceSearch

https://www.seasidevacationhomes.com/javascripts/js/z_global.js?v=137

js seasidevacationhomes.com collected 2026-10-08 19:14:15 UTC 21,720 bytes, 649 lines download raw bytes

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

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.