1$(document).ready(function () { 2 $('.page-article').waypoint({ 3 handler: function () { 4 $(this.element).addClass('animate'); 5 this.destroy(); 6 }, 7 offset: '90%' 8 }); 9 10 $('.about-us').waypoint({ 11 handler: function () { 12 $(this.element).addClass('animate'); 13 this.destroy(); 14 }, 15 offset: '90%' 16 }); 17}); 18 19document.addEventListener("DOMContentLoaded", function () { 20 initializeTermsAndConditions() 21}); 22 23function initializeTermsAndConditions() { 24 const containers = document.querySelectorAll('.terms-and-conditions'); 25 26 if(!containers) return; 27 28 containers.forEach(function (container) { 29 const arrow = container.querySelector('.terms-and-conditions-arrow'); 30 const content = container.querySelector('.terms-and-conditions-content'); 31 32 container.addEventListener('click', function () { 33 // console.log('Terms and Conditions clicked'); 34 arrow?.classList.toggle('upward'); 35 content?.classList.toggle('show'); 36 }); 37 }); 38} 39$(document).ready(function () { 40 $('.article').waypoint({ 41 handler: function () { 42 $(this.element).addClass('animate'); 43 this.destroy(); 44 }, 45 offset: '90%' 46 }); 47 48 // Function to check if element is in viewport 49 function isInViewport(element) { 50 var rect = element[0].getBoundingClientRect(); 51 // console.log("rect: ", element); 52 // console.log("top: ", rect.top, " bottom: ", rect.bottom, " wh: ", $(window).height()); 53 // console.log("isInViewPoint: ", rect.top >= 0, rect.bottom <= $(window).height()); 54 return ( 55 rect.top >= 0 56 ); 57 } 58 59 // On collapse, check all articles 60 $('.article').on('hidden.bs.collapse', function () { 61 $('.article').each(function () { 62 if (isInViewport($(this)) && !$(this).hasClass('animate')) { 63 $(this).addClass('animate'); 64 } 65 }); 66 }); 67}); 68 69$(document).ready(function () { 70 var backTop = $('.backTop'); 71 72 window.scrollTo = function (element, to, duration) { 73 if (duration <= 0) return; 74 var difference = to - element.scrollTop; 75 var perTick = difference / duration * 10; 76 77 setTimeout(function () { 78 element.scrollTop = element.scrollTop + perTick; 79 if (element.scrollTop === to) return; 80 scrollTo(element, to, duration - 10); 81 }, 10); 82 } 83 84 var backTopScrollHandle = function () { 85 var _scrollTop = window.pageYOffset || document.documentElement.scrollTop; 86 if (_scrollTop > 0) { 87 backTop.addClass('backTop--show'); 88 if ($('footer.footer').offset().top <= _scrollTop + $(window).height() - backTop.height()) { 89 backTop.addClass('backTop--freez'); 90 } else { 91 backTop.removeClass('backTop--freez'); 92 } 93 } else { 94 backTop.removeClass('backTop--show'); 95 } 96 }; 97 98 backTop.on('click touchstart', function () { 99 window.scrollTo($('body')[0], 0, 400); // For iOS or Edge 100 window.scrollTo(document.documentElement, 0, 400); // For Chrome, Safari, IE and Opera 101 }); 102 103 backTopScrollHandle(); 104 105 $(document).on('scroll', function () { 106 backTopScrollHandle(); 107 }); 108}); 109 110$(document).ready(function () { 111 $('.badge__del').on('click', function () { 112 $(this).parents('.badge').trigger('badgeRemove'); 113 $(this).parents('.badge').remove(); 114 }); 115}); 116 117$(document).ready(function () { 118 $('.cardGroup__more').on('click', function () { 119 var $more = $(this); 120 var $group = $more.parents('.cardGroup'); 121 var $item = $group.find('.cardGroup__group:not(.cardGroup__group--show)'); 122 var $loading = $group.find('.cardGroup__loading'); 123 var $tools = $group.find('.cardGroup__tools'); 124 $more.hide(); 125 $loading.fadeIn(); 126 if ($item.length > 0) { 127 setTimeout(function () { 128 $item.eq(0).slideDown(1000, function () { 129 $(this).addClass('cardGroup__group--show'); 130 if ($item.length > 1) { 131 $more.show(); 132 $loading.fadeOut(); 133 } else { 134 $tools.addClass('d-none'); 135 } 136 }); 137 }, 600); 138 } else { 139 $tools.addClass('d-none'); 140 } 141 }); 142}); 143$(document).ready(function () {
144 $('#cinemaDetailsDropdown').on('change', function () { 145 $('#' + $(this).val()).collapse('show'); 146 }); 147 148 if($('.cinema__wrapper').length > 0) { 149 var $cinemaTitle = $('.pageTopic__title__text'); 150 var $cinemaOpening = $('.shopDetails__info__time__item__day'); 151 152 if($cinemaTitle.text().indexOf('æ²é¢') > 1) { 153 $cinemaTitle.html(function(_, html) { 154 return html.replace(/(æ²é¢)/g, '<span class="text-group">$1</span>') 155 }); 156 } 157 158 if($cinemaOpening.text().indexOf('å ¬ç¾åæ') > 1) { 159 $cinemaOpening.html(function(_, html) { 160 return html.replace(/(å ¬ç¾åæ)/g, '<span class="text-group">$1</span>') 161 }); 162 } 163 } 164}); 165$(document).ready(function () { 166 function getUserAgent () { 167 for (let key in devices) 168 if (navigator.userAgent.match(devices[key].userAgent)) return key; 169 170 return 'other'; 171 } 172 function getStore(ele) { 173 var store = devices[os]; 174 var link = $(ele).attr('href'); 175 176 if (ele.id) { 177 switch (os) { 178 case 'ios': 179 store = devices.ios.store + ele.appId; 180 break; 181 case 'android': 182 default: 183 store = devices[this._os].store + ele.appId; 184 break; 185 } 186 } else store = link ? link : 'javascript:;'; 187 188 return store; 189 } 190 var devices = { 191 android: { // android system 192 store: 'market://details?id=', 193 userAgent: /Android/i 194 }, 195 ios: { // ios 196 store: 'itms-apps://itunes.apple.com/hk/app/', 197 userAgent: /iPhone|iPad|iPod/i 198 } 199 } 200 var os = getUserAgent(); 201 var delay = os == 'ios' ? 300 : 500; 202 203 if ($('.deeplink').length > 0) { 204 $('.deeplink').each(function () { 205 if (os != 'other') { 206 this.appId = $(this).attr('data-bs-' + os + '-id'); 207 this.deeplink = $(this).attr('data-bs-deep-link'); 208 this.store = getStore(this); 209 console.log(this.appId, this.deeplink, this.store) 210 if ((this.appId && this.appId != '') || (this.deeplink && this.deeplink != '')) { 211 $(this).on('click', function (event) { 212 var self = this; 213 event.preventDefault(); 214 setTimeout(function () { 215 var _start = new Date().getTime(); 216 if (self.deeplink) { 217 var _timeout = setTimeout(function () { 218 // Get current time 219 var _now = new Date().getTime(); 220 221 // clear timeout 222 clearTimeout(_timeout); 223 224 if (_now - _start >= delay) return; 225 226 // Open store or original link 227 window.open(self.store, '_blank'); 228 //window.location = self.store; 229 }, delay); 230 231 // try open deep link 232 window.location = self.deeplink; 233 } else window.open(self.store, '_blank'); // window.location = self.store; 234 }, delay); 235 }); 236 } 237 } 238 }); 239 } 240}); 241 242$(document).ready(function () { 243 function shareSetMinWidth(dropdownEle) { 244 var $menu; 245 var minWidth; 246 dropdownEle.each(function () { 247 $menu = $(this).find('.dropdown-menu'); 248 minWidth = parseInt($menu.attr('data-bs-min-width')); 249 console.log($(this).offset().left, minWidth, $(document).width()); 250 if (!isNaN(minWidth)) { 251 if ($(this).offset().left + minWidth >= $(document).width()) { 252 if (minWidth < $(document).width()) { 253 $(this).find('.dropdown-menu').addClass('dropdown-menu-right'); 254 } else { 255 $menu.css({ 256 minWidth: ($(document).width() - $(this).offset().left - 20) + 'px' 257 }); 258 } 259 } else { 260 $(this).find('.dropdown-menu-right').removeClass('dropdown-menu-right'); 261 $menu.css({ 262 minWidth: '' 263 }); 264 } 265 } 266 267 }); 268 } 269 $('.dropdown--share').on('show.bs.dropdown', function () { 270 shareSetMinWidth($(this)); 271 }); 272 273 $('.formSelect__select').each(function () { 274 var $dropdown = $('#' + $(this).attr('data-bs-dropdown')); 275 if ($(this).val() && $(this).val() != '') { 276 $(this).removeClass('formSelect__select--placeholder'); 277 if ($dropdown.length > 0) { 278 $dropdown.find('.dropdown-toggle').removeClass('dropdown-toggle--placeholder'); 279 } 280 } else { 281 $(this).addClass('formSelect__select--placeholder'); 282 if ($dropdown.length > 0) { 283 $dropdown.find('.dropdown-toggle').addClass('dropdown-toggle--placeholder'); 284 } 285 } 286 }); 287 $('.formSelect__select').on('change', function () { 288 var $dropdown = $('#' + $(this).attr('data-bs-dropdown')); 289 if ($(this).val() && $(this).val() != '') { 290 $(this).removeClass('formSelect__select--placeholder'); 291 if ($dropdown.length > 0) { 292 $dropdown.find('.dropdown-toggle').removeClass('dropdown-toggle--placeholder'); 293 } 294 } else { 295 $(this).addClass('formSelect__select--placeholder'); 296 if ($dropdown.length > 0) { 297 $dropdown.find('.dropdown-toggle').addClass('dropdown-toggle--placeholder'); 298 } 299 } 300 }); 301 302 $('.dropdown--formSelect').on('hidden.bs.dropdown', function () { 303 var $select = $('#' + $(this).attr('data-bs-select-id')); 304 var $active = $(this).find('.dropdown-item.active'); 305 var value = $active.length > 0 ? $active.val() : ''; 306 307 if ($select.length > 0) { 308 $select.val(value).trigger('focusout'); 309 } 310 }); 311 $('.dropdown--formSelect .dropdown-item').on('click', function () { 312 var $dropdown = $(this).parents('.dropdown--formSelect'); 313 var $select = $('#' + $dropdown.attr('data-bs-select-id')); 314 var value = $(this).val(); 315 if (!$(this).hasClass('active')) { 316 $dropdown.find('.dropdown-toggle__text').html($(this).html()); 317 $dropdown.find('.dropdown-item.active').removeClass('active'); 318 $(this).addClass('active'); 319 320 if ($select.length > 0) { 321 $select.val(value).trigger('change'); 322 } 323 } 324 }); 325 $('.dropdown--formSelect').find('.dropdown-toggle, .dropdown-item').on('focusout', function () { 326 var $dropdown = $(this).parents('.dropdown--formSelect'); 327 var $select = $('#' + $dropdown.attr('data-bs-select-id')); 328 if (!$dropdown.hasClass('show') && $select.length > 0) { 329 $select.trigger('focusout'); 330 } 331 }); 332 $('.formSelect__select--withDropdowp').on('change', function () { 333 var value = $(this).val(); 334 var $dropdown = $('#' + $(this).attr('data-bs-dropdown')); 335 var $active = $dropdown.find('.dropdown-item[value="' + value + '"]'); 336 337 if ($active.length > 0) { 338 if (!$active.hasClass('active')) { 339 $dropdown.find('.dropdown-item.active').removeClass('active'); 340 $active.addClass('active'); 341 $dropdown.find('.dropdown-toggle__text').html($active.html()) 342 } 343 } 344 }); 345}); 346$(document).ready(function () { 347 $('.eventPage__collapse').on('shown.bs.collapse', function (event) { 348 if (window.matchMedia('(max-width: 768px)').matches) { 349 window.scrollTo(document.documentElement, $('.eventPage__body__title__btn[data-bs-target="#' + $(this).attr('id') + '"]').offset().top, 400); 350 } 351 }); 352 353 $('.eventPage__tnc__collapse').on('shown.bs.collapse', function (event) { 354 if (!window.matchMedia('(max-width: 768px)').matches) { 355 window.scrollTo(document.documentElement, $('.eventPage__tnc__btn[data-bs-target="#' + $(this).attr('id') + '"]').offset().top, 400); 356 } 357 }); 358 $('.template5__collapse').on('shown.bs.collapse', function (event) { 359 if (window.matchMedia('(max-width: 768px)').matches) { 360 window.scrollTo(document.documentElement, $('.template5__body__title__btn[data-bs-target="#' + $(this).attr('id') + '"]').offset().top, 400); 361 } 362 }); 363 364 $('.template5__tnc__collapse').on('shown.bs.collapse', function (event) { 365 if (!window.matchMedia('(max-width: 768px)').matches) { 366 window.scrollTo(document.documentElement, $('.template5__tnc__btn[data-bs-target="#' + $(this).attr('id') + '"]').offset().top, 400); 367 } 368 }); 369}); 370document.addEventListener("DOMContentLoaded", function () { 371 const chips = document.querySelectorAll('.mdc-chip'); 372 373 if (chips.length === 0) { 374 console.warn('No .mdc-chip elements found!'); 375 return; 376 } 377 378 chips.forEach(chip => { 379 chip.addEventListener('click', function () { 380 const categoryId = chip.getAttribute("data-bs-value"); 381 chips.forEach(c => c.classList.remove('mdc-chip--selected')); 382 this.classList.add('mdc-chip--selected'); 383 filterProducts(categoryId); 384 }); 385 }); 386 function filterProducts(categoryId) { 387 const cards = document.querySelectorAll('.merchant-offers li'); 388 let visibleCount = 0; 389 cards.forEach(card => { 390 const cardCategoryId = card.getAttribute('data-bs-category'); 391 if (categoryId === 'all' || categoryId === cardCategoryId) { 392 card.style.display = 'block'; 393 visibleCount++; 394 } else { 395 card.style.display = 'none'; 396 } 397 }); 398 } 399}); 400$(document).ready(function () { 401 var selectedOption = $('.footer__malls').val(); 402 $('.footer__malls').on('change', function () { 403 if ($(this).val() && $(this).val() != selectedOption && $(this).val() != '') { 404 if ($('.ios').length > 0) { 405 location.href = $(this).val(); 406 } else { 407 window.open($(this).val(), '_blank'); 408 setTimeout(function () { 409 $(this).val(selectedOption); 410 }, 400); 411 } 412 } 413 }); 414}); 415$(document).ready(function () { 416 function submitError(formEle) { 417 var $form = $(formEle); 418 var $loading = $form.find('.form__loading'); 419 var captcha = $form.find('.form__captcha'); 420 421 if (captcha.length > 0) { 422 if (captcha[0].captcha != undefined && grecaptcha) { 423 grecaptcha.reset(captcha[0].captcha); 424 $form.find('.form__btn[type="submit"]').attr('disabled', ''); 425 } 426 } 427 setTimeout(function () { 428 $form.find('.form__content').addClass('d-none'); 429 $form.find('.form__submited--error').addClass('d-block'); 430 431 $loading.fadeOut(400); 432 }, 0); 433 } 434 function submitSucessful(formEle) { 435 var $form = $(formEle); 436 var $loading = $form.find('.form__loading'); 437 var captcha = $form.find('.form__captcha'); 438 439 if (captcha.length > 0) { 440 if (captcha[0].captcha != undefined && grecaptcha) { 441 grecaptcha.reset(captcha[0].captcha); 442 $form.find('.form__btn[type="submit"]').attr('disabled', ''); 443 } 444 } 445 setTimeout(function () { 446 $form.find('.form__content').addClass('d-none'); 447 $form.find('.form__submited--sucessful').addClass('d-block'); 448 449 $loading.fadeOut(400); 450 }, 0); 451 } 452 $('.form').find('input, textarea, select').on('change', function () { 453 var isValid = inputRequired(this, true); 454 if (isValid) { 455 isValid = inputPattern(this, true); 456 } 457 canSubmitForm($(this).parents('.form__content')); 458 }).on('focusout', function () { 459 var isValid = inputRequired(this, true); 460 if (isValid) { 461 isValid = inputPattern(this, true); 462 } 463 canSubmitForm($(this).parents('.form__content')); 464 }); 465 466 $('.form__content').on('submit', function (event) { 467 event.preventDefault(); 468 var canSubmit = true; 469 var api = $(this).attr('action'); 470 var $form = $(this).parents('.form'); 471 var captcha = $form.find('.form__captcha'); 472 var $loading = $form.find('.form__loading'); 473 $loading.fadeIn(200); 474 canSubmit = canSubmitForm($form); 475 if (canSubmit && api && api != '') { 476 $.ajax({ 477 url: api, 478 dataType: 'text', 479 type: 'post', 480 contentType: 'application/x-www-form-urlencoded', 481 data: $(this).serialize() 482 }).done(function (data) { 483 try { 484 var res = JSON.parse(data); 485 if (res.statusCode == "Accepted") { 486 submitSucessful($form); 487 } else { 488 submitError($form); 489 } 490 } 491 catch (err) { 492 submitError($form); 493 } 494 }).fail(function () { 495 submitError($form); 496 }); 497 } else { 498 if (captcha.length > 0) { 499 if (captcha[0].captcha != undefined && grecaptcha) { 500 grecaptcha.reset(captcha[0].captcha); 501 $form.find('.form__btn[type="submit"]').attr('disabled', ''); 502 } 503 } 504 505 $loading.fadeOut(400); 506 } 507 }); 508 509 $('.form__btn--back').on('click', function () { 510 var $form = $(this).parents('.form'); 511 $form.find('.form__submited').removeClass('d-block'); 512 $form.find('.form__content').removeClass('d-none'); 513 }); 514 515 $('select[name="replyBy"]').on('change', onChangeReplyFor) 516}); 517 518function onChangeReplyFor() { 519 var forCase = $(this).closest('form').attr('data-bs-for'); 520 var elementList = { 521 customer: ['#contactUs_customer_title', '#contactUs_customer_firstname', '#contactUs_customer_lastname', '#contactUs_customer_contact', '#contactUs_customer_email'], 522 leasing: ['#contactUs_leasing_title', '#contactUs_leasing_firstname', '#contactUs_leasing_lastname', '#contactUs_leasing_contact', '#contactUs_leasing_email'], 523 }; 524 var elements = elementList[forCase]; 525 for (let idx = 0; idx < elements.length; idx++) { 526 var eleField = $(elements[idx]); 527 var eleParent = eleField.parent(); 528 if (eleField && eleParent) { 529 if (inputRequired(elements[idx], true)) { 530 inputPattern(elements[idx], true) 531 } 532 } 533 } 534} 535 536function funcValidReplyForIgnoreChecking(formEle) { 537 var forCase = formEle.attr('data-bs-for'); 538 var elementList = { 539 customer: '#contactUs_customer_replyBy', 540 leasing: '#contactUs_leasing_replyBy', 541 }; 542 var eleValidBy = $(elementList[forCase]), 543 valValidBy = eleValidBy.val(), 544 ignorePatternCheckIfFieldIsEmpty = { 545 no: { 546 customer: ['#contactUs_customer_contact', '#contactUs_customer_email'], 547 leasing: ['#contactUs_leasing_contact', '#contactUs_leasing_email'], 548 }, 549 email: { 550 customer: ['#contactUs_customer_contact'], 551 leasing: ['#contactUs_leasing_contact'], 552 }, 553 phone: { 554 customer: ['#contactUs_customer_email'], 555 leasing: ['#contactUs_leasing_email'], 556 }, 557 }, 558 ignorePatternCheckList = []; 559 560 // XXX: Init Validation; 561 ignorePatternCheckList = ignorePatternCheckIfFieldIsEmpty[valValidBy][forCase]; 562 563 // XXX: Reeset fields attributes; 564 for (let idx = 0; idx < ignorePatternCheckIfFieldIsEmpty
564.no[forCase].length; idx++) { 565 var eleRequired = $(ignorePatternCheckIfFieldIsEmpty.no[forCase][idx]); 566 eleRequired.removeAttr('data-bs-ignore'); 567 } 568 569 // XXX: Set ignore pattern check list; 570 if (ignorePatternCheckList && ignorePatternCheckList.length) { 571 for (let idx = 0; idx < ignorePatternCheckList.length; idx++) { 572 var eleField = $(ignorePatternCheckList[idx]); 573 eleField.attr('data-bs-ignore', 'true'); 574 if (eleField && eleField.val() !== '') { 575 eleField.removeAttr('data-bs-ignore'); 576 } 577 } 578 } 579} 580 581function funcValidReplyForRequiredChecking(formEle) { 582 var forCase = formEle.attr('data-bs-for'); 583 var elementList = { 584 customer: '#contactUs_customer_replyBy', 585 leasing: '#contactUs_leasing_replyBy', 586 }; 587 var eleValidBy = $(elementList[forCase]), 588 valValidBy = eleValidBy.val(), 589 ruleValidBy = null, 590 validFor = { 591 customer: { 592 email: ['#contactUs_customer_title', '#contactUs_customer_firstname', '#contactUs_customer_lastname', '#contactUs_customer_email'], 593 phone: ['#contactUs_customer_title', '#contactUs_customer_firstname', '#contactUs_customer_lastname', '#contactUs_customer_contact'], 594 }, 595 leasing: { 596 email: ['#contactUs_leasing_title', '#contactUs_leasing_firstname', '#contactUs_leasing_lastname', '#contactUs_leasing_email'], 597 phone: ['#contactUs_leasing_title', '#contactUs_leasing_firstname', '#contactUs_leasing_lastname', '#contactUs_leasing_contact'], 598 } 599 }, 600 validForAll = validFor[forCase].email.concat(validFor[forCase].phone); 601 602 // XXX: Init Validation; 603 validForAll = validForAll.filter(function (item, pos) { 604 return validForAll.indexOf(item) === pos; 605 }); 606 ruleValidBy = validFor[forCase][valValidBy]; 607 608 // XXX: Reeset fields attributes; 609 for (let idx = 0; idx < validForAll.length; idx++) { 610 var eleRequired = $(validForAll[idx]), 611 eleParent = eleRequired.closest('div.form-group'), 612 eleLabel = eleParent.find('label'); 613 eleRequired.removeAttr('required'); 614 eleLabel.removeClass('mandatory'); 615 } 616 617 // XXX: Set required attributes fields in matched option; 618 if (ruleValidBy) { 619 for (let idx = 0; idx < ruleValidBy.length; idx++) { 620 var eleRequired = $(ruleValidBy[idx]), 621 eleParent = eleRequired.closest('div.form-group'), 622 eleLabel = eleParent.find('label'); 623 eleRequired.attr('required', 'true'); 624 eleLabel.addClass('mandatory'); 625 } 626 } 627 628 funcValidReplyForIgnoreChecking(formEle); 629} 630 631function inputRequired(inputEle, isCheck) { 632 var $input = $(inputEle); 633 var $form = $input.parents('.form__content'); 634 var $formGroup = $input.parents('.form-group'); 635 var error = $form.attr('data-bs-required-error'); 636 var isValid = true; 637 638 if (!$input.attr('id')) { 639 return isValid; 640 } 641 642 if (isCheck) { 643 $formGroup.removeClass('error error--withText'); 644 $formGroup.find('.form__error').remove(); 645 funcValidReplyForRequiredChecking($form); 646 } 647 648 if ($input.is("[required]")) { 649 switch ($input.attr('type')) { 650 case 'checkbox': 651 if (inputEle.checked && isCheck) { 652 $formGroup.removeClass('error'); 653 } else if (!inputEle.checked) { 654 if (isCheck) { 655 $formGroup.addClass('error'); 656 isValid = false; 657 } 658 } 659 break 660 default: 661 if ($input.val() && $input.val() != '' && isCheck) { 662 $formGroup.removeClass('error'); 663 } else if (!$input.val() || $input.val() == '') { 664 if (isCheck) { 665 if (error && error != '') { 666 $formGroup.addClass('error error--withText'); 667 $formGroup.append('<p class="form__error">' + error + '</p>'); 668 isValid = false;
669 } 670 } 671 } 672 break; 673 } 674 } 675 676 return isValid; 677} 678 679function inputPattern(inputEle, isCheck) { 680 var $input = $(inputEle); 681 var $formGroup = $input.parents('.form-group'); 682 var regex = new RegExp($input.attr('pattern'), 'g'); 683 var error = $input.attr('data-bs-pattern-error'); 684 var isValid = true; 685 var isIgnore = $input.attr('data-bs-ignore'); 686 687 if (!$input.attr('id')) { 688 return isValid; 689 } 690 691 if (isIgnore && isIgnore === 'true') { 692 return isValid; 693 } 694 695 if (isCheck) { 696 $formGroup.removeClass('error error--withText'); 697 $formGroup.find('.form__error').remove(); 698 } 699 700 if ($input.attr('pattern') && $input.attr('pattern') != '') { 701 if ($input.val().match(regex) && isCheck) { 702 $formGroup.removeClass('error'); 703 } else if (!$input.val().match(regex)) { 704 if (isCheck) { 705 if (error && error != '') { 706 $formGroup.addClass('error error--withText'); 707 $formGroup.append('<p class="form__error">' + error + '</p>'); 708 isValid = false; 709 } 710 } 711 } 712 } 713 return isValid; 714} 715 716function canSubmitForm(formEle) { 717 var isValid = true; 718 var $form = $(formEle); 719 var $submit = $form.find('.form__btn[type="submit"]'); 720 var captcha = $form.find('.form__captcha'); 721 722 if ($form.length > 0) { 723 $form.find('input, textarea, select').each(function () { 724 var _checkInput = true; 725 if (_checkInput) { 726 _checkInput = inputRequired(this, true); 727 728 if (_checkInput) { 729 _checkInput = inputPattern(this, true); 730 } 731 } 732 if(isValid && !_checkInput){ 733 isValid = _checkInput; 734 } 735 }); 736 737 if (captcha.length > 0) { 738 if (captcha[0].captcha != undefined && grecaptcha) { 739 if (grecaptcha.getResponse(captcha[0].captcha).length == 0) { 740 isValid = false; 741 var error = captcha.attr('data-bs-invalid'); 742 if (error && error != '') { 743 captcha.addClass('error--withText'); 744 captcha.append('<p class="form__error">' + error + '</p>'); 745 } 746 } 747 } else { 748 isValid = false; 749 var error = captcha.attr('data-bs-invalid'); 750 if (error && error != '') { 751 captcha.addClass('error--withText'); 752 captcha.append('<p class="form__error">' + error + '</p>'); 753 } 754 } 755 } 756 757 if (isValid) { 758 $submit.removeAttr('disabled'); 759 } else { 760 $submit.attr('disabled', ''); 761 } 762 } 763 764 return isValid; 765} 766 767function captchaInit() { 768 $('.form__captcha').each(function () { 769 var id = $(this).attr('id'); 770 if (id && id != '' && $(this).attr('data-bs-sitekey') && $(this).attr('data-bs-sitekey') != '') { 771 this.captcha = grecaptcha.render(id, { 772 'sitekey': $(this).attr('data-bs-sitekey'), 773 'callback': function () { 774 var $form = $('#' + id).parents('.form__content'); 775 canSubmitForm($form); 776 }, 777 'expired-callback': function () { 778 var $form = $('#' + id).parents('.form__content'); 779 canSubmitForm($form); 780 } 781 }); 782 } 783 }); 784} 785 786window.getAllUrlParams = function (url) { 787 var queryString = url ? url.split('?')[1] : window.location.search.slice(1); 788 var obj = {}; 789 790 if (queryString) { 791 queryString = queryString.split('#')[0]; 792 793 var arr = queryString.split('&'); 794 795 for (var i = 0; i < arr.length; i++) { 796 var a = arr[i].split('='); 797 798 var paramName = a[0]; 799 var paramValue = typeof (a[1]) === 'undefined' ? true : a[1]; 800 801 paramName = paramName.toLowerCase(); 802 if (typeof paramValue === 'string') paramValue = paramValue.toLowerCase(); 803 804 if (paramName.match(/\[(\d+)?\]$/)) { 805 var key = paramName.replace(/\[(\d+)?\]/, ''); 806 if (!obj[key]) obj[key] = []; 807 808 if (paramName.match(/\[\d+\]$/)) { 809 var index = /\[(\d+)\]/.exec(paramName)[1]; 810 obj[key][index] = paramValue; 811 } else { 812 obj[key].push(paramValue); 813 } 814 } else { 815 if (!obj[paramName]) { 816 obj[paramName] = paramValue; 817 } else if (obj[paramName] && typeof obj[paramName] === 'string') { 818 obj[paramName] = [obj[paramName]]; 819 obj[paramName].push(paramValue); 820 } else { 821 obj[paramName].push(paramValue); 822 } 823 } 824 } 825 } 826 827 return obj; 828}; 829 830window.setParams = function (params) {
831 var allParams = window.getAllUrlParams(location.search); 832 var key; 833 var search = '?'; 834 if (typeof params == 'object') { 835 for (key in params) { 836 allParams[key] = params[key]; 837 } 838 } 839 840 if (Object.keys(allParams).length > 0) { 841 for (key in allParams) { 842 if (search != '?') 843 search += '&'; 844 search += key + '=' + allParams[key]; 845 } 846 847 location.search = search; 848 } 849 850}; 851 852window.mobileAndTabletCheck = function () { 853 let check = false; 854 (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera); 855 return check; 856}; 857 858var previousScrollY = 0; 859$(document).ready(function () { 860 $('.withAnimate').waypoint({ 861 handler: function () { 862 $(this.element).addClass('animate'); 863 this.destroy(); 864 }, 865 offset: '90%' 866 }); 867 868 if ($('#disableTableScroll').val() == "true") { 869 $('table').each(function () { 870 if (!$(this).parent().is('.tableWrapper')) { 871 $(this).wrap('<div class="tableWrapper"></div>') 872 } 873 }); 874 } 875 else { 876 $('table').each(function () { 877 if (!$(this).parent().is('.tableWrapper')) { 878 $(this).wrap('<div class="tableWrapper"><div class="tableWrapper__scroll"></div></div>') 879 } 880 }); 881 } 882 883 var simpleBar = []; 884 $('.tableWrapper__scroll').each(function () { 885 this.simpleBar = new SimpleBar(this); 886 }); 887 888 $('.modal').on('shown.bs.modal', function () { 889 $(this).find('.tableWrapper__scroll').each(function () { 890 if (this.simpleBar) { 891 if (typeof this.simpleBar.recalculate === 'function') { 892 this.simpleBar.recalculate(); 893 } 894 } 895 }); 896 }); 897 898 $('.collapse').on('shown.bs.collapse', function () { 899 $(this).find('.tableWrapper__scroll').each(function () { 900 if (this.simpleBar) { 901 if (typeof this.simpleBar.recalculate === 'function') { 902 this.simpleBar.recalculate(); 903 } 904 } 905 }); 906 }); 907 908 if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) { 909 $('html').addClass('ios'); 910 $(document).on('show.bs.modal', function () { 911 previousScrollY = $(document.documentElement).scrollTop(); 912 $('html').addClass('modal-open').css({ 913 marginTop: -previousScrollY 914 }); 915 }).on('hidden.bs.modal', function () { 916 $('html').removeClass('modal-open').css({ 917 marginTop: '' 918 }); 919 window.scrollTo(document.documentElement, previousScrollY, 10); 920 }); 921 } 922 923 document.addEventListener('selectionchange', function (event) { 924 $(document.activeElement).trigger('keyup'); 925 }, false); 926}); 927 928 929$(document).ready(function () { 930 931 //Enable Gray Mode 932 //document.body.style.filter = "grayscale(100%)"; 933 934 var header = $('.header'); 935 var backTop = $('.backTop'); 936 var headerDropdown = $('.header__menu__item .dropdown'); 937 var headerDropdownToggle = $('.header__menu__item .dropdown-toggle'); 938 var headerMedia = window.matchMedia("(min-width: 1024px)");
939 var headerSticky = $('.header__sticky'); 940 var headerNavBtn = $('.header__navbar__btn'); 941 var headerScrollHandle = function () { 942 var _scrollTop = window.pageYOffset || document.documentElement.scrollTop; 943 944 if (!window.bodyLastScrollTop) { 945 window.bodyLastScrollTop = _scrollTop <= 0 ? 0 : _scrollTop; 946 } 947 948 if (_scrollTop <= window.bodyLastScrollTop) { 949 // upscroll 950 header.removeClass('header--static'); 951 header.removeClass('header--hide'); 952 header.addClass('header--show'); 953 954 if (headerMedia.matches) { 955 backTop.removeClass('backTop--header'); 956 } else { 957 backTop.addClass('backTop--header'); 958 } 959 } else { 960 // downscroll 961 backTop.removeClass('backTop--header'); 962 header.removeClass('header--show'); 963 if (_scrollTop > header.height()) { 964 header.addClass('header--hide'); 965 } else { 966 header.removeClass('header--hide'); 967 header.addClass('header--static'); 968 } 969 } 970 971 window.bodyLastScrollTop = _scrollTop <= 0 ? 0 : _scrollTop; 972 }; 973 var headerStickyOpen = function () { 974 var $active = $('.header__menu__item.active'); 975 var $dropdown = $active.find('.dropdown'); 976 $('body').addClass('header-open'); 977 headerSticky.show(0, function () { 978 headerSticky.addClass('header__sticky--show'); 979 }); 980 981 headerSticky.find('a, button').eq(0).focus(); 982 if ($dropdown.length > 0) { 983 $dropdown.dropdown('show'); 984 } 985 }; 986 var headerStickyClose = function () { 987 $('body').removeClass('header-open'); 988 headerSticky.removeClass('header__sticky--show'); 989 $('.header__menu__item .dropdown').dropdown('hide'); 990 $('.header__menu__item .dropdown.show').removeClass('show'); 991 $('.header__menu__item.show').removeClass('show'); 992 $('.header__menu__item .dropdown-toggle').attr('aria-expanded', 'true'); 993 setTimeout(function () { 994 headerSticky.css({display: ''}); 995 }, 400); 996 }; 997 998 $('.header .dropdown-item[href]').click(function () { 999 if ($(this).attr('target') && $(this).attr('target') != '' && $(this).attr('target') != '_self') { 1000 window.open($(this).val(), $(this).attr('target')); 1001 } else { 1002 location.href = $(this).attr('href'); 1003 } 1004 }); 1005 1006 headerScrollHandle(); 1007 1008 headerNavBtn.on('click', function () { 1009 if ($('.header-open').length > 0) { 1010 headerStickyClose(); 1011 } else { 1012 headerStickyOpen(); 1013 } 1014 }); 1015 1016 headerMedia.addListener(function (media) { 1017 if (media.matches) { 1018 headerStickyClose(); 1019 backTop.removeClass('backTop--header'); 1020 } 1021 }); 1022 1023 var isEllipsisActive = function (element) { 1024 return $(element).width() - element.scrollWidth < -0.74; 1025 }; 1026 1027 var checkShortcutSize = function () { 1028 var _isEllipsisActive = false; 1029 $('.header__navbar__shortcut__link__text').each(function () { 1030 if (isEllipsisActive(this)) { 1031 _isEllipsisActive = true; 1032 } 1033 }); 1034 1035 if (_isEllipsisActive) { 1036 $('.header__navbar__shortcut').addClass('header__navbar__shortcut--iconOnly'); 1037 } else { 1038 $('.header__navbar__shortcut').removeClass('header__navbar__shortcut--iconOnly'); 1039 } 1040 }; 1041 1042 checkShortcutSize(); 1043 1044 $(window).on('resize', function () { 1045 checkShortcutSize(); 1046 }); 1047 1048 $(document).on('scroll', function () { 1049 headerScrollHandle(); 1050 }); 1051 1052 if (headerDropdown.length > 0) { 1053 headerDropdown.on('mouseleave', function () { 1054 if (headerMedia.matches) { 1055 $(this).dropdown('hide'); 1056 } 1057 }); 1058 1059 headerDropdownToggle.on('mouseover', function () { 1060 if (headerMedia.matches) { 1061 $(this).parent('.dropdown').dropdown('show'); 1062 } 1063 }); 1064 } 1065}); 1066 1067$(document).ready(function () { 1068 $('.ice-ring').waypoint({ 1069 handler: function () { 1070 $(this.element).addClass('animate'); 1071 this.destroy(); 1072 }, 1073 offset: '90%' 1074 }); 1075}); 1076 1077$(document).ready(function () { 1078 var imageID; 1079 var resizeTimeout = null; 1080 1081 function setImageBounds(mapEle) { 1082 var southWest; 1083 var northEast; 1084 var bounds; 1085 var map; 1086 var $img = mapEle.next('.leafletImage__image'); 1087 var $zoomIn = mapEle.parents('.leafletImage').find('.leafletImage__control__btn--in'); 1088 var $zoomOut = mapEle.parents('.leafletImage').find('.leafletImage__control__btn--out'); 1089 mapEle.removeClass('leafletImage__wrapper--ready'); 1090 if (mapEle.length > 0 && $img.length > 0) { 1091 map = mapEle[0].leafletImage; 1092 southWest = map.unproject([-$img.width() / 2, $img.he
1092ight() / 2], 1); 1093 northEast = map.unproject([$img.width() / 2, -$img.height() / 2], 1); 1094 bounds = new L.LatLngBounds(southWest, northEast); 1095 if (!mapEle[0].leafletImageBg) { 1096 mapEle[0].leafletImageBg = L.imageOverlay($img.attr('src'), bounds); 1097 mapEle[0].leafletImageBg.addTo(map); 1098 } else { 1099 mapEle[0].leafletImageBg.setBounds(bounds); 1100 } 1101 1102 map.invalidateSize(); 1103 if ($img.width() == 0) { 1104 mapEle.parents('.slider__wrapper').slick("refresh"); 1105 mapEle.parents('.slider__wrapper').slick('setPosition'); 1106 setTimeout(function () { 1107 setImageBounds(mapEle); 1108 }, 200); 1109 } else { 1110 setTimeout(function () { 1111 //console.log(mapEle.width()) 1112 mapEle.parents('.slider__wrapper').slick("refresh"); 1113 mapEle.parents('.slider__wrapper').slick('setPosition'); 1114 map.setMaxBounds(bounds); 1115 map.fitBounds(bounds); 1116 map.invalidateSize(); 1117 if ($zoomIn.length > 0) { 1118 if (map.getZoom() >= map.getMaxZoom()) { 1119 $zoomIn[0].disabled = true; 1120 } else { 1121 $zoomIn[0].disabled = false; 1122 } 1123 } 1124 if ($zoomOut.length > 0) { 1125 if (map.getZoom() <= map.getMinZoom()) { 1126 $zoomOut[0].disabled = true; 1127 } else { 1128 $zoomOut[0].disabled = false; 1129 } 1130 } 1131 mapEle.addClass('leafletImage__wrapper--ready'); 1132 mapEle.parents('.modal--slider').removeClass('modal--slider'); 1133 }, 200); 1134 } 1135 } 1136 } 1137 1138 if ($('.leafletImage__wrapper').length > 0) { 1139 $('.leafletImage__wrapper').each(function (index) { 1140 if (!$(this).attr('id') || $(this).attr('id') == '') { 1141 $(this).attr('id', 'leafletImage' + index); 1142 } 1143 imageID = $(this).attr('id'); 1144 this.leafletImage = L.map(imageID, { 1145 minZoom: 1, 1146 maxZoom: 4, 1147 center: [0, 0], 1148 zoom: 1, 1149 attributionControl: false, 1150 maxBoundsViscosity: 4, 1151 zoomControl: false, 1152 crs: L.CRS.Simple 1153 }); 1154 this.leafletImage.on('zoomend', function (e) { 1155 var $zoomIn = $(this.getContainer()).parents('.leafletImage').find('.leafletImage__control__btn--in'); 1156 var $zoomOut = $(this.getContainer()).parents('.leafletImage').find('.leafletImage__control__btn--out'); 1157 var map = this; 1158 if ($zoomIn.length > 0) { 1159 if (map.getZoom() >= map.getMaxZoom()) { 1160 $zoomIn[0].disabled = true; 1161 } else { 1162 $zoomIn[0].disabled = false; 1163 } 1164 } 1165 if ($zoomOut.length > 0) { 1166 if (map.getZoom() <= map.getMinZoom()) { 1167 $zoomOut[0].disabled = true; 1168 } else { 1169 $zoomOut[0].disabled = false; 1170 } 1171 } 1172 }); 1173 if ($(this).parents('.modal').length > 0) { 1174 $(this).parents('.modal').on('shown.bs.modal', function () { 1175 var $leafletImage = $(this).find('.leafletImage__wrapper'); 1176 $(this).removeClass('modal--slider'); 1177 $leafletImage.each(function () { 1178 setImageBounds($(this)); 1179 }); 1180 }); 1181 } 1182 }); 1183 1184 $('.leafletImage__control__btn--in').on('click', function () { 1185 var $leafletImage = $(this).parents('.leafletImage').find('.leafletImage__wrapper'); 1186 var zoom; 1187 if ($leafletImage.length > 0) { 1188 zoom = $leafletImage[0].leafletImage.getZoom(); 1189 if (zoom + 1 <= $leafletImage[0].leafletImage.getMaxZoom()) { 1190 $leafletImage[0].leafletImage.setZoom(zoom + 1); 1191 } 1192 } 1193 }); 1194 1195 $('.leafletImage__control__btn--out').on('click', function () { 1196 var $leafletImage = $(this).parents('.leafletImage').find('.leafletImage__wrapper'); 1197 var zoom; 1198 if ($leafletImage.length > 0) { 1199 zoom = $leafletImage[0].leafletImage.getZoom(); 1200 if (zoom - 1 >= $leafletImage[0].leafletImage.getMinZoom()) { 1201 $leafletImage[0].leafletImage.setZoom(zoom - 1); 1202 } 1203 } 1204 }); 1205 1206 $('.modal--leafletImage').on('shown.bs.modal', function () { 1207 var $slider = $(this).find('.slider--leafletImage .slick'); 1208 if ($slider.length > 0) { 1209 $slider.slick('slickPlay'); 1210 } 1211 }).on('hiden.bs.modal', function () { 1212 var $slider = $(this).find('.slider--leafletImage .slick'); 1213 if ($slider.length > 0) { 1214 $slider.slick('slickPause'); 1215 } 1216 }); 1217 1218 $('.slider--leafletImage .leafletImage__wrapper').on('click', function () { 1219 var $slider = $(this).parents('.slick'); 1220 if ($slider.length > 0) { 1221 $slider.slick('slickNext'); 1222 } 1223 }); 1224 1225 window.addEventListener('resize', function (e) { 1226 if (e.target == this) { 1227 if (resizeTimeout != null) { 1228 clearTimeout(resizeTimeout); 1229 } 1230 resizeTimeout = setTimeout(function () { 1231 $('.leafletImage__wrapper').parents('.modal').addClass('modal--slider'); 1232 setTimeout(function () { 1233 $('.leafletImage__wrapper').each(function () { 1234 setImageBounds($(this)); 1235 }); 1236 }, 200); 1237 }, 400); 1238 } 1239 }); 1240 } 1241}); 1242 1243$(document).ready(function () { 1244 var imageID; 1245 // var mapScale = .2; 1246 var defaultMapScale = .2; 1247 var modalMapScale = .15; 1248 var popupTimer; 1249 var popupCloseTimer;
1250 var isClicked = false; 1251 1252 function sanitize(value) { 1253 return DOMPurify.sanitize(value); 1254 } 1255 1256 1257 window.setFloorPlanBounds = function (mapEle, options) { 1258 var southWest; 1259 var northEast; 1260 var bounds; 1261 var map; 1262 var $zoomIn = mapEle.parents('.map').find('.map__control__btn--in'); 1263 var $zoomOut = mapEle.parents('.map').find('.map__control__btn--out'); 1264 1265 if (mapEle.length > 0) { 1266 var minZoom = mapEle[0].map.getMinZoom(); 1267 mapEle[0].map.setZoom(minZoom); 1268 } 1269 1270 var mapScale = defaultMapScale; 1271 if(mapEle.parent().hasClass('map--modal')) { 1272 mapScale = modalMapScale; 1273 } else { 1274 mapScale = defaultMapScale; 1275 } 1276 1277 mapEle.removeClass('map__wrapper--ready'); 1278 mapEle.parent().find('.map__loading').show(); 1279 if (mapEle.length > 0 && options) { 1280 map = mapEle[0].map; 1281 mapEle[0].mapOptions = options; 1282 // southWest = map.unproject([-options.width / 2, options.height / 2], map.getZoom()); 1283 // northEast = map.unproject([options.width / 2, -options.height / 2], map.getZoom()); 1284 southWest = map.unproject([-options.width / 2, options.height / 2], map.getMinZoom()); 1285 northEast = map.unproject([options.width / 2, -options.height / 2], map.getMinZoom()); 1286 // southWest = map.unproject([(-options.width / 2) - 100, (options.height / 2) + 100], map.getMinZoom()); 1287 // northEast = map.unproject([(options.width / 2) + 100, (-options.height / 2) - 100], map.getMinZoom()); 1288 1289 bounds = new L.LatLngBounds(southWest, northEast); 1290 if (options.src) { 1291 if (!mapEle[0].floorImage) { 1292 mapEle[0].floorImage = L.imageOverlay(options.src, bounds); 1293 mapEle[0].floorImage.addTo(map); 1294 } else { 1295 mapEle[0].floorImage.setUrl(options.src); 1296 mapEle[0].floorImage.setBounds(bounds); 1297 } 1298 1299 map.setMaxBounds(bounds); 1300 map.panTo(bounds.getCenter()); 1301 map.invalidateSize(); 1302 1303 setFloorPlanMarkers(mapEle, options.pins, options.height / 2 - 500); 1304 1305 // var activePins = options.pins.filter(function (item) { return item.isActive || item.isChecked }); 1306 // if (mapEle.parent().is('.map--details') && activePins.length == 1) { 1307 // map.panTo(map.unproject([activePins[0].lat * mapScale - options.width / 2, activePins[0].lng * mapScale - options.height / 2], 1)); 1308 // } else if (mapEle.parent().is('.map--details') && options.pins.length == 1) { 1309 // map.panTo(map.unproject([options.pins[0].lat * mapScale - options.width / 2, options.pins[0].lng * mapScale - options.height / 2], 1)); 1310 // } 1311 } 1312 if ($zoomIn.length > 0) { 1313 if (map.getZoom() >= map.getMaxZoom()) { 1314 $zoomIn[0].disabled = true; 1315 } else { 1316 $zoomIn[0].disabled = false; 1317 } 1318 } 1319 if ($zoomOut.length > 0) { 1320 if (map.getZoom() <= map.getMinZoom()) { 1321 $zoomOut[0].disabled = true; 1322 } else { 1323 $zoomOut[0].disabled = false; 1324 } 1325 } 1326 setTimeout(function () { 1327 mapEle.parent().find('.map__loading').fadeOut(400); 1328 mapEle.addClass('map__wrapper--ready'); 1329 }, 400); 1330 1331 } 1332 } 1333 1334 window.floorPlanPanTo = function (mapEle, pos) { 1335 var mapScale = defaultMapScale; 1336 if(mapEle.parent().hasClass('map--modal')) { 1337 mapScale = modalMapScale; 1338 } else { 1339 mapScale = defaultMapScale; 1340 } 1341 1342 var mapOption = this.window.getFloorPlanOptions(mapEle); 1343 if (mapEle.length > 0) { 1344 if (mapEle[0].map) { 1345 mapEle[0].map.panTo(mapEle[0].map.unproject([pos.lat * mapScale - mapOption.width / 2, pos.lng * mapScale - mapOption.height / 2], 1)); 1346 } 1347 } 1348 } 1349 1350 function clickPin(event) { 1351 floorPlanPanTo($(event.layer._map.getContainer()), event.layer.details); 1352 } 1353 1354 function popupOpen(event) { 1355 $(this._icon).addClass('focus'); 1356 } 1357 1358 function popupClose(event) { 1359 $(this._icon).removeClass('focus'); 1360 } 1361 1362 window.setFloorPlanMarkers = function (mapEle, pins, topLng) { 1363 var mapScale = defaultMapScale; 1364 if (mapEle.length > 0) { 1365 if(mapEle.eq(0).parent().hasClass('map--modal')) { 1366 mapScale = modalMapScale; 1367 } else { 1368 mapScale = defaultMapScale; 1369 } 1370 } else { 1371 if(mapEle.parent().hasClass('map--modal')) { 1372 mapScale = modalMapScale; 1373 } else { 1374 mapScale = defaultMapScale; 1375 } 1376 } 1377 // console.log('mapScale 0', mapEle); 1378 1379 var marker; 1380 var icon = { 1381 className: 'map__pin', 1382 html: mapEle.parents('.map').find('.map__pin').html(), 1383 // iconSize: [45, 53], 1384 // // iconAnchor: [23, 53] 1385 // iconAnchor: [23, 49] 1386 iconSize: [30, 38], 1387 iconAnchor: [15, 38] 1388 }; 1389 1390 // var href = window.location.href || ""; 1391 var href = window.location.pathname || ""; 1392 1393 if ($.trim(href) != "" && (href.endsWith("/dining") || href.endsWith("/shops"))) { 1394 // icon.iconSize = [21, 29]; 1395 // icon.iconAnchor = [11, 26]; 1396 icon.iconSize = [15, 20]; 1397 icon.iconAnchor = [7.5, 20]; 1398 } 1399 1400 var leafletIcon; 1401 var $popup_sample = mapEle.parents('.map').find('.map__popup'); 1402 var mapOptions = this.window.getFloorPlanOptions(mapEle); 1403 1404 if (!topLng) { 1405 topLng = 0; 1406 } 1407 1408 if (mapEle.length > 0) { 1409 if (mapEle[0].map) { 1410 size = mapEle[0].map.getSize(); 1411 if (!mapEle[0].floorMarkers) { 1412 mapEle[0].floorMarkers = L.featureGroup([]); 1413 mapEle[0].floorMarkers.addTo(mapEle[0].map).on('click', clickPin); 1414 } 1415 1416 mapEle[0].floorMarkers.clearLayers(); 1417 if (Array.isArray(pins)) { 1418 for (var i = 0; i < pins.length; i++) { 1419 // console.log('pins[i]', pins[i].shopID, pins[i].isActive, pins[i].isChecked, pins[i].isHidden); 1420 // console.log('pins[i]', pins[i]); 1421 icon.className = 'map__pin'; 1422 if (pins[i].isHidden) { 1423 icon.className += ' transparent'; 1424 } 1425 if (pins[i].isActive) { 1426 icon.className += ' active'; 1427 } 1428 if (pins[i].isChecked) { 1429 icon.className += ' focus'; 1430 } 1431 leafletIcon = L.divIcon(icon); 1432 // marker = L.marker(mapEle[0].map.unproject([pins[i].lat * mapScale - mapOptions.width / 2, pins[i].lng * mapScale - mapOptions.height / 2], 1), { icon: leafletIcon }); 1433 marker = L.marker(mapEle[0].map.unproject(L.point(pins[i].lat * mapScale - mapOptions.width / 2, pins[i].lng * mapScale - mapOptions.height / 2), 1), { icon: leafletIcon }); 1434 1435 if (pins[i].withPopup) { 1436 $popup = $popup_sample.clone(); 1437 if (pins[i].link) { 1438 $popup.find('.map__popup__arrow').attr('href', pins[i].link); 1439 $popup.find('.map__popup__title').attr('href', pins[i].link); 1440 } else { 1441 $popup.find('.map__popup__arrow').remove(); 1442 $popup.find('.map__popup__wrapper').addClass('p-0'); 1443 } 1444 if (pins[i].text) { 1445 $popup.find('.map__popup__title').html(sanitize(pins[i].text)); 1446 } else { 1447 $popup.find('.map__popup__title').remove(); 1448 } 1449 if (pins[i].location) { 1450 $popup.find('.map__popup__location').html(sanitize(pins[i].location.text)); 1451 } else { 1452 $popup.find('.map__popup__info--location').remove(); 1453 } 1454 if (pins[i].tel) { 1455 $popup.find('.map__popup__info--tel a').attr('href', 'tel:' + pins[i].tel.split(' ').join('').split('-').join('')); 1456 $popup.find('.map__popup__tel').html(sanitize(pins[i].tel)); 1457 } else { 1458 $popup.find('.map__popup__info--tel').remove(); 1459 }; 1460 marker.bindPopup($popup.html(), { 1461 autoPan: false, 1462 offset: [0, -53], 1463 className: pins[i].lng > topLng ? 'map__popup--bottom' : '' 1464 }).on('popupopen', function(e) { 1465 // this.popupOpen(e); 1466 if($('.shopDetails').length > 0 && $('#mapMobileModal').hasClass('show')) { 1467 var map = mapEle[0].map; 1468 var px = map.project(e.target._popup._latlng); // find the pixel location on the map where the popup anchor is 1469 px.y += e.target._popup._container.clientHeight/2; // find the height of the popup container, divide by 2, subtract from the Y axis of marker location 1470 1471 clearTimeout(popupTimer); 1472 clearTimeout(popupCloseTimer); 1473 popupTimer = setTimeout(function(){ 1474 map.panTo(map.unproject(px),{animate: true}); // pan to new center 1475 }, 1000); 1476 } 1477 $(e.popup._source._icon).addClass('focus'); 1478 }).on('popupclose', popupClose).on('mouseover', function () { 1479 this.openPopup(); 1480 }).on('mouseout', function () { 1481 clearTimeout(popupCloseTimer); 1482 popupCloseTimer = setTimeout(function(){ 1483 console.log('isClicked', isClicked); 1484 if(!isClicked) { 1485 // this.closePopup(); 1486 mapEle[0].map.closePopup(); 1487 clearTimeout(popupTimer); 1488 } 1489 }, 500); 1490 }).on('click', function () { 1491 isClicked = true; 1492 this.openPopup(); 1493 }); 1494 } 1495 marker.details = pins[i]; 1496 mapEle[0].floorMarkers.addLayer(marker); 1497 } 1498 } 1499 mapEle[0].map.on('click', function() { 1500 isClicked = false;
1501 }).on('popupclose', function() { 1502 isClicked = false; 1503 }); 1504 $(document).on("mouseover", ".leaflet-popup", function() { 1505 isClicked = true; 1506 }).on("mouseout", ".leaflet-popup", function() { 1507 // isClicked = false; 1508 }); 1509 } 1510 } 1511 } 1512 1513 window.getFloorPlanOptions = function (ele) { 1514 var pins; 1515 var width; 1516 var height; 1517 1518 var mapScale = defaultMapScale; 1519 1520 if ($(ele).length > 0) { 1521 if ($(ele)[0].mapOptions) { 1522 return $(ele)[0].mapOptions; 1523 } 1524 1525 if($(ele).eq(0).parent().hasClass('map--modal') || $(ele).eq(0).attr('data-bs-target') === '#mapModal' || $(ele).eq(0).hasClass('map__overlay')) { 1526 mapScale = modalMapScale; 1527 } else { 1528 mapScale = defaultMapScale; 1529 } 1530 } else { 1531 if($(ele).parent().hasClass('map--modal') || $(ele).attr('data-bs-target') === '#mapModal' || $(ele).hasClass('map__overlay')) { 1532 mapScale = modalMapScale; 1533 } else { 1534 mapScale = defaultMapScale; 1535 } 1536 } 1537 1538 // console.log('mapScale 1', mapScale, $(ele)); 1539 // console.log('mapScale 2', $(ele).parent(), $(ele).parent().hasClass('map--modal'), $(ele).hasClass('map__overlay')); 1540 1541 width = parseInt($(ele).attr('data-bs-width')); 1542 height = parseInt($(ele).attr('data-bs-height')); 1543 if (isNaN(width)) 1544 width = 0; 1545 if (isNaN(height)) 1546 height = 0; 1547 try { 1548 pins = JSON.parse($(ele).attr('data-bs-pins')); 1549 } 1550 catch (err) { 1551 pins = []; 1552 } 1553 1554 // console.log('mapScale', width * mapScale, height * mapScale); 1555 1556 return { 1557 src: $(ele).attr('data-bs-src'), 1558 pins: pins, 1559 width: width * mapScale, 1560 height: height * mapScale 1561 }; 1562 } 1563 1564 if ($('.tabs__collapse.collapse .map__wrapper').length > 0) { 1565 $('.tabs__collapse.collapse .map__wrapper').each(function (index) { 1566 if (!$(this).attr('id') || $(this).attr('id') == '') { 1567 $(this).attr('id', 'map' + index); 1568 } 1569 imageID = $(this).attr('id'); 1570 1571 this.map = L.map(imageID, { 1572 minZoom: 1, 1573 maxZoom: 4, 1574 center: [0, 0], 1575 zoom: 1, 1576 attributionControl: false, 1577 maxBoundsViscosity: 4, 1578 zoomControl: false, 1579 crs: L.CRS.Simple 1580 }); 1581 1582 this.map.on('zoomend', function (e) { 1583 var $zoomIn = $(this.getContainer()).parents('.map').find('.map__control__btn--in'); 1584 var $zoomOut = $(this.getContainer()).parents('.map').find('.map__control__btn--out'); 1585 var map = this; 1586 if ($zoomIn.length > 0) { 1587 if (map.getZoom() >= map.getMaxZoom()) { 1588 $zoomIn[0].disabled = true; 1589 } else { 1590 $zoomIn[0].disabled = false; 1591 } 1592 } 1593 if ($zoomOut.length > 0) { 1594 if (map.getZoom() <= map.getMinZoom()) { 1595 $zoomOut[0].disabled = true; 1596 } else { 1597 $zoomOut[0].disabled = false; 1598 } 1599 } 1600 }); 1601 1602 setFloorPlanBounds($(this), getFloorPlanOptions($(this))); 1603 1604 $('.map__control__btn--in').on('click', function () { 1605 var $map = $(this).parents('.map').find('.map__wrapper'); 1606 var zoom; 1607 if ($map.length > 0) { 1608 zoom = $map[0].map.getZoom(); 1609 if (zoom + 1 <= $map[0].map.getMaxZoom()) { 1610 $map[0].map.setZoom(zoom + 1); 1611 } 1612 } 1613 }); 1614 1615 $('.map__control__btn--out').on('click', function () { 1616 var $map = $(this).parents('.map').find('.map__wrapper'); 1617 var zoom; 1618 if ($map.length > 0) { 1619 zoom = $map[0].map.getZoom(); 1620 if (zoom - 1 >= $map[0].map.getMinZoom()) { 1621 $map[0].map.setZoom(zoom - 1); 1622 } 1623 } 1624 }); 1625 1626 $('.map__control__btn--floor').on('click', function () { 1627 var $map = $(this).parents('.map').find('.map__wrapper'); 1628 var options = getFloorPlanOptions($(this)); 1629 var obj = $(this); 1630 $(this).parents('.map').find('.map__control__btn--floor.active').removeClass('active'); 1631 $(this).addClass('active'); 1632 setFloorPlanBounds($map, options); 1633 }); 1634 1635 }); 1636 1637 //preselect first floor button, for handling phase only 1638 setTimeout(function () { 1639 if ($('.tabs__collapse.collapse.show .map__control__btn--floor.active').length) { 1640 $('.tabs__collapse.collapse.show .map__control__btn--floor.active').click(); 1641 } 1642 }, 0); 1643 1644 $('#mapView_panel .tabs__collapse').on('hide.bs.collapse', function () { 1645 $('#' + $(this).attr('aria-labelledby')).removeAttr('disabled'); 1646 }).on('show.bs.collapse', function () { 1647 $('.tabsDropdown__select option[value="' + $(this).attr('id') + '"]').parent().val($(this).attr('id')); 1648 $('#' + $(this).attr('aria-labelledby')).attr('disabled', true); 1649 1650 setTimeout(function () { 1651 if ($('.tabs__collapse.collapse.show .map__control__btn--floor.active').length) { 1652 $('.tabs__collapse.collapse.show .map__control__btn--floor.active').click(); 1653 } 1654 }, 100); 1655 }); 1656 1657 $('button[data-bs-view=mapView]').on('click', function() { 1658 console.log('tab', $('.tabs__collapse.collapse.show .map__control__btn--floor.active')); 1659 setTimeout(function () { 1660 if ($('.tabs__collapse.collapse.show .map__control__btn--floor.active').length) { 1661 $('.tabs__collapse.collapse.show .map__control__btn--floor.active').click(); 1662 } 1663 }, 100); 1664 }); 1665 } else if ($('.map__wrapper').length > 0) { 1666 $('.map__wrapper').each(function (index) { 1667 if (!$(this).attr('id') || $(this).attr('id') == '') { 1668 $(this).attr('id', 'map' + index); 1669 } 1670 imageID = $(this).attr('id'); 1671 1672 this.map = L.map(imageID, { 1673 minZoom: 1, 1674 maxZoom: 4, 1675 center: [0, 0], 1676 zoom: 1, 1677 attributionControl: false, 1678 maxBoundsViscosity: 4, 1679 zoomControl: false, 1680 crs: L.CRS.Simple 1681 }); 1682 1683 this.map.on('zoomend', function (e) { 1684 var $zoomIn = $(this.getContainer()).parents('.map').find('.map__control__btn--in'); 1685 var $zoomOut = $(this.getContainer()).parents('.map').find('.map__control__btn--out'); 1686 var map = this; 1687 if ($zoomIn.length > 0) { 1688 if (map.getZoom() >= map.getMaxZoom()) { 1689 $zoomIn[0].disabled = true; 1690 } else { 1691 $zoomIn[0].disabled = false;
1692 } 1693 } 1694 if ($zoomOut.length > 0) { 1695 if (map.getZoom() <= map.getMinZoom()) { 1696 $zoomOut[0].disabled = true; 1697 } else { 1698 $zoomOut[0].disabled = false; 1699 } 1700 } 1701 }); 1702 1703 setFloorPlanBounds($(this), getFloorPlanOptions($(this))); 1704 1705 $('.map__control__btn--in').on('click', function () { 1706 var $map = $(this).parents('.map').find('.map__wrapper'); 1707 var zoom; 1708 if ($map.length > 0) { 1709 zoom = $map[0].map.getZoom(); 1710 if (zoom + 1 <= $map[0].map.getMaxZoom()) { 1711 $map[0].map.setZoom(zoom + 1); 1712 } 1713 } 1714 }); 1715 1716 $('.map__control__btn--out').on('click', function () { 1717 var $map = $(this).parents('.map').find('.map__wrapper'); 1718 var zoom; 1719 if ($map.length > 0) { 1720 zoom = $map[0].map.getZoom(); 1721 if (zoom - 1 >= $map[0].map.getMinZoom()) { 1722 $map[0].map.setZoom(zoom - 1); 1723 } 1724 } 1725 }); 1726 1727 $('.map__control__btn--floor').on('click', function () { 1728 var $map = $(this).parents('.map').find('.map__wrapper'); 1729 var options = getFloorPlanOptions($(this)); 1730 $(this).parents('.map').find('.map__control__btn--floor.active').removeClass('active'); 1731 $(this).addClass('active'); 1732 setFloorPlanBounds($map, options); 1733 }); 1734 }); 1735 1736 //preselect first floor button, for handling phase only 1737 setTimeout(function () { 1738 if ($('.collapse .map').length && $('.collapse .map__control__btn--floor.active').length) { 1739 $('.collapse .map__control__btn--floor.active').click(); 1740 } 1741 }, 0); 1742 } 1743 1744 $('[data-bs-target="#mapModal"], [data-bs-target="#mapMobileModal"]').on('click', function () { 1745 var options = getFloorPlanOptions($(this)); 1746 var $modal = $($(this).attr('data-bs-target')); 1747 1748 //console.log('click option', options); 1749 1750 if ($modal.length > 0) { 1751 $modal[0].mapOptions = options; 1752 } 1753 }); 1754 1755 $('.modal--map').on('show.bs.modal', function (event) { 1756 // console.log('modal show', this.mapOptions); 1757 var map; 1758 var activePins; 1759 var hasInfo = false; 1760 var options = this.mapOptions ? this.mapOptions : getFloorPlanOptions($(event.relatedTarget)); 1761 // setFloorPlanBounds($(this).find('.map__wrapper'), options); 1762 if ($(this).find('.map__wrapper').length > 0) { 1763 activePins = options.pins.filter(function (item) { return item.isActive || item.isChecked }) 1764 if (options.pins.length > 0) { 1765 if (options.pins.length == 1) { 1766 activePins = options.pins; 1767 } 1768 1769 if (activePins.length > 0) { 1770 if (activePins[0].link && activePins[0].link != '') { 1771 $(this).find('.map__modal__title').attr(activePins[0].link); 1772 } else { 1773 $(this).find('.map__modal__title').attr('href', 'javascript:;'); 1774 } 1775 if (activePins[0].text && activePins[0].text != '') { 1776 $(this).find('.map__modal__title').html(activePins[0].text); 1777 hasInfo = true; 1778 } else { 1779 $(this).find('.map__modal__title').addClass('d-none'); 1780 } 1781 if (activePins[0].tel && activePins[0].tel != '') { 1782 $(this).find('.map__modal__tel').html(activePins[0].tel); 1783 $(this).find('.map__modal__info__item--tel a').attr('href', 'tel:' + activePins[0].tel.split(' ').join('').split('-').join('')); 1784 hasInfo = true; 1785 } else { 1786 $(this).find('.map__modal__info__item--tel').addClass('d-none'); 1787 } 1788 if (activePins[0].location) { 1789 if (activePins[0].location.text && activePins[0].location.text != '') { 1790 $(this).find('.map__modal__location').html(activePins[0].location.text); 1791 hasInfo = true; 1792 } else { 1793 $(this).find('.map__modal__info__item--location').addClass('d-none'); 1794 } 1795 } else { 1796 $(this).find('.map__modal__info__item--location').addClass('d-none'); 1797 } 1798 } 1799 } 1800 if (!hasInfo) {
1801 $(this).find('.modal-footer').addClass('d-none'); 1802 } 1803 } 1804 }); 1805 1806 $('.modal--map').on('shown.bs.modal', function (event) { 1807 // console.log('modal shown', this.mapOptions, this.mapOptions.pins); 1808 var $this = $(this); 1809 var map; 1810 var options = this.mapOptions ? this.mapOptions : getFloorPlanOptions($(event.relatedTarget)); 1811 var activePins = options.pins.filter(function (item) { return item.isActive || item.isChecked }); 1812 1813 // show loading 1814 $this.find('.map__loading').show(); 1815 1816 // start add ajax call to get all shop pins 1817 // add ajax call, update this.mapOptions.pins, and run the below code after updated the pin options 1818 var lang = location.pathname.split('/')[1]; 1819 var floorUid = $('button.map__overlay').attr('data-bs-floor'); 1820 var getShopPinsUrl = '/' + lang + '/Shops/GetShopPins/' + floorUid; 1821 1822 if (typeof floorUid !== 'undefined' && floorUid !== '') { 1823 $.ajax({ 1824 type: 'GET', 1825 url: getShopPinsUrl 1826 }).done(function(data) { 1827 // console.log('data: ', data); 1828 1829 // replace options.pins with data 1830 options.pins = data; 1831 1832 $.each(options.pins, function(index, value){ 1833 // console.log(index, value); 1834 if (value.shopID === activePins[0].shopID) { 1835 options.pins[index] = activePins[0]; 1836 } 1837 }); 1838 }).then(function() { 1839 // console.log('options: ', options); 1840 setMapModalContent($this, options, activePins); 1841 }); 1842 } else { 1843 setMapModalContent($this, options, activePins); 1844 } 1845 // end add ajax call to get all shop pins 1846 }); 1847 1848 window.setMapModalContent = function (ele, options, activePins) { 1849 // console.log('options: ', options); 1850 1851 var $this = ele; 1852 setFloorPlanBounds($this.find('.map__wrapper'), options); 1853 1854 if ($this.find('.map__wrapper').length > 0) { 1855 map = $this.find('.map__wrapper')[0].map; 1856 1857 var mapScale = defaultMapScale; 1858 if($this.find('.map__wrapper').parent().hasClass('map--modal')) { 1859 mapScale = modalMapScale; 1860 } else { 1861 mapScale = defaultMapScale; 1862 } 1863 1864 // activePins = options.pins.filter(function (item) { return item.isActive || item.isChecked }) 1865 // console.log('activePins', activePins); 1866 if (options.pins.length > 0 && window.innerWidth <= 768) { 1867 // if (options.pins.length == 1) { 1868 // map.panTo(map.unproject([options.pins[0].lat * mapScale - options.width / 2, options.pins[0].lng * mapScale - options.height / 2], 1)); 1869 // } else if (activePins.length > 0) { 1870 if (activePins.length > 0) { 1871 map.panTo(map.unproject([activePins[0].lat * mapScale - options.width / 2, activePins[0].lng * mapScale - options.height / 2], 1)); 1872 // map.panTo([0, 0]); 1873 } else { 1874 map.panTo([0, 0]); 1875 } 1876 } else { 1877 map.panTo([0, 0]); 1878 } 1879 setTimeout(function () { 1880 map.invalidateSize(); 1881 }, 200); 1882 } 1883 } 1884 1885 $('.modal--map').on('hidden.bs.modal', function (event) { 1886 this.mapOptions = false; 1887 $(this).find('.modal-footer').removeClass('d-none'); 1888 $(this).find('.map__modal__title').removeClass('d-none'); 1889 $(this).find('.map__modal__info__item--tel').removeClass('d-none'); 1890 $(this).find('.map__modal__info__item--location').removeClass('d-none'); 1891 }); 1892 1893 window.matchMedia("(min-width: 769px)").addListener(function (media) { 1894 if (media.matches) { 1895 $('#mapMobileModal').modal('hide'); 1896 } 1897 }) 1898}); 1899$(document).ready(function () { 1900 var windowHeight = $(window).height(); 1901 $('.modal').appendTo($('body')); 1902 $('.modal .video').on('videoReady', function (event) { 1903 var _$player = $(event.target).parents('.video'); 1904 stopVideo(_$player[0]); 1905 }); 1906 1907 $('.modal').on('shown.bs.modal', function (event) { 1908 if ($(event.target).length > 0) { 1909 var _$player = $(event.target).find('.video'); 1910 if (_$player.length === 0 && $(event.target).attr('data-bs-target')) { 1911 _$player = $($(event.target).attr('data-bs-target')).find('.video') 1912 } 1913 var _index; 1914 if (_$player.length > 0) { 1915 for (_index = 0; _index < _$player.length; _index++) { 1916 playVideo(_$player[_index]); 1917 } 1918 } 1919 } 1920 }); 1921 1922 $('.modal').on('hidden.bs.modal', function (event) { 1923 if ($(event.target).length > 0) { 1924 var _$player = $(event.target).find('.video'); 1925 if (_$player.length > 0) { 1926 for (var i = 0; i < _$player.length; i++) { 1927 stopVideo(_$player[i]); 1928 } 1929 } 1930 } 1931 }); 1932 1933 $(window).on('resize', function () { 1934 if ($('.ios').length > 0 && windowHeight > $(window).height() && $('.modal-open').length > 0) { 1935 $('body').addClass('ios-modal'); 1936 } else { 1937 $('body').removeClass('ios-modal'); 1938 } 1939 windowHeight = $(window).height(); 1940 }); 1941 1942 if ($.trim($('#noticeModal')) != "" && $('#noticeModal').length > 0) { 1943 1944 var sessionNM = sessionStorage.getItem("NoticeModal"); 1945 1946 if ($.trim(sessionNM) == "") { 1947 $('#noticeModal').modal('show'); 1948 } else { 1949 $('#noticeModal').remove(); 1950 } 1951 1952 $('#noticeModal.modal.notice--popup').on('click', function () { 1953 var cls = $(this).attr('class'); 1954 if (cls == 'modal notice--popup') { 1955 sessionStorage.setItem("NoticeModal", "showed"); 1956 } 1957 }); 1958 $('#noticeModal .modal__close').on('click', function () { 1959 sessionStorage.setItem("NoticeModal", "showed"); 1960 }); 1961 $('#noticeModal .button, #noticeModal a').on('click', function () { 1962 sessionStorage.setItem("NoticeModal", "showed"); 1963 }); 1964 1965 } 1966 1967}); 1968 1969$(document).ready(function () { 1970 $('.scrollDownLink').on('click', function (event) { 1971 event.preventDefault(); 1972 var $toEle = $($(this).attr('href')); 1973 if ($toEle.length > 0) { 1974 if (navigator.userAgent.indexOf('Edge') >= 0) { 1975 window.scrollTo($('body')[0], $toEle.offset().top, 400); 1976 } else { 1977 window.scrollTo(document.documentElement, $toEle.offset().top, 400); 1978 } 1979 window.scrollTo(document.documentElement, $toEle.offset().top, 400); 1980 } 1981 }); 1982}); 1983$(document).ready(function () { 1984 var historys; 1985 var maxHistory = parseInt($('.searchModal__history').attr('data-bs-max-history')); 1986 var maxResult = parseInt($('.searchModal__results').attr('data-bs-max-result')); 1987 var searchKey = ''; 1988 var searchTimeout = null;
1989 if (isNaN(maxHistory)) maxHistory = 5; 1990 if (isNaN(maxResult)) maxResult = 5; 1991 try { 1992 historys = JSON.parse(localStorage.getItem('mtrmall_search_history')); 1993 if (historys == null) 1994 historys = []; 1995 } 1996 catch (err) { 1997 historys = []; 1998 } 1999 2000 2001 function sanitize(value) { 2002 return DOMPurify.sanitize(value); 2003 } 2004 function escapeHtml(unsafe) { 2005 return unsafe 2006 .replace(/&/g, "&") 2007 .replace(/</g, "<") 2008 .replace(/>/g, ">") 2009 .replace(/"/g, """) 2010 .replace(/'/g, "'"); 2011 } 2012 2013 2014 function addHistory(keyword) { 2015 var _keyword = keyword.replace(/\r|\n|\\r|\\n/g, ' '); 2016 if (historys.indexOf(_keyword) == -1) { 2017 historys.push(_keyword); 2018 if (historys.length > maxHistory) historys.shift(); 2019 localStorage.setItem('mtrmall_search_history', JSON.stringify(historys)); 2020 updateHistory(); 2021 } 2022 } 2023 function clearHistory() { 2024 historys = []; 2025 localStorage.removeItem('mtrmall_search_history'); 2026 updateHistory(); 2027 } 2028 function updateHistory() { 2029 var $item; 2030 $('.searchModal__history__list').addClass('d-none').html(''); 2031 if (historys.length == 0) { 2032 $('.searchModal__history__empty').removeClass('d-none'); 2033 $('.searchModal__history__title__btn').addClass('d-none'); 2034 } else { 2035 $('.searchModal__history__empty').addClass('d-none'); 2036 $('.searchModal__history__title__btn').removeClass('d-none'); 2037 for (var i = historys.length - 1; i >= 0; i--) { 2038 $item = $('.searchModal__history__item.d-none').clone(); 2039 $item.attr('href', window.resultURL + encodeURIComponent(historys[i])); 2040 $item.html(historys[i]); 2041 $item.removeClass('d-none'); 2042 $('.searchModal__history__list').append($item); 2043 } 2044 $('.searchModal__history__list').removeClass('d-none'); 2045 } 2046 } 2047 function loading() { 2048 if (!$('.searchModal__results').is('.searchModal__results--loading')) { 2049 $('.searchModal__history').addClass('d-none'); 2050 $('.searchModal__results__list').addClass('d-none'); 2051 $('.searchModal__results__more').addClass('d-none'); 2052 $('.searchModal__results__title').addClass('d-none'); 2053 $('.searchModal__results__empty').addClass('d-none'); 2054 $('.searchModal__results').removeClass('d-none').addClass('searchModal__results--loading'); 2055 $('.searchModal__results__loading').fadeIn(200); 2056 } 2057 } 2058 function updateResult(data) { 2059 var $item; 2060 var $icon; 2061 var $list = $('.searchModal__results__list'); 2062 var $more = $('.searchModal__results__more'); 2063 var $loading = $('.searchModal__results__loading'); 2064 var $empty = $('.searchModal__results__empty'); 2065 var $title = $('.searchModal__results__title'); 2066 $list.addClass('d-none').html(''); 2067 $more.addClass('d-none'); 2068 $title.addClass('d-none'); 2069 $empty.addClass('d-none'); 2070 if (Array.isArray(data)) { 2071 if (data.length > 0) { 2072 $title.removeClass('d-none'); 2073 for (var i = 0; i < data.length; i++) { 2074 $item = $('.searchModal__results__item.d-none').clone(true); 2075 $icon = $('.searchModal__icon.d-none[data-bs-search-type="' + sanitize(data[i].type) + '"]').clone(true); 2076 $icon.removeClass('d-none'); 2077 2078 $item.find('.searchModal__results__item__icon').append($icon); 2079 $item.find('.searchModal__results__item__text').html(sanitize(data[i].text)); 2080 $item.find('.searchModal__results__item__title').html(sanitize(data[i].title)); 2081 2082 $item.attr('href', data[i].href); 2083 $item.attr('target', sanitize(data[i].target)); 2084 2085 $item.removeClass('d-none').appendTo($list); 2086 } 2087 $('.searchModal__results__more__link').attr('href', window.resultURL + encodeURIComponent(searchKey)); 2088 $loading.fadeOut(200, function () { 2089 $list.removeClass('d-none'); 2090 $more.removeClass('d-none'); 2091 $('.searchModal__results--loading').removeClass('searchModal__results--loading'); 2092 }); 2093 } else { 2094 $loading.fadeOut(200, function () { 2095 $empty.removeClass('d-none'); 2096 $('.searchModal__results--loading').removeClass('searchModal__results--loading'); 2097 }); 2098 } 2099 } else { 2100 $loading.fadeOut(200, function () { 2101 $empty.removeClass('d-none'); 2102 $('.searchModal__results--loading').removeClass('searchModal__results--loading'); 2103 }); 2104 } 2105 } 2106 updateHistory(); 2107 if ($('.searchModal').length > 0) { 2108 $('.searchModal__history__title__btn').click(function () { 2109 clearHistory(); 2110 }); 2111 $('.searchModal__results__item').click(function () { 2112 var $searchModal = $(this).parents('.searchModal'); 2113 var $input = $searchModal.find('.form-control'); 2114 if ($input.length > 0 && $input.val() && $input.val() != '') { 2115 addHistory($input.val()); 2116 } 2117 }); 2118 $('.searchModal .input-group-text__icon').click(function (event) { 2119 var $searchModal = $(this).parents('.searchModal'); 2120 var $input = $searchModal.find('.form-control'); 2121 var val = escapeHtml($input.val().replace(/\r|\n|\\r|\\n/g, ' ')); 2122 event.preventDefault(); 2123 if ($input.length > 0 && typeof val == 'string' && val != '') { 2124 addHistory(val); 2125 location.href = window.resultURL + val; 2126 } 2127 }); 2128 $('.searchModal__results__more__link').click(function () { 2129 var $searchModal = $(this).parents().parents('.searchModal'); 2130 var $input = $searchModal.find('.form-control'); 2131 if ($input.length > 0 && $input.val() && $input.val() != '') { 2132 addHistory($input.val()); 2133 } 2134 }); 2135 $('.searchModal .form-control').on('keyup', function (event) { 2136 var val = escapeHtml($(this).val().replace(/\r|\n|\\r|\\n/g, ' ')); 2137 var _searchMinLength = location.href.search('/en/') != -1 ? 2 : 1; 2138 if (!val) val = ''; 2139 if (searchTimeout != null) 2140 clearTimeout(searchTimeout); 2141 if (event.key == "Enter") { 2142 if (typeof val == 'string' && val != '') { 2143 addHistory(val); 2144 location.href = window.resultURL + val; 2145 } 2146 } else { 2147 if (val != '' && (val.length >= _searchMinLength || searchKey != '') && val != searchKey) { 2148 loading(); 2149 searchTimeout = setTimeout(function () { 2150 searchKey = val; 2151 //console.log('$AJAX: ' + window.searchAPI + searchKey); 2152 $.ajax({ 2153 method: 'GET', 2154 url: window.searchAPI + escapeHtml(searchKey.replace(/\r|\n|\\r|\\n/g, ' ')) 2155 }).done(function (data) { 2156 //console.log('done', data); 2157 updateResult(data); 2158 }).fail(function (err) { 2159 //console.log('fail', err); 2160 updateResult([]); 2161 // updateResult([{ type: "dining", title: "xxx", text: "<strong>dd</strong> yy", href: "#" }, { href: "#", type: "dining", title: "xxx", text: "<strong>dd</strong> yy" }]); // demo 2162 }); 2163 }, 400); 2164 } else if (val == '') { 2165 searchKey = val; 2166 $('.searchModal__history').removeClass('d-none'); 2167 $('.searchModal__results').addClass('d-none'); 2168 $('.searchModal__results--loading').removeClass('searchModal__results--loading'); 2169 $('.searchModal__results__loading').fadeOut(200); 2170 } 2171 } 2172 }); 2173 $('.searchModal .form-control').on('change', function (event) { 2174 var val = escapeHtml($(this).val().replace(/\r|\n|\\r|\\n/g, ' ')); 2175 if (!val) val = ''; 2176 if (searchTimeout != null) 2177 clearTimeout(searchTimeout); 2178 if (val != '' && val != searchKey) { 2179 loading(); 2180 searchKey = val; 2181 //console.log('$AJAX: ' + window.searchAPI + searchKey); 2182 $.ajax({ 2183 method: 'GET', 2184 url: window.searchAPI + searchKey 2185 }).done(function (data) { 2186 //console.log('done', data); 2187 updateResult(data); 2188 }).fail(function (err) { 2189 //console.log('fail', err); 2190 updateResult([]); 2191 // updateResult([{ type: "dining", title: "xxx", text: "<strong>dd</strong> yy", href: "#" }, { href: "#", type: "dining", title: "xxx", text: "<strong>dd</strong> yy" }]); // demo 2192 }); 2193 } else if (val == '') { 2194 searchKey = val; 2195 $('.searchModal__history').removeClass('d-none'); 2196 $('.searchModal__results').addClass('d-none'); 2197 $('.searchModal__results--loading').removeClass('searchModal__results--loading'); 2198 $('.searchModal__results__loading').fadeOut(200); 2199 } 2200 }); 2201 $('.searchModal') 2202 .on('show.bs.modal', function () { 2203 $('.header').addClass('header--searchOpen'); 2204 $('.searchModal__results').addClass('d-none'); 2205 $('.searchModal__history').removeClass('d-none'); 2206 2207 $(this).find('.form-control').val(''); 2208 searchKey = ''; 2209 }) 2210 .on('hidden.bs.modal', function () { 2211 $('body').removeClass('header--searchOpen'); 2212 searchKey = ''; 2213 if (searchTimeout != null) 2214 clearTimeout(searchTimeout); 2215 }); 2216 } 2217}); 2218 2219$(document).ready(function () { 2220 $('.shopDetails__description__preview').each(function () { 2221 var $this = $(this); 2222 var $img = $this.find('img'); 2223 //console.log($this, $img); 2224 if ($this.outerHeight() > $img.outerHeight()) { 2225 $img.addClass('fixHeight'); 2226 } else { 2227 $img.removeClass('fixHeight'); 2228 } 2229 }); 2230}); 2231$(document).ready(function () { 2232 2233 function sanitize(value) { 2234 return DOMPurify.sanitize(value); 2235 } 2236 2237 2238 // reset filter 2239 if ($('.shopList').length > 0) { 2240 setTimeout(function(){ 2241 $('input[name="Cuisine"]').eq(0).click(); 2242 $('input[name="Features"]').eq(0).click(); 2243 if($('#filterFloor').length > 0) { 2244 $('#filterFloor').find('.shopList__filter__item__input:checked').click(); 2245 } 2246 }, 0); 2247 } 2248 2249 var params = window.getAllUrlParams(); 2250 var windowWidth = $(window).width(); 2251 2252 function shopListScrolldownHandle() { 2253 var _$next = $(this.element).next('.shopList__group'); 2254 this.destroy(); 2255 if (_$next.length > 0) { 2256 loading(true); 2257 2258 setTimeout(function () { 2259 loading(false); 2260 if (_$next.length > 0) { 2261 _$next.eq(0).addClass('shopList__group--show').slideDown(1000, function () { 2262 if ($(this).next('.shopList__group').length > 0) { 2263 $(this).waypoint({ 2264 handler: shopListScrolldownHandle, 2265 offset: 'bottom-in-view' 2266 }); 2267 } 2268 }); 2269 2270 } 2271 }, 1000); 2272 } 2273 } 2274 2275 function shopListInit() { 2276 var _$list = $('.shopList__list'); 2277 var _$shops; 2278 2279 $('.shopList__group--show').removeClass('shopList__group--show'); 2280 2281 if (_$list.length > 0) { 2282 _$list.each(function () { 2283 _$this = $(this); 2284 _$shops = _$this.find('.shopList__shops .shopList__group'); 2285 _$shops.hide(); 2286 2287 setTimeout(function () { 2288 loading(false); 2289 if (_$shops.length > 0) 2290 _$shops.eq(0).addClass('shopList__group--show').slideDown(1000, function () { 2291 if ($(this).next('.shopList__group').length > 0) { 2292 $(this).waypoint({ 2293 handler: shopListScrolldownHandle, 2294 offset: 'bottom-in-view' 2295 }); 2296 } 2297 }); 2298 }, 1000); 2299 }); 2300 } 2301 }; 2302 2303 function sort() { 2304 $('.shopList__results__sort').toggleClass('shopList__results__sort--desc'); 2305 if ($('.shopList__results__sort').hasClass('shopList__results__sort--desc')) { 2306 params.sort = 'desc'; 2307 } else { 2308 params.sort = 'asc'; 2309 } 2310 window.fullShopsList.reverse(); 2311 window.currentShopsList.reverse(); 2312 window.displayList.reverse(); 2313 } 2314 2315 function resetFilter() { 2316 var $checkbox = $('.shopList__filter__item__input[type="checkbox"]'); 2317 var $radio = $('.shopList__filter__item__input[type="radio"]'); 2318 var $checked; 2319 $checkbox.each(function () { 2320 this.checked = $('.shopList__badges__item[data-bs-value="' + this.value + '"][data-bs-name="' + $(this).attr('name') + '"]').length > 0; 2321 }); 2322 2323 $radio.each(function () { 2324 $checked = $(this).parents('.shopList__filter__group').find('.shopList__filter__item__input[type="checkbox"]:checked'); 2325 $checkbox = $(this).parents('.shopList__filter__group').find('.shopList__filter__item__input[type="checkbox"]'); 2326 if ($checked.length == $checkbox.length) { 2327 $checkbox.each(function () { 2328 this.checked = false;
2329 }); 2330 $checked = $(this).parents('.shopList__filter__group').find('.shopList__filter__item__input[type="checkbox"]:checked'); 2331 } 2332 this.checked = $checked.length == 0; 2333 }); 2334 }; 2335 2336 function filtersUpdate(addFilter, value, name, text) { 2337 var $badges = $('.shopList__badges'); 2338 var $tempBadge = $('.shopList__badges__item.d-none'); 2339 var $addBadge; 2340 var $input = $('.shopList__filter__item__input[value="' + value + '"][name="' + name + '"]'); 2341 2342 if ($input.length > 0) { 2343 $input[0].checked = addFilter === true; 2344 } 2345 if (addFilter) { 2346 if (typeof params.filters != "undefined") { 2347 if (params.filters.indexOf(value) == -1) { 2348 params.filters.push(value); 2349 } 2350 } 2351 if ($('.shopList__badges__item[data-bs-value="' + value + '"][data-bs-name="' + name + '"]').length == 0) { 2352 $addBadge = $tempBadge.clone(true) 2353 .attr('data-bs-value', value) 2354 .attr('data-bs-name', name) 2355 .removeClass('d-none'); 2356 $addBadge.find('.badge__text').html(text); 2357 $badges.find('.shopList__badges__wrapper') 2358 .append($addBadge); 2359 $badges.removeClass('d-block'); 2360 } 2361 } else { 2362 if (typeof params.filters != "undefined") { 2363 if (params.filters.indexOf(value) != -1) { 2364 params.filters.splice(params.filters.indexOf(value), 1); 2365 $badges.find('.shopList__badges__item[data-bs-value="' + value + '"][data-bs-name="' + name + '"]').remove(); 2366 if (params.length <= 0) { 2367 $badges.addClass('d-block'); 2368 } 2369 } 2370 } 2371 } 2372 } 2373 2374 function loading(isLoading) { 2375 if (isLoading) { 2376 $('.shopList__loading').fadeIn(); 2377 } else { 2378 $('.shopList__loading').fadeOut(); 2379 } 2380 } 2381 2382 function textSearch() { 2383 var name, value 2384 var searchList = window.fullShopsList.filter(function (item) { 2385 if (!params.search || params.search == "") 2386 return true; 2387 if (!item.text) 2388 return false; 2389 return item.text.toLowerCase().search(params.search.toLowerCase()) != -1; 2390 }).map(function (item) { 2391 return item.shopID; 2392 }); 2393 window.displayList = window.currentShopsList.filter(function (item) { 2394 return searchList.indexOf(item.shopID) != -1; 2395 }); 2396 2397 $('.shopList__filter__item__input[type="radio"]') 2398 .next('.shopList__filter__item__label') 2399 .find('.shopList__filter__item__count') 2400 .html(sanitize(window.displayList.length)); 2401 2402 $('.shopList__filter__item__input[type="checkbox"]').each(function () { 2403 name = $(this).attr('name').toLowerCase(); 2404 value = this.value; 2405 $(this).next('.shopList__filter__item__label') 2406 .find('.shopList__filter__item__count') 2407 .html(sanitize(window.displayList.filter(function (item) { 2408 if (Array.isArray(item[name])) 2409 return item[name].indexOf(value) != -1; 2410 else 2411 return item[name] == value; 2412 }).length)); 2413 }); 2414 } 2415 2416 function shopsFilter() { 2417 var index, isFilter, isPass = true, filters = []; 2418 $('.shopList__badges__wrapper .shopList__badges__item').each(function () { 2419 filters.push({ 2420 type: $(this).attr('data-bs-name'), 2421 value: $(this).attr('data-bs-value') 2422 }); 2423 }); 2424 return window.displayList.filter(function (item) { 2425 isFilter = {}; 2426 isPass = true; 2427 for (index = 0; index < filters.length; index++) { 2428 if (typeof filters[index].type == 'string') { 2429 if (typeof isFilter[filters[index].type.toLowerCase()] == 'undefined') 2430 isFilter[filters[index].type.toLowerCase()] = false;
2431 if (!isFilter[filters[index].type.toLowerCase()]) { 2432 if (Array.isArray(item[filters[index].type.toLowerCase()])) 2433 isFilter[filters[index].type.toLowerCase()] = item[filters[index].type.toLowerCase()].indexOf(filters[index].value) != -1; 2434 else 2435 isFilter[filters[index].type.toLowerCase()] = item[filters[index].type.toLowerCase()] == filters[index].value; 2436 } 2437 } 2438 } 2439 for (index in isFilter) { 2440 if (isFilter[index] === false) 2441 isPass = false; 2442 } 2443 return isPass; 2444 }); 2445 } 2446 2447 function reBuildList(shopId) { 2448 var $tempGroup = $('.shopList__group.d-none').eq(0); 2449 var $tempItem = $('.shopList__list__item.d-none').eq(0); 2450 var $tempIcon = $('.shopList__list__item.d-none .shopCard__icons__item').eq(0); 2451 var $shops = $('.shopList__shops'); 2452 var defaultShow = parseInt($shops.attr('data-bs-default-show')); 2453 var groupItems = parseInt($shops.attr('data-bs-show')); 2454 var path = window.location.pathname || ""; 2455 var startIndex = 0, endIndex; 2456 var filterList = shopsFilter(); 2457 var floorList = []; 2458 2459 function addGroup(_start, _end) { 2460 var $appendGroup, 2461 $newItem, 2462 $icons, 2463 $icon, 2464 index, 2465 subIndex; 2466 2467 if (typeof _start == 'undefined' || _start == null) { 2468 _start = 0; 2469 } 2470 if (typeof _end == 'undefined' || _end == null) { 2471 _end = 0; 2472 } 2473 2474 $appendGroup = $tempGroup.clone(true); 2475 $appendGroup.removeClass('d-none'); 2476 2477 for (index = _start; index < _end; index++) { 2478 // console.log('filterList[index]', index, filterList[index]); 2479 if (!floorList.includes(filterList[index].floor)) { 2480 floorList.push(filterList[index].floor); 2481 } 2482 // console.log('floorList', floorList); 2483 2484 $newItem = $tempItem.clone(true); 2485 $newItem.removeClass('d-none'); 2486 if (filterList[index].badge != null && filterList[index].badge != '') { 2487 $newItem.find('.shopCard__badge').html(sanitize(filterList[index].badge)); 2488 } else { 2489 $newItem.find('.shopCard__badge').addClass('d-none'); 2490 } 2491 2492 $newItem.find('.shopCard__preview__image').css('background-image', 'url("' + filterList[index].src + '")'); 2493 $newItem.find('.shopCard__title').attr('href', sanitize(filterList[index].link)).attr('target', sanitize(filterList[index].target)).html(sanitize(filterList[index].text)); 2494 2495 if (filterList[index].location != null) { 2496 if (filterList[index].location.text && filterList[index].location.text != '') { 2497 $newItem.find('.shopCard__info__item--location') 2498 .find('.iconText__text') 2499 .html(sanitize(filterList[index].location.text)); 2500 if (((filterList[index].location.link && filterList[index].location.link != '') || filterList[index].location.modal != null) && filterList[index].pin != null) { 2501 $newItem.find('.shopCard__info__item--location') 2502 .attr('data-bs-shopID', sanitize(filterList[index].shopID)) 2503 .attr('href', sanitize(path) + "?view=map#" + sanitize(filterList[index].shopID)); 2504 } else { 2505 $newItem.find('.shopCard__info__item--location') 2506 .removeAttr('data-bs-shopID') 2507 .removeAttr('href'); 2508 } 2509 } else { 2510 $newItem.find('.shopCard__info__item--location').parent().addClass('d-none'); 2511 } 2512 } else { 2513 $newItem.find('.shopCard__info__item--location').parent().addClass('d-none'); 2514 } 2515 2516 if (filterList[index].time != null) { 2517 $newItem.find('.shopCard__info__item--time') 2518 .find('.iconText__text') 2519 .html(sanitize(filterList[index].time)); 2520 } else { 2521 $newItem.find('.shopCard__info__item--time').parent().addClass('d-none'); 2522 } 2523 2524 $icons = $newItem.find('.shopCard__icons--service'); 2525 $icons.html(''); 2526 if (Array.isArray(filterList[index].service)) { 2527 for (subIndex = 0; subIndex < filterList[index].service.length; subIndex++) { 2528 $icon = $tempIcon.clone(true); 2529 $icon.find('.icon').attr('title', filterList[index].service[subIndex].text); 2530 $icon.find('.icon img') 2531 .attr('alt', sanitize(filterList[index].service[subIndex].text)) 2532 .attr('src', sanitize(filterList[index].service[subIndex].src)); 2533 2534 $icons.append($icon); 2535 } 2536 } 2537 $icons = $newItem.find('.shopCard__icons--discount'); 2538 $icons.html(''); 2539 if (Array.isArray(filterList[index].discount)) { 2540 for (subIndex = 0; subIndex < filterList[index].discount.length; subIndex++) { 2541 $icon = $tempIcon.clone(true); 2542 $icon.find('.icon').attr('title', filterList[index].discount[subIndex].text); 2543 $icon.find('.icon img') 2544 .attr('alt', sanitize(filterList[index].discount[subIndex].text)) 2545 .attr('src', sanitize(filterList[index].discount[subIndex].src)); 2546 $icons.append($icon); 2547 } 2548 } 2549 2550 $appendGroup.find('.shopList__group__list').append($newItem); 2551 } 2552 2553 $shops.append($appendGroup); 2554 } 2555 2556 // console.log(filterList); 2557 var floorPins = []; 2558 var thisFloor; 2559 var floorActive = false;
2560 var searchId = shopId; 2561 if (!shopId || shopId == '') { 2562 searchId = location.hash; 2563 if (typeof searchId == 'string') { 2564 searchId = searchId.substr(1); 2565 } 2566 } 2567 // console.log(searchId) 2568 $('.map__control__btn--floor').each(function () { 2569 // reset pins 2570 $(this).attr('data-bs-pins', sanitize( JSON.stringify(floorPins.map(function (item) { item.isChecked = false; return item; })))); 2571 // console.log('floorPins reset', floorPins); 2572 2573 thisFloor = $(this).attr('data-bs-value'); 2574 floorActive = false; 2575 floorPins = filterList.filter(function (item) { 2576 return item.floor == thisFloor && item.pin != null; 2577 }).map(function (item) { 2578 if (searchId && searchId != '') { 2579 if (item.pin.shopID == searchId) { 2580 item.pin.isChecked = true; 2581 floorActive = true; 2582 } 2583 } 2584 return item.pin; 2585 }); 2586 2587 // console.log('thisFloor', thisFloor, floorActive, !$(this).is('.active'), $(this)); 2588 // console.log('floorPins', floorPins); 2589 2590 // Handle card location jump to wrong floor issue which caused by multi phases 2591 clickPhaseTab(thisFloor, floorActive); 2592 2593 $(this).attr('data-bs-pins', sanitize(JSON.stringify(floorPins))); 2594 if (floorActive && !$(this).is('.active')) { 2595 $(this).parents('.map__control').find('.map__control__btn--floor.active').removeClass('active'); 2596 $(this).addClass('active'); 2597 window.setFloorPlanBounds($('.map__wrapper'), window.getFloorPlanOptions($(this))); 2598 } else if ($(this).is('.active')) { 2599 window.setFloorPlanMarkers($('.map__wrapper'), floorPins, window.getFloorPlanOptions($(this)).height / 2 - 500); 2600 2601 if($('.shopList__filter__groupitem').length > 0){ 2602 setTimeout(function() { 2603 $('.map__pin.focus').click(); 2604 }, 500); 2605 } 2606 } 2607 if($('.shopList__filter__groupitem').length === 0){ 2608 $(this).attr('data-bs-pins', sanitize(JSON.stringify(floorPins.map(function (item) { item.isChecked = false; return item; })))); 2609 } 2610 2611 // handle filter show pin in other phases 2612 setTimeout(function() { 2613 if($('.tabs__collapse.collapse.show .map__control__btn--floor').length > 0) { 2614 if ($('.tabs__collapse.collapse.show .map__control__btn--floor.active:visible').length === 0) { 2615 $('.tabs__collapse.collapse.show .map__control__btn--floor:visible').first().click(); 2616 } else if ($('.tabs__collapse.collapse.show .map__control__btn--floor')) { 2617 $('.tabs__collapse.collapse.show .map__control__btn--floor.active:visible').click(); 2618 } 2619 } 2620 }, 0); 2621 }); 2622 2623 $('.shopList__results__count').html(sanitize(filterList.length)); 2624 2625 if (isNaN(defaultShow)) defaultShow = 6; 2626 if (isNaN(groupItems)) groupItems = 6; 2627 2628 endIndex = filterList.length < defaultShow ? filterList.length : defaultShow; 2629 2630 $shops.html(''); 2631 loading(true); 2632 addGroup(startIndex, endIndex); // default show 2633 2634 while (endIndex < filterList.length) { 2635 startIndex = endIndex; 2636 endIndex = filterList.length < startIndex + groupItems ? filterList.length : startIndex + groupItems; 2637 addGroup(startIndex, endIndex); 2638 } 2639 2640 if($("#filterFloor .shopList__filter__item__input").length > 0) { 2641 // console.log('floorList', floorList);
2642 // Only displays selected floors in map view 2643 var allFloors = $("#filterFloor .shopList__filter__item__input"); 2644 var phases = $.unique($.map(allFloors, function (floor) { 2645 var floorValue = $(floor).attr('value'); 2646 return $.inArray(floorValue, floorList) !== -1 ? $(floor).closest('.shopList__filter__groupitem').attr('tabid') : null; 2647 })); 2648 // console.log('phases', phases); 2649 if (phases.length > 0) { 2650 $('ul.tabs__wrapper li.tabs__item').each(function () { 2651 var tabId = $(this).children('.tabs__item__btn').attr('id'); 2652 if ($.inArray(tabId, phases) === -1) { 2653 $(this).hide(); 2654 } else { 2655 $(this).show(); 2656 } 2657 }); 2658 } 2659 $('.map__control__btn--floor').each(function () { 2660 // console.log('check floor', $(this).attr('data-bs-value'), $.inArray($(this).attr('data-bs-value'), floorList)); 2661 if ($.inArray($(this).attr('data-bs-value'), floorList) === -1) { 2662 if ($(this).hasClass('active')) { 2663 $(this).removeClass('active'); 2664 } 2665 $(this).hide(); 2666 } else { 2667 $(this).show(); 2668 } 2669 }); 2670 if(phases.length > 0) { 2671 $('#' + phases[0]).click(); 2672 // console.log('phase click'); 2673 } 2674 // if ($('ul.tabs__wrapper li.tabs__item .tabs__item__btn:visible').length > 0) { 2675 // $('ul.tabs__wrapper li.tabs__item .tabs__item__btn:visible').first().click(); 2676 // // $('#' + phases[0]).click(); 2677 // // console.log('phases[0]', phases[0], $('#' + phases[0])); 2678 // } 2679 2680 if ($('.map__control__btn--floor:visible').length > 0) { 2681 $('.map__control__btn--floor:visible').first().click(); 2682 // console.log('floor click'); 2683 } 2684 } 2685 2686 if(filterList.length === 0) { 2687 $('#mapView').children('div').hide(); 2688 } else { 2689 $('#mapView').children('div').show(); 2690 } 2691 2692 shopListInit(); 2693 } 2694 2695 function clickPhaseTab (thisFloor, floorActive) { 2696 // Handle card location jump to wrong floor issue which caused by multi phases 2697 var _tabid = ''; 2698 var _tabContentClass = ''; 2699 if($('.shopList__filter__groupitem').length > 0){ 2700 $('.shopList__filter__item__input').each(function() { 2701 var _value = $(this).attr('value'); 2702 // console.log('_value', _value, thisFloor, _value === thisFloor); 2703 if(_value === thisFloor && floorActive) { 2704 _tabid = $(this).closest('.shopList__filter__groupitem').attr('tabid'); 2705 // console.log('_value', _value, thisFloor); 2706 // console.log('_tabid', _tabid); 2707 _tabContentClass = _tabid.replace('Handle', ''); 2708 2709 setTimeout(function(){ 2710 $('#'+_tabid).trigger('click'); 2711 2712 $('.' + _tabContentClass).find('.map__control__btn--floor').each(function() { 2713 var _floorValue = $(this).attr('data-bs-value'); 2714 if(_floorValue === _value) { 2715 $(this).trigger('click'); 2716 } 2717 }); 2718 }, 50); 2719 } 2720 }); 2721 } 2722 } 2723 2724 function initShopsListingComponent() { 2725 2726 $('.shopCard').on('click', function (event) { 2727 var _$item = $(event.target).is('.shopCard') ? $(event.target) : $(event.target).parents('.shopCard'); 2728 var _$title = _$item.find('.shopCard__title'); 2729 2730 if (!$(event.target).is('button, a') || ($(event.target).is('button, a') && (!_$title.attr('href') || _$title.attr('href') != ''))) { 2731 if (_$title.attr('target') && _$title.attr('target') === '_blank') { 2732 window.open(_$title.attr('href'), '_blank'); 2733 } else { 2734 location.href = _$title.attr('href'); 2735 } 2736 } 2737 }); 2738 2739 $('.eventCard').on('click', function (event) { 2740 var _$item = $(event.target).is('.eventCard') ? $(event.target) : $(event.target).parents('.eventCard'); 2741 var _$title = _$item.find('.eventCard__title'); 2742 2743 if (!$(event.target).is('button, a') || ($(event.target).is('button, a') && (!_$title.attr('href') || _$title.attr('href') != ''))) { 2744 if (_$title.attr('target') && _$title.attr('target') === '_blank') { 2745 window.open(_$title.attr('href'), '_blank'); 2746 } else { 2747 location.href = _$title.attr('href'); 2748 } 2749 } 2750 }); 2751 2752 // is listing page 2753 if ($('.shopList').length > 0) { 2754 // get url params 2755 if (params.filters) { 2756 params.filters = params.filters.split(','); 2757 } else { 2758 params.filters = []; 2759 } 2760 if (params.view != 'map') params.view = 'view'; 2761 if (!params.search) params.search = ''; 2762 if (params.sort != 'desc') params.sort = 'asc'; 2763 2764 // init 2765 // card click handle 2766 loading(true); 2767 $('.shopCard__info__item--location').on('click', function (event) { 2768 var shopId = $(this).attr('data-bs-shopID'); 2769 if (shopId && shopId != '') { 2770 event.preventDefault(); 2771 reBuildList(shopId); 2772 $('#mapView').collapse('show'); 2773 setTimeout(function () { 2774 $('html, body').animate({ scrollTop: $('#mapView.show').offset().top }, 'slow'); 2775 }, 200); 2776 } 2777 }); 2778 2779 // sorting click handle 2780 $('.shopList__results__sort').on('click', function () { 2781 sort(); 2782 reBuildList(); 2783 }); 2784 2785 // view change handle 2786 $('#listView, #mapView').on('hide.bs.collapse', function () { 2787 $('#' + $(this).attr('aria-labelledby')).removeAttr('disabled'); 2788 }).on('show.bs.collapse', function () { 2789 $('#' + $(this).attr('aria-labelledby')).attr('disabled', true); 2790 $('.shopList__filter__submit').removeClass('activeView'); 2791 $('.shopList__filter__submit[data-bs-view="' + $(this).attr('id') + '"]').addClass('activeView'); 2792 }); 2793 2794 $('#mapView').on('show.bs.collapse', function () { 2795 $('.shopList__results__sort').addClass('d-none'); 2796 }); 2797 2798 $('#listView').on('show.bs.collapse', function () { 2799 $('.shopList__results__sort').removeClass('d-none'); 2800 }); 2801 2802 // filter change handle 2803 $('.shopList__filter__item__input').on('change', function () { 2804 var $parent = $(this).parents('.shopList__filter__group'); 2805 var $all = $parent.find('.shopList__filter__item__input[type="radio"]'); 2806 var isModal = $(this).parents('.shopList__filter.show').length > 0; 2807 var isAll = $(this).attr('type') == 'radio'; 2808 var $checkbox; 2809 var $checked; 2810 var text = $('label[for="' + $(this).attr('id') + '"] .shopList__filter__item__display').text(); 2811 if ($all.length > 0) { 2812 $checked = $parent.find('.shopList__filter__item__input[type="checkbox"]:checked'); 2813 $checkbox = $parent.find('.shopList__filter__item__input[type="checkbox"]'); 2814 if (isAll) { 2815 if (this.checked) { 2816 $checked.each(function () { 2817 if (isModal) 2818 this.checked = false;
2819 else 2820 filtersUpdate(false, this.value, $(this).attr('name')); 2821 }); 2822 } 2823 } else { 2824 if (this.checked) { 2825 if ($checked.length == $checkbox.length && $(this).attr('name') !== 'Features') { 2826 $all[0].checked = true; 2827 2828 $checked.each(function () { 2829 if (isModal) 2830 this.checked = false; 2831 else 2832 filtersUpdate(false, this.value, $(this).attr('name')); 2833 }); 2834 } else { 2835 $all[0].checked = false; 2836 if (!isModal) 2837 filtersUpdate(true, this.value, $(this).attr('name'), text); 2838 } 2839 2840 } else { 2841 if ($checked.length == 0) { 2842 $all[0].checked = true; 2843 2844 $checked.each(function () { 2845 if (isModal) 2846 this.checked = false; 2847 else 2848 filtersUpdate(false, this.value, $(this).attr('name')); 2849 }); 2850 } 2851 if (!isModal) 2852 filtersUpdate(false, this.value, $(this).attr('name')); 2853 } 2854 } 2855 } else if (!isModal) { 2856 if (this.checked) { 2857 filtersUpdate(true, this.value, $(this).attr('name'), text); 2858 } else { 2859 filtersUpdate(false, this.value, $(this).attr('name')); 2860 } 2861 } 2862 2863 if (!isModal) { 2864 reBuildList(); 2865 } 2866 }); 2867 2868 // text input 2869 var inputTimer = null; 2870 $('#shopsSearch').on('keyup', function (event) { 2871 var _searchMinLength = location.href.search('/en/') != -1 ? 2 : 0; 2872 if (inputTimer != null) { 2873 clearTimeout(inputTimer); 2874 } 2875 if (event.key != 'Enter') { 2876 inputTimer = setTimeout(function () { 2877 if ((params.search && params.search != "" && params.search != $('#shopsSearch').val()) || $('#shopsSearch').val().length > _searchMinLength) { 2878 params.search = $('#shopsSearch').val(); 2879 textSearch(); 2880 2881 reBuildList(); 2882 } 2883 }, 400); 2884 } else { 2885 params.search = $('#shopsSearch').val(); 2886 textSearch(); 2887 2888 reBuildList(); 2889 } 2890 }).on('change', function (event) { 2891 if (inputTimer != null) { 2892 clearTimeout(inputTimer); 2893 } 2894 if (params.search != this.value) { 2895 params.search = this.value; 2896 textSearch(); 2897 2898 reBuildList(); 2899 } 2900 }); 2901 $('#shopsSearchBtn').on('click', function () { 2902 params.search = $('#shopsSearch').val(); 2903 textSearch(); 2904 2905 reBuildList(); 2906 }); 2907 2908 $('.shopList__badges').on('badgeRemove', function (event) { 2909 filtersUpdate(false, $(event.target).attr('data-bs-value'), $(event.target).attr('data-bs-name')); 2910 reBuildList(); 2911 }); 2912 2913 // close filter modal when resize 2914 $(window).on('resize', function () { 2915 console.log($(window).width(), windowWidth); 2916 if ($(window).width() != windowWidth) { 2917 windowWidth = $(window).width(); 2918 if ($('.shopList__filter.show').length > 0) { 2919 $('.shopList__filter').modal('hide'); 2920 } 2921 } 2922 }); 2923 $('.shopList__filter').on('hidden.bs.modal', function (e) { 2924 resetFilter(); 2925 $(this).attr('style', ''); 2926 }).on('shown.shown.bs.modal', function () { windowWidth = $(window).width(); }); 2927 2928 // filters submit 2929 $('.shopList__filter__submit').on('click', function (e) { 2930 e.preventDefault(); 2931 if ($('.shopList__filter.show').length > 0) { 2932 $('.shopList__filter__item__input[type="checkbox"]').each(function () { 2933 filtersUpdate(this.checked, this.value, $(this).attr('name'), $('label[for="' + $(this).attr('id') + '"] .shopList__filter__item__display').text()); 2934 }); 2935 if (!$(this).is('.activeView')) { 2936 $('.activeView').removeClass('activeView'); 2937 $(this).addClass('activeView'); 2938 $('#' + $(this).attr('data-bs-view')).collapse('show'); 2939 } 2940 $('.shopList__filter').modal('hide'); 2941 reBuildList(); 2942 } 2943 }); 2944
2945 // Only displays selected floors in map view 2946 $("#filterFloor .shopList__filter__item__input").on('click', function (e) { 2947 $('ul.tabs__wrapper li.tabs__item').each(function () { 2948 $(this).show(); 2949 }); 2950 2951 $('.map__control__btn--floor').each(function () { 2952 $(this).show(); 2953 }); 2954 2955 var selectedFloors = $("#filterFloor .shopList__filter__item__input:checked"); 2956 if (selectedFloors.length > 0) { 2957 if ($('#filterFloor .shopList__filter__groupitem').length > 0) { 2958 var phases = $.unique($.map(selectedFloors, function (floor) { 2959 return $(floor).closest('.shopList__filter__groupitem').attr('tabid'); 2960 })); 2961 2962 if (phases.length > 0) { 2963 $('ul.tabs__wrapper li.tabs__item').each(function () { 2964 var tabId = $(this).children('.tabs__item__btn').attr('id'); 2965 if ($.inArray(tabId, phases) === -1) { 2966 $(this).hide(); 2967 } 2968 }); 2969 } 2970 } 2971 2972 var floors = $.map(selectedFloors, function (floor) { 2973 return floor.value; 2974 }); 2975 2976 $('.map__control__btn--floor').each(function () { 2977 if ($.inArray($(this).attr('data-bs-value'), floors) === -1) { 2978 if ($(this).hasClass('active')) { 2979 $(this).removeClass('active'); 2980 } 2981 $(this).hide(); 2982 } 2983 }); 2984 } 2985 2986 if ($('ul.tabs__wrapper li.tabs__item').length > 0 && $('ul.tabs__wrapper li.tabs__item .tabs__item__btn:visible[aria-expanded="true"]').length !== 1) { 2987 $('ul.tabs__wrapper li.tabs__item .tabs__item__btn:visible').first().click(); 2988 } 2989 2990 if ($('.map__control__btn--floor.active:visible').length !== 1) { 2991 $('.map__control__btn--floor:visible').first().click(); 2992 } 2993 }); 2994 2995 window.displayList = window.currentShopsList.map(function (item) { return item }); 2996 var $ele; 2997 if (params.filters.length != 0 || params.search != '' || params.sort != 'asc') { 2998 if (params.sort == 'desc') { 2999 sort(); 3000 } 3001 3002 if (params.search != '') 3003 textSearch(); 3004 3005 if (params.filters.length) { 3006 for (var i = 0; i < params.filters.length; i++) { 3007 $ele = $('.shopList__filter__item__input[type="checkbox"][value="' + params.filters[i] + '"]'); 3008 if ($ele.length > 0) { 3009 $ele[0].checked = true; 3010 $ele.trigger('change'); 3011 } 3012 } 3013 } 3014 3015 reBuildList(); 3016 } else { 3017 textSearch(); 3018 reBuildList(); 3019 } 3020 3021 // show map view resize floor plan 3022 $('#mapView').on('shown.bs.collapse', function () { 3023 var map; 3024 if ($(this).find('.map__wrapper').length > 0) { 3025 map = $(this).find('.map__wrapper')[0].map; 3026 if (map) { 3027 map.panTo([0, 0]); 3028 map.invalidateSize(); 3029 $('.map__pin.focus').click() 3030 } 3031 } 3032 3033 // preselect first floor button 3034 if ($('.tabs__collapse.collapse.show .map__control__btn--floor').length > 0) { 3035 if ($('.tabs__collapse.collapse.show .map__control__btn--floor.active:visible').length === 0) { 3036 $('.tabs__collapse.collapse.show .map__control__btn--floor:visible').first().click(); 3037 } else if ($('.tabs__collapse.collapse.show .map__control__btn--floor')) { 3038 $('.tabs__collapse.collapse.show .map__control__btn--floor.active:visible').click(); 3039 } 3040 } else { 3041 if ($('.map__control__btn--floor.active:visible').length === 0) { 3042 $('.map__control__btn--floor:visible').first().click(); 3043 } 3044 } 3045 }); 3046 3047 if (params.view == 'map') { 3048 // map view 3049 $('#mapView').collapse('show'); 3050 } else { 3051 shopListInit(); 3052 } 3053 } 3054 3055 } 3056 3057 //To get Json from API and init the view model 3058 $.getJSON("/" + getCurrentLanguage() + "/api/v1/" + getAPIcontroller() + "/shops", function (data) { 3059 window.fullShopsList = data.fullShops; 3060 window.currentShopsList = data.shops; 3061 initShopsListingComponent(); 3062 }); 3063 3064 function getCurrentLanguage() { 3065 var url = window.location.pathname; 3066 var tokenizedUrlPart = url.split('/'); 3067 return tokenizedUrlPart[1]; 3068 } 3069 3070 //To get the related API controller 3071 function getAPIcontroller() { 3072 var url = window.location.pathname; 3073 var tokenizedUrlPart = url.split('/'); 3074 var CurrentShopType = tokenizedUrlPart[2]; 3075 var APIcontroller; 3076 if (CurrentShopType == 'shops') { 3077 APIcontroller = 'ShopsListing'; 3078 } else if (CurrentShopType == 'dining') { 3079 APIcontroller = 'DiningListing'; 3080 }; 3081 return APIcontroller; 3082 } 3083 3084}); 3085 3086$(document).ready(function () { 3087 var splideList = document.getElementsByClassName('splide'); 3088 Array.from(splideList).forEach(element => { 3089 const slideCount = element.querySelectorAll('.splide__slide').length; 3090 new Splide(element, { 3091 type : 'fade', 3092 rewind : true, 3093 pagination : true, 3094 autoplay : false, 3095 interval : 2000, 3096 arrows : slideCount > 1, 3097 }).mount(); 3098 }); 3099 $('.my-slick-slider').slick({ 3100 dots: true, 3101 infinite: true, 3102 slidesToShow: 1, 3103 slidesToScroll: 1, 3104 arrows: true, 3105 prevArrow: '<button type="button" class="slick-prev"><</button>', 3106 nextArrow: '<button type="button" class="slick-next">></button>', 3107 adaptiveHeight: true, 3108 fade: true, 3109 }); 3110 3111 $('.slider .video').on('videoReady', function (event) { 3112 var _$player = $(event.target).parents('.video'); 3113 if (_$player.parents('.slick-active').length === 0) { 3114 stopVideo(_$player[0]); 3115 } 3116 }); 3117 window.checkYTVideoSilder = function ($target) { 3118 if ($('.slider .video--youtube').length > 0) { 3119 var _$player = $target.parents('.video'); 3120 if (_$player.parents('.slick-active').length === 0) { 3121 stopVideo(_$player[0]); 3122 } else { 3123 playVideo(_$player[0]); 3124 } 3125 } 3126 } 3127 $('.slider__wrapper') 3128 .on('init', function (event) { 3129 $(event.target).find('.slick-slide').removeClass('animate'); 3130 $(event.target).find('.slick-active').addClass('animate'); 3131 }) 3132 .on('afterChange', function (event) { 3133 var _$slides = $(event.target).find('.video'); 3134 $(event.target).find('.slick-slide').removeClass('animate'); 3135 $(event.target).find('.slick-active').addClass('animate'); 3136 3137 for (var i = 0; i < _$slides.length; i++) { 3138 if (_$slides.eq(i).parents('.slick-active').length > 0) { 3139 playVideo(_$slides[i]); 3140 } else { 3141 stopVideo(_$slides[i]); 3142 _$slides.eq(i).find('.vjs-poster').css({ display: '' }); 3143 } 3144 } 3145 }) 3146 .on('mouseenter', function (event) { 3147 if ($(this).find('.slick-cloned.d-none').length == 0) { 3148 $(this).slick('slickPause'); 3149 } 3150 }) 3151 .on('mouseleave', function (event) { 3152 if ($(this).find('.slick-cloned.d-none').length == 0) { 3153 $(this).slick('slickPlay'); 3154 } 3155 }) 3156 .on('focusin', function (event) { 3157 if ($(this).find('.slick-cloned.d-none').length == 0) { 3158 $(this).slick('slickPause'); 3159 } 3160 }) 3161 .on('focusout', function (event) { 3162 if ($(this).find('.slick-cloned.d-none').length == 0) { 3163 $(this).slick('slickPlay'); 3164 } 3165 }); 3166 $('.slider__wrapper').each(function () { 3167 if ($(this).parents('.slider--card').length > 0) { 3168 $(this).on('init reInit afterChange', function(event, slick, currentSlide){ 3169 //currentSlide is undefined on init -- set it to 0 in this case (currentSlide is 0 based) 3170 var currentIndex = (currentSlide ? currentSlide : 0); 3171 var slidesPerPage; 3172 if (window.matchMedia('(max-width: 576px)').matches) { 3173 slidesPerPage = 1; 3174 } else if (window.matchMedia('(max-width: 769px)').matches) { 3175 slidesPerPage = 2; 3176 } else { 3177 slidesPerPage = 3; 3178 } 3179 console.log(slick); 3180 var totalPages = slick.$dots ? slick.$dots[0].children.length : 1; // slick.slideCount 3181 var index = Math.floor(currentIndex / slidesPerPage) + 1; 3182 var totalSlides = slick.$slides.length; 3183 var totalShopCard = $(this).find('div.slick-slide div.card').length; 3184 3185 $('#slickPaging').text(index + ' / ' + totalPages); 3186 3187 $(this).parents('.slider--card').removeClass('singleCard singlePage firstPage lastPage'); 3188 3189 if (index == 1) { 3190 $(this).parents('.slider--card').addClass('firstPage'); 3191 } 3192 if (index == totalPages) { 3193 $(this).parents('.slider--card').addClass('lastPage'); 3194 } 3195 if (totalPages == 1) { 3196 $(this).parents('.slider--card').addClass('singlePage'); 3197 } 3198 if (totalShopCard == 1) { 3199 $(this).parents('.slider--card').addClass('singleCard'); 3200 } 3201 3202 // console.log("Total slides: " + totalSlides + " Total Cards: " + totalShopCard); 3203 if (totalShopCard > 1) { 3204 var slidesToAdd; 3205 if (slidesPerPage == 1 || totalShopCard % slidesPerPage == 0) { 3206 slidesToAdd = 0; 3207 } else { 3208 slidesToAdd = slidesPerPage - (totalShopCard % slidesPerPage); 3209 } 3210 // console.log(slidesToAdd); 3211 var netChange = slidesToAdd - (totalSlides - totalShopCard); 3212 // console.log("Net Change: " + netChange); 3213 if (netChange < 0) { 3214 slick.slickRemove(totalSlides - 1); 3215 } 3216 if (netChange > 0) { 3217 slick.slickAdd('<div class="emptyCard"><div>'); 3218 } 3219 } 3220 }); 3221 $(this).slick({ 3222 // fade: $(this).attr('data-bs-variable-width') != 'true', 3223 // draggable: $(this).attr('data-bs-draggable') != 'false', 3224 // swipe: $(this).attr('data-bs-draggable') != 'false', 3225 dots: $(this).find('> *').length > 1 && $(this).attr('data-bs-without-dots') != 'true', 3226 arrows: $(this).attr('data-bs-arrows') ? true : false, 3227 infinite: $(this).attr('data-bs-infinite') != 'false' ? true : false, 3228 prevArrow: $(this).parent('.slider').find('.slick-prev'), 3229 nextArrow: $(this).parent('.slider').find('.slick-next'), 3230 // autoplay: $(this).attr('data-bs-speed') !== '0', 3231 // autoplay: false, 3232 autoplay: true, 3233 variableWidth: false, 3234 // autoplaySpeed: $(this).attr('data-bs-speed') && $(this).attr('data-bs-speed') > 0 ? parseInt($(ele).attr('data-bs-speed')) : 6000, 3235 slidesToShow: 3, 3236 slidesToScroll: 3, 3237 responsive: [ 3238 { 3239 breakpoint: 769, 3240 settings: { 3241 arrows: true, 3242 slidesToShow: 2, 3243 slidesToScroll: 2 3244 } 3245 }, 3246 { 3247 breakpoint: 576, 3248 settings: { 3249 arrows: true, 3250 slidesToShow: 1, 3251 slidesToScroll: 1 3252 } 3253 } 3254 ] 3255 }); 3256 $(this).slick('slickPause'); 3257 } else if ($(this).parents('.slider--article__preview').length > 0) { 3258 $(this).on('init reInit afterChange', function(event, slick, currentSlide){ 3259 if(slick.$slides.length === 1){ 3260 const $list = $(slick.$list[0]); 3261 $list.addClass('slick-list--single'); 3262 } 3263 }); 3264 3265 $(this).slick({ 3266 pauseOnFocus: false, 3267 pauseOnHover: false, 3268 pauseOnDotsHover: false, 3269 fade: false, 3270 draggable: $(this).attr('data-bs-draggable') != 'false', 3271 swipe: $(this).attr('data-bs-draggable') != 'false', 3272 dots: $(this).find('> *').length > 1 && $(this).attr('data-bs-without-dots') != 'true', 3273 arrows: $(this).attr('data-bs-arrows') ? true : false, 3274 infinite: $(this).attr('data-bs-infinite') != 'false' ? true : false, 3275 prevArrow: $(this).parent('.slider').find('.slick-prev'), 3276 nextArrow: $(this).parent('.slider').find('.slick-next'), 3277 autoplay: $(this).attr('data-bs-speed') !== '0', 3278 variableWidth: $(this).attr('data-bs-variable-width') == 'true', 3279 autoplaySpeed: $(this).attr('data-bs-speed') && $(this).attr('data-bs-speed') > 0 ? parseInt($(ele).attr('data-bs-speed')) : 6000, 3280 // slidesToShow: 1.2, 3281 // centerMode: true, 3282 // centerPadding: '8%', 3283 }); 3284 } else { 3285 $(this).slick({ 3286 pauseOnFocus: false, 3287 pauseOnHover: false, 3288 pauseOnDotsHover: false, 3289 fade: $(this).attr('data-bs-variable-width') != 'true', 3290 draggable: $(this).attr('data-bs-draggable') != 'false', 3291 swipe: $(this).attr('data-bs-draggable') != 'false', 3292 dots: $(this).find('> *').length > 1 && $(this).attr('data-bs-without-dots') != 'true', 3293 arrows: $(this).attr('data-bs-arrows') ? true : false, 3294 infinite: $(this).attr('data-bs-infinite') != 'false' ? true : false, 3295 prevArrow: $(this).parent('.slider').find('.slick-prev'), 3296 nextArrow: $(this).parent('.slider').find('.slick-next'), 3297 autoplay: $(this).attr('data-bs-speed') !== '0', 3298 variableWidth: $(this).attr('data-bs-variable-width') == 'true', 3299 autoplaySpeed: $(this).attr('data-bs-speed') && $(this).attr('data-bs-speed') > 0 ? parseInt($(ele).attr('data-bs-speed')) : 6000 3300 }); 3301 } 3302 if ($(this).parents('.slider--card').length > 0 || $(this).parents('.slider--coaches').length > 0) { 3303 checkCardsDisplay($(this)); 3304 } 3305 }); 3306 function checkCardsDisplay($ele) { 3307 $ele.slick('slickPause'); 3308 var slides = $ele.slick('getSlick').slideCount; 3309 3310 if ($ele.parents('.slider--card').length == 0) { 3311 if ($ele.width() > $ele.find('.slick-current').width() * slides) { 3312 $ele.find('.slick-cloned').addClass('d-none'); 3313 $ele.find('.slick-dots').addClass('d-none'); 3314
3314 $ele.slick('slickSetOption', { 3315 draggable: false, 3316 swipe: false 3317 }); 3318 $ele.slick('slickGoTo', 0); 3319 } else { 3320 $ele.find('.slick-cloned').removeClass('d-none'); 3321 $ele.find('.slick-dots').removeClass('d-none'); 3322 $ele.slick('slickSetOption', { 3323 draggable: true, 3324 swipe: true 3325 }); 3326 $ele.slick('slickPlay'); 3327 } 3328 } else { 3329 $ele.slick('slickPlay'); 3330 } 3331 } 3332 3333 window.addEventListener('resize', function () { 3334 $('.slider--card .slider__wrapper, .slider--coaches .slider__wrapper').each(function () { 3335 checkCardsDisplay($(this)); 3336 }); 3337 }); 3338 3339 if (window.mobileAndTabletCheck()) { 3340 window.addEventListener('blur', function () { 3341 $('.slick-active .video').each(function () { 3342 stopVideo(this); 3343 $(this).find('.vjs-poster').css({ display: '' }); 3344 }); 3345 }); 3346 3347 window.addEventListener('focus', function () { 3348 $('.slick-active .video').each(function () { 3349 playVideo(this); 3350 }); 3351 $('.slider__wrapper').each(function () { 3352 if ($(this).find('.slick-cloned.d-none').length == 0) { 3353 $(this).slick('slickPlay'); 3354 } 3355 }); 3356 }); 3357 } 3358}); 3359$(document).ready(function () { 3360 $('.socialMedia--copy').on('click', function () { 3361 if ($(this).attr('data-bs-copy')) { 3362 $('body').append('<input id="copyText" type="text" value="' + $(this).attr('data-bs-copy') + '" class="" />'); 3363 3364 var copyText = document.getElementById('copyText'); 3365 var modalId = $(this).attr('data-bs-modal-id'); 3366 copyText.select(); 3367 copyText.setSelectionRange(0, 99999); 3368 document.execCommand('copy'); 3369 $.when($(copyText).remove()).then(function () { 3370 if (modalId && modalId != '') { 3371 $('#' + modalId).modal('show'); 3372 } 3373 }); 3374 } 3375 }); 3376}); 3377$(document).ready(function () { 3378 // view change handle 3379 $('.tabs__collapse').on('hide.bs.collapse', function () { 3380 $('#' + $(this).attr('aria-labelledby')).removeAttr('disabled'); 3381 }).on('show.bs.collapse', function () { 3382 $('.tabsDropdown__select option[value="' + $(this).attr('id') + '"]').parent().val($(this).attr('id')); 3383 $('#' + $(this).attr('aria-labelledby')).attr('disabled', true); 3384 }); 3385 $('.tabsDropdown__select').on('change', function () { 3386 if ($(this).val() && $(this).val() != '') { 3387 $('#' + $(this).val()).collapse('show'); 3388 } 3389 }); 3390}); 3391$(document).ready(function () { 3392 $('[data-bs-toggle="tooltip"]').tooltip(); 3393}); 3394 3395var tag = document.createElement('script'); 3396 3397tag.src = "https://www.youtube.com/iframe_api"; 3398var firstScriptTag = document.getElementsByTagName('script')[0]; 3399firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); 3400 3401function playVideo(player) { 3402 var _options; 3403 if (player) { 3404 if (player.ytPlayer) { 3405 if (player.player) { 3406 _options = player.player.tech_.options(); 3407 } 3408 if (_options.muted && typeof player.ytPlayer.mute === 'function') { 3409 player.ytPlayer.mute(); 3410 } else if (typeof player.ytPlayer.unMute === 'function') { 3411 player.ytPlayer.unMute(); 3412 } 3413 if (typeof player.ytPlayer.playVideo === 'function') 3414 player.ytPlayer.playVideo(); 3415 } else if (player.player) { 3416 if (player.player.error_ == null || !player.player.error_) { 3417 if (typeof player.player.play === 'function') 3418 player.player.play(); 3419 } 3420 } 3421 } 3422} 3423function stopVideo(player) { 3424 if (player) { 3425 if (player.ytPlayer) { 3426 if (typeof player.ytPlayer.stopVideo === 'function') 3427 player.ytPlayer.stopVideo(); 3428 } else if (player.player && !$(player).is('.video--youtube')) { 3429 if (player.player.error_ == null || !player.player.error_) { 3430 if (typeof player.player.pause === 'function') 3431 player.player.pause(); 3432 if (typeof player.player.currentTime === 'function') 3433 player.player.currentTime(0); 3434 } 3435 } 3436 } 3437} 3438 3439function onYouTubeIframeAPIReady() { 3440 var video = $('.video-js'); 3441 3442 if (video.length > 0) { 3443 for (var i = 0; i < video.length; i++) { 3444 if (video.eq(i).is('.video--youtube')) { 3445 video[i].player = videojs(video[i], {}, function () { 3446 var _id = this.id(); 3447 var _options = this.tech_.options(); 3448 var _$player = $('#' + _id); 3449 var _$video = $('#' + _id + '_html5_api'); 3450 _$player.find('.vjs-poster, .vjs-big-play-button').css({ display: 'none' }); 3451 3452 if (_$video.length > 0 && _$player.attr('data-bs-src')) { 3453 if (!this.options().controls) { 3454 _$player.append('<div class="video__mask"></div>'); 3455 } 3456 3457 _$player[0].ytPlayer = new YT.Player(_id + '_html5_api', { 3458 videoId: _$player.attr('data-bs-src'), 3459 playerVars: { 3460 'autoplay': _options.autoplay === true ? 1 : 0, 3461 'mute': _options.muted === true ? 1 : 0, 3462 'controls': this.options().controls === true ? 1 : 0, 3463 'autohide': 1, 3464 'showinfo': 0, 3465 'wmode': 'opaque', 3466 'rel': 0, 3467 'disablekb': 1, 3468 'loop': _options.loop === true ? 1 : 0, 3469 'playsinline': 1 3470 }, 3471 events: { 3472 'onReady': function (event) { 3473 $(event.target.getIframe()).trigger('videoReady'); 3474 checkYTVideoSilder($(event.target.getIframe())); 3475 }, 3476 'onStateChange': function (event) { 3477 var _playerEle = $(event.target.f).parents('.video'); 3478 if (_playerEle.length > 0) { 3479 var _videoOptions = _playerEle[0].player.tech_.options(); 3480 3481 switch (event.data) { 3482 case 0: 3483 case YT.PlayerState.ENDED: 3484 // console.log('end'); 3485 if (_videoOptions.loop) { 3486 event.target.playVideo(); 3487 } else 3488 event.target.stopVideo(); 3489 break; 3490 case 1: 3491 case YT.PlayerState.PLAYER: 3492 _$player.find('.vjs-poster, .vjs-big-play-button').css({ display: 'none' }); 3493 break; 3494 case 2: 3495 case YT.PlayerState.PAUSED: 3496 // console.log(event.target); 3497 break; 3498 default: 3499 break; 3500 } 3501 } 3502 } 3503 } 3504 }); 3505 } 3506 }); 3507 } else { 3508 videojs(video[i]).ready(function () { 3509 $('#' + this.id())[0].player = this; 3510 $('#' + this.id() + '_html5_api').trigger('videoReady'); 3511 }); 3512 } 3513 } 3514 } 3515}
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.