1/* 2 * BASE 3 * first site js file to load 4 */ 5 6function RareBrick() { 7} 8 9if (!rb) { 10 var rb = new RareBrick(); 11} 12rb.inittime = new Date().getTime(); 13 14/* 15 * GLOBAL VARS 16 */ 17rb.bkpts_h = [0, 480, 768, 992, 1200, 9999999]; 18rb.bkpt_names = ['xs', 'sm', 'md', 'lg']; 19rb.bkpt_xs = rb.bkpts_h[0]; 20rb.bkpt_sm = rb.bkpts_h[1]; 21rb.bkpt_md = rb.bkpts_h[2]; 22rb.bkpt_lg = rb.bkpts_h[3]; 23 24 25(function ($) { 26 27 rb.toggleMobileNav = function () { 28 var isOn = $('#nav_primary').hasClass('on'); 29 30 $('#nav_primary').toggleClass('on'); 31 $('#nav_mobile_holder').toggleClass('on'); 32 33 if (isOn) { 34 $('#nav_primary li').removeClass('on'); 35 } 36 }; 37 38 /* 39 * INIT -- MAIN INIT FUNC CALLED ON DOC.READY 40 */ 41 RareBrick.prototype.init = function () { 42 /* 43 * init admin stuff if available 44 */ 45 if (rb.adminInit) rb.adminInit(); 46 47 /* 48 * create new Site and init its size and scroll 49 */ 50 51 rb.s = new rb.Site(); 52 rb.s.onWindowResize(); 53 rb.s.onWindowScroll(); 54 55 $('[pinAspect]').rb_pinAspect(); 56 rb.initSlideshows(); 57 58 $('h3.faq').rb_faqs(); 59 $('p:not(.btns) >a.btn').rb_btns(); 60 61 $('.makecrmb').rb_breadcrumbs(); 62 63 $('.current-menu-item > a').click(function ($event) { 64 $event.preventDefault(); 65 return false; 66 }); 67 68 //DATEPICKERS 69 //$('.date-picker').datepicker(); 70 71 //BOOK MENU 72 73 var bookTid; 74 75 //BOOK OVER 76 $('#nav_primary li.book').mouseover(function () { 77 clearTimeout(bookTid); 78 $(this).removeClass('off'); 79 $(this).addClass('on'); 80 }); 81 82 //BOOK OUT 83 $('#nav_primary li.book').mouseout(function () { 84 clearTimeout(bookTid); 85 86 bookTid = setTimeout(function () { 87 $('#nav_primary li.book').removeClass('on'); 88 }, 5000); 89 //$(this).addClass('off'); 90 }); 91 92 //OTHER NAVS OVER 93 $('#nav_primary li:not(.book)').mouseover(function () { 94 clearTimeout(bookTid); 95 96 var t = $('#nav_primary li.book').hasClass('on') ? 1 : 0; 97 $('#nav_primary li.book').removeClass('on'); 98 bookTid = setTimeout(function () { 99 $('#nav_primary li.book').addClass('off'); 100 }, t); 101 }); 102 103 //OTHER NAVS OUT 104 $('#nav_primary li:not(.book)').mouseout(function () { 105 clearTimeout(bookTid); 106 bookTid = setTimeout(function () { 107 $('#nav_primary li.book').removeClass('off'); 108 }, 1000); 109 }); 110 111 112 //move rez-widget to nav 113 $('#nav_primary li.book').each(function () { 114 var rez_widget = $('#rez_widget'); 115 $(this).append(rez_widget); 116 }); 117 118 119 //MOBILE & TABLET NAV CLICK HANDLERS 120 $('#nav_primary >div >ul >li >a').click(function ($event) { 121 if (isMobile) { 122 var parent = $(this).parent(); 123 if (parent.hasClass('book')) { 124 rb.checkRates(); 125 rb.toggleMobileNav(); 126 return true; 127 } 128 129 var hasChildren = parent.find('li').length; 130 if (hasChildren) { 131 parent.toggleClass('on'); 132 $event.preventDefault(); 133 return false; 134 } else { 135 rb.toggleMobileNav(); 136 return true; 137 } 138 } 139 }); 140 141 $('#nav_primary >div >ul >li li >a').click(function ($event) { 142 if (isMobile) { 143 rb.toggleMobileNav(); 144 return true; 145 } 146 }); 147 148 //book and signup magic links 149 //zzzzz 150 $('a[href="#book"]') 151 .click(function ($event) { 152 console.log('book clicked'); 153 $event.stopImmediatePropagation(); 154 $event.preventDefault(); 155 rb.checkRates(); 156 }); 157 158 $('a[href="#signup"]') 159 .click(function ($event) { 160 console.log('signup clicked'); 161 $event.stopImmediatePropagation(); 162 $event.preventDefault(); 163 rb.signUpUpdates(); 164 165 var header = document.querySelector('header'); 166 var headerRect = header.getBoundingClientRect(); 167 //console.info(headerRect, '--headerRect'); 168 169 var elem = document.querySelector('.sign-up-btns'); 170 var rect = elem.getBoundingClientRect(); 171 //console.info(rect, '--rect'); 172 var top = rect.top - headerRect.bottom; 173 //console.log('top: ' + top); 174 window.scrollTo({ 175 left: 0, 176 top: top, 177 behavior: 'smooth' 178 }) 179 }); 180 181 182 /* 183 * RE-FIRE SIZE AND SCROLL 184 */ 185 rb.s.onWindowResize(); 186 rb.s.onWindowScroll(); 187 rb.s.triggerResize(); 188 189 $('div.promo-in').each(function () { 190 var div = $(this);
191 var div2 = $('<div>').addClass('promo-out'); 192 193 div.wrap(div2); 194 }); 195 196 $('img.alignleft, img.alignright').each(function () { 197 var img = $(this); 198 var div = $('<span>').addClass('promo no-width'); 199 if (img.hasClass('alignleft')) { 200 div.addClass('left'); 201 } 202 if (img.hasClass('alignright')) { 203 div.addClass('right'); 204 } 205 img.wrap(div); 206 }); 207 }; //end rb.init 208 209 /* 210 * SITE -- SINGLETON 211 */ 212 rb.Site = function () { 213 var _this = this; 214 this.vw; //view width -- not necessarily same as window width 215 this.vh; //view height -- not necessarily same as window height 216 this.va; //view aspect ratio 217 this.scrolltop; //scroll position 218 this.docheight; //total doc height 219 this.bkpt; //current breakpoint size (int) 220 221 222 /* 223 * CUSTOM LISTENERS 224 */ 225 226 227 /* 228 * GLOBAL SCROLL LISTENER 229 */ 230 var scrollPoll = 100; 231 232 this.onWindowScroll = function () { 233 //return if within interval 234 if (this.didScroll) { 235 this.waitingOnScroll = true; 236 return; 237 } 238 239 //update all geom values 240 var w = jQuery(window); 241 var d = jQuery(document); 242 this.scrolltop = w.scrollTop(); 243 this.docheight = d.height(); 244 this.wheight = w.height(); 245 this.scrollbottom = this.docheight - this.scrolltop - this.vh; 246 247 $('.scroll-listener').trigger('rb-scroll'); 248 249 this.waitingOnScroll = false; 250 this.didScroll = true; 251 }; 252 253 this.resetDidScroll = function () { 254 //console.log('reset scroll'); 255 this.didScroll = false; 256 //make sure that the final scroll event gets called and not skipped 257 if (this.waitingOnScroll) { 258 this.waitingOnScroll = false; 259 this.onWindowScroll(); 260 } 261 }; 262 263 this.scrollTID = setInterval(function () { 264 this.waitingOnScroll = true; 265 _this.resetDidScroll(); 266 }, scrollPoll); 267 268 jQuery(window).scroll(function () { 269 _this.onWindowScroll(); 270 }); 271 272 273 /* 274 * GLOBAL RESIZE LISTENER 275 */ 276 var resizePoll = 100; 277 this.onWindowResize = function () { 278 var w = jQuery(window); 279 var d = jQuery(document); 280 this.docheight = d.height(); 281 this.vw = w.width(); 282 283 this.vh = w.height(); 284 this.va = this.vw / this.vh; 285 _this.updateBreakpoint(); 286 287 clearTimeout(this.resizeTID); 288 this.resizeTID = setTimeout(_this.triggerResize, resizePoll); 289 }; 290 291 this.triggerResize = function () { 292 clearTimeout(this.resizeTID); 293 294 $('.resize-listener').trigger('rb-resize'); 295 }; 296 297 jQuery(window).resize(function () { 298 _this.onWindowResize(); 299 }); 300 301 /* 302 * BREAKPOINTS 303 */ 304 this.updateBreakpoint = function () { 305 var bkpt = 0; 306 for (var i = 0; i < rb.bkpts_h.length; i++) { 307 if (this.vw < rb.bkpts_h[i]) break; 308 bkpt = i; 309 } 310 311 var changed = (bkpt == this.bkpt) ? false : true; 312 var bkptPrev = this.bkpt; 313 this.bkpt = bkpt; 314 if (changed) this.bkptChanged(bkptPrev); 315 } 316 this.bkptChanged = function (bkptPrev) { 317 var site = $('#site'); 318 if (bkptPrev != undefined) site.removeClass('bkpt' + bkptPrev); 319 site.addClass('bkpt' + this.bkpt); 320 321 $('.bkpt-listener').trigger('breakpoint'); 322 } 323
324 this.getBreakpointName = function () { 325 return rb.bkpt_names[this.bkpt]; 326 } 327 }; 328 329 $(document).ready(function () { 330 rb.init(); 331 }); 332 333 334 rb.signUpUpdates = function () { 335 $('#sign_up_form').show(); 336 $('#sign_up_btns').hide(); 337 return false; 338 }; 339 340 rb.signUpCancel = function () { 341 $('#sign_up_form').hide(); 342 $('#sign_up_btns').show(); 343 return false; 344 }; 345 346 rb.checkRates = function () { 347 $('#book_widget_popup').addClass('on'); 348 return false; 349 }; 350 351 rb.cancelCheckRates = function () { 352 $('#book_widget_popup').removeClass('on'); 353 return false; 354 }; 355 356 function padDateVal(val) { 357 return (val.length > 1) ? val : '0' + val; 358 } 359 360 rb.clickSignup = function () { 361 var data = $('#sign_up_form').serializeJSON(); 362 //console.info(data, '--d'); 363 364 if (!data || !data.name || !data.email || !data.address || !data.city || !data.state || !data.zip) { 365 $('#mc_error').empty() 366 .append('*Please fill out all required fields.') 367 .show(); 368 return false; 369 } else { 370 $('#mc_error').hide(); 371 } 372 373 var names = data.name.split(' '); 374 if (names.length > 1) { 375 data.name_last = names[names.length - 1]; 376 names.length = names.length - 1; 377 } 378 data.name = names.join(' '); 379 380 if (data.dob && data.mob) { 381 data.bday = padDateVal(data.mob) + '/' + padDateVal(data.dob); 382 } 383 384 console.info(data, 'mcData'); 385 var url = '/wp-admin/admin-ajax.php?action=submit_mc_contact'; 386 $.ajax({ 387 url: url, 388 data: data, 389 dataType: 'json' 390 }).done(function (response) { 391 console.info(response, '-response'); 392 393 if (!response || !response.data || !response.data.email_address) { 394 $('#mc_error').empty() 395 .append('Sorry, something went wrong! Please check to ensure all information is correct and try again.') 396 .show(); 397 } else { 398 $('#mc_error').hide(); 399 $('#mc_success').empty() 400 .append('Congrats! You are now on our list to receive updates and offers!') 401 .show(); 402 $('.mc-form').hide(); 403 } 404 }); 405 return false; 406 }; 407 408 409 rb.gotoHash = function (link) { 410 var href = link.getAttribute('href'); 411 var targetElem = document.querySelector(href); 412 var targetTop = targetElem.getBoundingClientRect().top; 413 var headerBottom = document.querySelector('header').getBoundingClientRect().bottom; 414 var scrollTo = targetTop - headerBottom - 20 + window.scrollY; 415 416 /* 417 console.info(link, '--gotoHash'); 418 console.info(targetElem, '--targetElem'); 419 420 console.log('targetTop: ' + targetTop); 421 console.log('headerBottom: ' + headerBottom); 422 console.log('scrollTo: ' + scrollTo); 423 */ 424 425 window.scrollTo({ 426 top: scrollTo, 427 left: 0, 428 behavior: 'smooth' 429 }); 430 431 return false; 432 }; 433 434 rb.submitBookWidget = function (form) { 435 console.info(form.elements.adults, '--adults'); 436 console.info(form.elements.adults.options, '--adults'); 437 var search = { 438 propertyId: 4691, 439 checkIn: rb.convertDate(form.elements.checkIn.value), 440 checkOut: rb.convertDate(form.elements.checkOut.value), 441 guests: [{ 442 adults: 1 * form.elements.adults.options[form.elements.adults.selectedIndex].value, 443 children: 1 * form.elements.children.options[form.elements.children.selectedIndex].value 444 }], 445 promoCode: form.elements.promoCode.value, 446 }; 447 console.info(search, '--search'); 448 449 if (!search.checkIn) 450 return rb.submitBookError('Please enter a check in date'); 451 452 if (!search.checkOut) 453 return rb.submitBookError('Please enter a check in date'); 454 455 if (!search.guests[0].adults) 456 return rb.submitBookError('Please enter number of adults'); 457 458 var clientId; //unused 459 var linkerParam; 460 461 console.log(url); 462 463/* 464 CWD - Eliminate Universal Anlaytics tracking parameters that cause script to fail 465 466 ga(function (tracker, trackers) { 467 console.info(tracker, '--tracker'); 468 console.info(trackers, '--trackers'); 469 clientId = tracker.get('clientId'); 470 linkerParam = tracker.get('linkerParam'); 471 console.log('linker param: ' + linkerParam); 472 console.log('ga id: ' + clientId); 473 }); 474*/ 475 476 var url = 'https://endlesscoast.client.innroad.com/'; 477 478 url += '?' + linkerParam; 479 url += '&v=2'; 480 481 url += '#search=' + encodeURI(JSON.stringify(search)); 482 //url += '#search=' + JSON.stringify(search); 483 484 485 console.log(url); 486 url = url.replace(/%7b/gi, '{'); 487 url = url.replace(/%7d/gi, '}'); 488 url = url.replace(/%5b/gi, '['); 489 url = url.replace(/%5d/gi, ']'); 490 491 console.log('urlFin: ' + url); 492 493 494/* 495 CWD - don't use this to "submit" the form as it bypasses GA4 automatic cross-domain tracking 496 497 window.location.href = url; 498*/ 499 500 // CWD - Set the form action URL and submit it 501 502 var rezWidgetDiv = document.getElementById('rez_widget'); 503 const rezForm = rezWidgetDiv.querySelector('form'); 504 505 rezForm.action = url; 506 507 // Iterate over all form elements and clear their values to make the resulting URL less manic
508 Array.from(rezForm.elements).forEach(element => { 509 if (element.type !== "submit") { 510 element.value = ""; 511 } 512 }); 513 514 // Submit the form 515 rezForm.submit(); 516 517 return false; 518 }; 519 520 rb.testGA = function () { 521 ga(function (tracker) { 522 var clientId = tracker.get('clientId'); 523 alert(clientId); 524 }); 525 return false; 526 }; 527 528 rb.submitBookError = function (msg) { 529 alert(msg); 530 return false; 531 }; 532 533 rb.convertDate = function (d) { 534 console.log('convertDate:', d); 535 try { 536 d = d.split('/'); 537 return d[2] + '-' + d[0] + '-' + d[1]; 538 } catch (e) { 539 return ''; 540 } 541 }; 542 543 rb.getDatepickerDate = function (element, dateFormat) { 544 console.log('rb.getDatepickerDate'); 545 var date; 546 try { 547 date = $.datepicker.parseDate(dateFormat, element.value); 548 console.log('date:: ', date); 549 } catch (error) { 550 date = null; 551 } 552 553 return date; 554 }; 555 556 rb.popupInited = false; 557 558 rb.activatePopup = function () { 559 $('#pop').addClass('on'); 560 561 if (!rb.popupInited) { 562 $('#pop').click(function ($event) { 563 rb.closePop(); 564 }); 565 $('#pop .pop-window').click(function ($event) { 566 //$event.preventDefault(); 567 $event.stopImmediatePropagation(); 568 }); 569 rb.popupInited = true; 570 } 571 }; 572 573 rb.closePop = function () { 574 $('#pop').removeClass('on'); 575 }; 576 577 }(jQuery) 578); 579
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.