1 2/*============================== 3 Maps 4 ==============================*/ 5var map; 6var markers = []; 7 8 9function initMap() { 10 // Check if map exist 11 if (document.getElementById('map')) { 12 13 // Google map Styles 14 var customMapType = new google.maps.StyledMapType([{ 15 "featureType": "all", 16 "elementType": "all", 17 "stylers": [{ 18 "hue": "#ffc700" 19 }] 20 }], { 21 name: 'Custom Style' 22 }); 23 var customMapTypeId = 'custom_style'; 24 25 if ( $('#map').data('location') ) { 26 var arr_location = $('#map').data('location').split(','); 27 lat = parseFloat(arr_location[0]); 28 lng = parseFloat(arr_location[1]); 29 zoom = 10 30 startMap(); 31 32 } else if ( $('#map').data('bloglocation') ) { 33 34 geocoder = new google.maps.Geocoder(); 35 function codeAddress() { 36 //In this case it gets the address from an element on the page, but obviously you could just pass it to the method instead 37 var address = $('#map').data('bloglocation'); 38 geocoder.geocode( { 'address' : address }, function( results, status ) { 39 if( status == google.maps.GeocoderStatus.OK ) { 40 lat = results[0].geometry.location.lat(); 41 lng = results[0].geometry.location.lng(); 42 zoom = 12; 43 startMap(); 44 } else { 45 alert( 'Geocode was not successful for the following reason: ' + status ); 46 } 47 } ); 48 } 49 codeAddress(); 50 51 } else { 52 lat = 52.528755; 53 lng = -1.560059; 54 zoom = 6 55 //console.log(lat, lng); 56 startMap(); 57 } 58 59 function startMap() { 60 61 map = new google.maps.Map(document.getElementById('map'), { 62 center: { 63 lat: lat, 64 lng: lng 65 }, 66 zoom: zoom, 67 mapTypeControl: false 68 }); 69 70 71 if ( $('#map').data('location') || $('#map').data('bloglocation') ) { 72 var image = '/images/Icons/hph-main-icon.png'; 73 74 var center_marker = new google.maps.Marker({ 75 position: {lat: lat, lng: lng}, 76 map: map, 77 icon: image, 78 }); 79 } 80 81 82 var map_list_wpr = $('.map-list'); 83 var map_list = map_list_wpr.find("li span"); 84 85 var image = '/images/Icons/hph-hotspot-dot.png'; 86 87 $.each(map_list, function(index, value) { 88 89 var data = $(value).data("map"); 90 91 var lat = parseFloat(data.lat); 92 var long = parseFloat(data.long); 93 94 var marker = new google.maps.Marker({ 95 position: { 96 lat: lat, 97 lng: long 98 }, 99 map: map, 100 icon: image 101 }); 102 103 google.maps.event.addListener(marker, "click", function() { 104 map.panTo(marker.getPosition()); 105 map.panBy(0, -200); 106 if ($(".map-custom-window").hasClass('visible')) { 107 $(".map-custom-window").removeClass('visible'); 108 } 109 $('#' + data.hotel).addClass('visible'); 110 111 }); 112 113 markers.push(marker); 114 115 }); 116 117 map.mapTypes.set(customMapTypeId, customMapType); 118 map.setMapTypeId(customMapTypeId); 119 120 custom_map_windows = (function() { 121 122 // Cash 123 var map_list_wpr = $('.map-list'); 124 var map_list = map_list_wpr.find("li span"); 125 126 map_list.each(function(i) { 127 $(this).on({ 128 click: function(e) { 129 var data = $(this).data("map"); 130 e.stopPropagation(); 131 map.panTo(markers[i].getPosition()); 132 map.panBy(0, -200); 133 google.maps.event.trigger(markers[i], 'click'); 134 } 135 }); 136 }); 137 138 //close facility 139 $(".map-custom-window .close").on('click', function() { 140 $('.map-custom-window').removeClass('visible'); 141 }) 142 143 })(); 144 145 } 146 147 } else if (document.getElementById('maps-direction')) { 148 149 var origin_place_id = null; 150 var destination_place_id = null; 151 var travel_mode = google.maps.TravelMode.DRIVING; 152 var dest = $('#maps-direction').data('dest'); 153 var arr_location = dest.split(','); 154 var lat = parseFloat(arr_location[0]); 155 var lng = parseFloat(arr_location[1]); 156 //console.log(dest); 157 var map = new google.maps.Map(document.getElementById('maps-direction'), { 158 center: { 159 lat: lat, 160 lng: lng 161 }, 162 zoom: 14, 163 mapTypeControl: false 164 }); 165 var directionsService = new google.maps.DirectionsService; 166 var directionsDisplay = new google.maps.DirectionsRenderer({ 167 suppressMarkers: true, 168 panel: document.getElementById('directions') 169 });
170 directionsDisplay.setMap(map); 171 172 var origin_input = document.getElementById('origin-input'); 173 174 map.controls[google.maps.ControlPosition.TOP_LEFT].push(origin_input); 175 176 var origin_autocomplete = new google.maps.places.Autocomplete(origin_input); 177 origin_autocomplete.bindTo('bounds', map); 178 179 function expandViewportToFitPlace(map, place) { 180 if (place.geometry.viewport) { 181 map.fitBounds(place.geometry.viewport); 182 } else { 183 map.setCenter(place.geometry.location); 184 map.setZoom(17); 185 } 186 $('#directions').show(); 187 } 188 189 190 origin_autocomplete.addListener('place_changed', function() { 191 var place = origin_autocomplete.getPlace(); 192 193 if (!place.geometry) { 194 195 var address = origin_input.value; 196 var geocoder = new google.maps.Geocoder(); 197 geocoder.geocode({'address': address}, function(results, status) { 198 if (status === google.maps.GeocoderStatus.OK) { 199 place = results[0]; 200 expandViewportToFitPlace(map, place); 201 202 203 204 // If the place has a geometry, store its place ID and route if we have 205 // the other place ID 206 origin_place_id = place.place_id; 207 route(origin_place_id, destination_place_id, travel_mode, 208 directionsService, directionsDisplay); 209 210 } else { 211 alert('Geocode was not successful for the following reason: ' + status); 212 } 213 }); 214 return; 215 } 216 217 expandViewportToFitPlace(map, place); 218 219 // If the place has a geometry, store its place ID and route if we have 220 // the other place ID 221 origin_place_id = place.place_id; 222 route(origin_place_id, destination_place_id, travel_mode, 223 directionsService, directionsDisplay); 224 }); 225 226 function route(origin_place_id, destination_place_id, travel_mode, 227 directionsService, directionsDisplay) { 228 229 directionsService.route({ 230 origin: { 231 'placeId': origin_place_id 232 }, 233 destination: dest, 234 travelMode: travel_mode 235 }, function(response, status) { 236 if (status === google.maps.DirectionsStatus.OK) { 237 directionsDisplay.setDirections(response); 238 } else { 239 window.alert('Directions request failed due to ' + status); 240 } 241 }); 242 } 243 244 var geocoder = new google.maps.Geocoder(); 245 var image = '/images/Icons/hph-main-icon.png'; 246 247 function geocodeAddress(geocoder, resultsMap) { 248 var address = dest; 249 var arr_location = dest.split(','); 250 var lat = parseFloat(arr_location[0]); 251 var lng = parseFloat(arr_location[1]); 252 geocoder.geocode({ 253 'address': address 254 }, function(results, status) { 255 if (status === google.maps.GeocoderStatus.OK) { 256 resultsMap.setCenter(results[0].geometry.location); 257 //console.log(results[0]); 258 var marker = new google.maps.Marker({ 259 map: resultsMap, 260 position: { 261 lat: lat, 262 lng: lng 263 }, 264 icon: image 265 }); 266 } else { 267 alert('Geocode was not successful for the following reason: ' + status); 268 } 269 }); 270 } 271 272 geocodeAddress(geocoder, map); 273 274 } // end if 275 276} 277 278//Responsive Image Map: 279$(document).ready(function(){ 280 /*=========================== 281 Area map 282 =============================*/ 283 /* responsive map coords*/ 284 $('img[usemap]').rwdImageMaps(); 285}); 286 287$(document).ready(function() { 288 /** ============================================= 289 Toggle dropdown mobile 290 =============================================*/ 291 if($(".main-nav").length > 0 || $(".our-services .nav").length > 0){ 292 //duplicate the level 0 link into childcontent-inner-wrap 293 $(".main-nav .nav > li > a, .our-services .nav > li > a").each(function(){ 294 var $dest = $(this).siblings(".dropdown-wrp").first(); 295 if($dest.length > 0){ 296 $(this).addClass("has-children"); 297 var $destination = $dest; 298 var intHomeLink = $(this).text().indexOf('Home'); 299 if(intHomeLink > -1){ 300 $(this).clone().removeClass("active").addClass("clone-link").addClass("home-link").prependTo($destination); 301 }else{ 302 $(this).clone().removeClass("active").addClass("clone-link").prependTo($destination); 303 } 304 } 305 }); 306 //click touch screens (mega menu top links) 307 $(".uk-touch .nav > li").on("click", " > a", function(e){ 308 var $this = $(this); 309 var $dest = $(this).siblings(".dropdown-wrp").first(); 310 if($dest.length > 0){ 311 e.preventDefault(); 312 313 //open close dropdown on touch screens 314 var $dropdown = $(this).siblings(".dropdown-wrp").first(); 315 316 if($dropdown.hasClass("open")){ 317 $dropdown.removeClass("open"); 318 $this.removeClass("up"); 319 }else{ 320 //$(".uk-touch li.mega.haschild .childcontent").removeClass("open"); 321 $dropdown.addClass("open"); 322 $this.addClass("up"); 323 } 324 325 // if($(this).hasClass("animate")){ 326 // $(this).removeClass("animate"); 327 // }else{ 328 // $(".uk-touch a.mega.haschild").removeClass("animate"); 329 // $(this).addClass("animate"); 330 // } 331 332 //checkDropdownOverlapping($(this), $dropdown); 333 } 334 335 }); 336 337 //toggle menu 338// $("#js-mainnav").on("click", ".megaMenuToggle", function(){ 339// var $content = $(this).siblings("#js-meganav").first(); 340// if($content.hasClass("active")){ 341// $content.removeClass("active"); 342// }else{ 343// $content.addClass("active"); 344// } 345// }); 346 } 347 348 /** ============================================= 349 Accordion with Velocity 350 =============================================*/ 351 /* Requires jquery.js and velocity.js */ 352 if($(".accordion-velocity").length > 0){ 353 var $accordion = $('.accordion-velocity'); 354 $accordion.find('.accordion-target').css({ display : 'none', overflow : 'hidden'}); 355 $accordion.find('.accordion-trigger').click(function() { 356 var $this = $(this); 357 $accordion = $this.closest(".accordion-velocity"); 358 var $targetContainer = $accordion.find('.accordion-target').first(); 359 var $targetDescription = $targetContainer.find('.accordion-description').first(); 360 var $triggerArrow = $accordion.find("i[data-velocity-arrow]").first(); 361 $accordion.find('.accordion-trigger').removeClass('active'); 362 $this.toggleClass('active'); 363 364 if(!$targetDescription.hasClass('active')) { 365 $targetContainer.css('display', 'block'); 366 $targetDescription.css('margin-top', -$targetDescription.height()); 367 $targetDescription.velocity({ marginTop: 0}, { duration: 350 }); 368 $targetDescription.addClass('active'); 369 370 //arrow 371 $triggerArrow.velocity({ 372 rotateZ: "180deg" 373 }); 374 } 375 else { 376 $targetDescription.velocity({ marginTop: -$targetDescription.height()}, { duration: 350 }); 377 $targetDescription.removeClass('active'); 378 //arrow 379 $triggerArrow.velocity({ 380 rotateZ: "0deg" 381 }); 382 } 383 return false;
384 }); 385 } 386 387 /*============================== 388 Slider 389 ==============================*/ 390 if ($('#back-to-top').length) { 391 var scrollTrigger = 100, // px 392 backToTop = function () { 393 var scrollTop = $(window).scrollTop(); 394 if (scrollTop > scrollTrigger) { 395 $('#back-to-top').addClass('show'); 396 } else { 397 $('#back-to-top').removeClass('show'); 398 } 399 }; 400 backToTop(); 401 $(window).on('scroll', function () { 402 backToTop(); 403 }); 404 $('#back-to-top').on('click', function (e) { 405 e.preventDefault(); 406 $('html,body').animate({ 407 scrollTop: 0 408 }, 700); 409 }); 410 } 411 412 413 /*============================== 414 Slider 415 ==============================*/ 416 $('.Slider').slick({ 417 dots: false, 418 infinite: true, 419 speed: 300, 420 slidesToShow: 1, 421 slidesToScroll: 1, 422 autoplay: true, 423 autoplaySpeed: 6000, 424 fade:true, 425 cssEase: "linear", 426 prevArrow: '<div class="slick-prev"></div>', 427 nextArrow: '<div class="slick-next"></div>' 428 }); 429 $('.slider-blog-post').slick({ 430 arrows:true, 431 dots: false, 432 infinite: true, 433 speed: 300, 434 slidesToShow: 1, 435 slidesToScroll: 1, 436 autoplay: true, 437 autoplaySpeed: 6000, 438 fade:true, 439 cssEase: "linear", 440 prevArrow: '<div class="slick-prev"></div>', 441 nextArrow: '<div class="slick-next"></div>' 442 }); 443 444 $('.small-slider').slick({ 445 dots: false, 446 infinite: true, 447 speed: 300, 448 fade: true, 449 slidesToShow: 1, 450 adaptiveHeight: true, 451 prevArrow: '<div class="prev"><i class="fa fa-angle-left" aria-hidden="true"></i> Previous</div>', 452 nextArrow: '<div class="next">Next <i class="fa fa-angle-right" aria-hidden="true"></i> </div>' 453 }); 454 $('.medium-slider').slick({ 455 dots: false, 456 infinite: true, 457 speed: 300, 458 fade: true, 459 slidesToShow: 1, 460 adaptiveHeight: true, 461 prevArrow: '<div class="prev"><i class="fa fa-angle-left" aria-hidden="true"></i> Previous</div>', 462 nextArrow: '<div class="next">Next <i class="fa fa-angle-right" aria-hidden="true"></i> </div>' 463 }); 464 465 466 $('.multiple-image-slider').slick({ 467 centerMode: true, 468 centerPadding: '200px', 469 slidesToShow: 3, 470// autoplay: true, 471// autoplaySpeed: 8000, 472 prevArrow: '<div class="slick-arrows slick-arrow-left"><div class="prev"><img class="prev-arrow" src="/img/carousel_arrow_left.jpg" /></div></div>', 473 nextArrow: '<div class="slick-arrows slick-arrow-right"><div class="next"><img class="next-arrow" src="/img/carousel_arrow_right.jpg" /></div></div>', 474 responsive: [ 475 { 476 breakpoint: 1900, 477 settings: { 478 arrows: true, 479 centerMode: true, 480 centerPadding: '150px', 481 slidesToShow: 3 482 } 483 }, 484 { 485 breakpoint: 1120, 486 settings: { 487 arrows: true, 488 centerMode: true, 489 centerPadding: '80px', 490 slidesToShow: 3 491 } 492 }, 493 { 494 breakpoint: 768, 495 settings: { 496 arrows: true, 497 centerMode: true, 498 centerPadding: '50px', 499 slidesToShow: 1 500 } 501 }, 502 { 503 breakpoint: 550, 504 settings: { 505 arrows: true, 506 centerMode: true, 507 centerPadding: '50px', 508 slidesToShow: 1 509 } 510 } 511 ] 512 }); 513 514 515 $('.offers-slider').matchHeight(); 516 517 518 /*============================== 519 Tabs 520 ==============================*/ 521 $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) { 522 initMap(); 523 }); 524 525 /*============================== 526 Tooltip 527 ==============================*/ 528 $("[data-toggle=tooltip]").tooltip(); 529 530 531 /*============================== 532 Chosen 533 ==============================*/ 534 $(".chzn-done").chosen(); 535 536 537 /*============================== 538 Mixer 539 ==============================*/ 540 541 if($("#mixer-container").length > 0){ 542 $('#mixer-container').mixItUp({ 543 animation: { 544 enable:false, //stefman 2016.07.18 deactivate 545 duration: 250, 546 effects: 'fade stagger(34ms) scale(0.61)', 547 easing: 'cubic-bezier(0.645, 0.045, 0.355, 1)' 548 }, 549 callbacks: { 550 onMixEnd: function(state) { 551 //col_Heights.col_Setup(); // Fix col Heights 552 $.each( $('.row'), function () { 553 if($(".row .card").length > 0){ 554 $targets = $(this).find('.card:not(.card-horizontal)'); 555 556 // Get an array of all element heights 557 var elementHeights = $targets.map(function() { 558 return $(this).height()+2; 559 }).get(); 560 //console.log(elementHeights); 561 // Math.max takes a variable number of arguments 562 // `apply` is equivalent to passing each height as an argument 563 var minHeight = Math.max.apply(null, elementHeights); 564 565 // Set each height to the max height 566 $targets.css('min-height', minHeight); 567 } 568 }); 569 } 570 } 571 }); 572 } 573 574 575 if($(".filter-items .filter").length > 0){ 576 var $filter = $('.filter-items').find('.filter:first-of-type') 577 $filter.trigger('click'); 578 var targetCol = $filter.data("filter"); 579 if(targetCol){ 580 $(targetCol).find('.card:not(.card-horizontal)').css('min-height', 0); 581 if($(window).width() > 769){ 582 //console.log("sp") 583 col_Setup(targetCol); 584 } 585 } 586 } 587 588 /*============================== 589 Filter mobile button 590 ==============================*/ 591 mobile_button = (function() { 592 593 // Cash 594 var $button = $('.mobile-button'); 595 var $wpr = $('.dropdown-mobile-wpr'); 596 597 // Setup 598 $('.switcher').each(function(index, value) { 599 var text = $(value).find('> ul:first-of-type li.active').text(); 600 $(value).find('.mobile-button span').html(text); 601 }); 602 603 // Functions 604 function change_text(element) { 605 parent = $(element).closest('.switcher'); 606 var text = $(element).text(); 607 $(parent).find('.mobile-button span').html(text); 608 $(parent).find('.dropdown-mobile').removeClass('open-dropdown'); 609 } 610 611 // Events 612 $button.click(function() { 613 var open = $(this).data("drop"); 614 $(open).toggleClass('open-dropdown'); 615 }); 616 617 $('.switcher > ul:first-of-type li, .switcher .dropdown-mobile li').click(function() { 618 change_text(this) 619 }); 620 621 function close() { 622 if ($('.open-dropdown').length) { 623 $('.open-dropdown').removeClass('open-dropdown'); 624 } 625 } 626 627 $(document).on('mouseup', close); 628 629 // Reset 630 $(window).resize(function() { 631 $('.dropdown-mobile').removeClass('open-dropdown'); 632 }); 633 634 635 })(); 636 637 $('.require-details').click(function() { 638 $("#require_details_download_button").attr("href", $(this).data("href")) 639 $("#require_details_brochure_name").val($(this).data("brochure-name")) 640 $("#require_details_hotel_code").val($(this).data("hotel-code")) 641 $("#require_details_brochure_id").val($(this).data("item-id")) 642 $("#require_details_popup").modal("show"); 643 }); 644 645 /*============================== 646 Gallery 647 ==============================*/ 648 // Initialize popup as usual 649 650 $('.gallery').each(function() { 651 $(this).magnificPopup({ 652 delegate: 'a', 653 type: 'image', 654 gallery: { 655 enabled: true 656 }, 657 658 zoom: { 659 enabled: true, // By default it's false, so don't forget to enable it 660 duration: 300, // duration of the effect, in milliseconds 661 easing: 'ease-in-out', // CSS transition easing function 662 // The "opener" function should return the element from which popup will be zoomed in 663 // and to which popup will be scaled down 664 // By defailt it looks for an image tag: 665 opener: function(openerElement) { 666 // openerElement is the element on which popup was initialized, in this case its <a> tag 667 // you don't need to add "opener" option if this code matches your needs, it's defailt one. 668 return openerElement.is('img') ? openerElement : openerElement.find('img'); 669 } 670 } 671 672 }); 673 }); 674 675 $("body").on("swiperight", ".mfp-img", function () { 676 $(".gallery").magnificPopup("prev"); 677 }); 678 $("body").on("swipeleft", ".mfp-img", function () { 679 $(".gallery").magnificPopup("next"); 680 }); 681 682 /*============================== 683 Gallery with Captions 684 ==============================*/ 685 // Initialize popup as usual 686 687 $('.gallery-captions').each(function() { 688 $(this).magnificPopup({ 689 delegate: 'a', 690 type: 'image', 691 gallery: { 692 enabled: true 693 }, 694 markup: '<div class="mfp-figure">'+ 695 '<div class="mfp-close"></div>'+ 696 '<div class="mfp-img"></div>'+ 697 '<div class="mfp-bottom-bar">'+ 698 '<div class="mfp-title"></div>'+ 699 '<div class="mfp-counter"></div>'+ 700 '</div>'+ 701 '</div>', 702 image: { 703 titleSrc: function(item) { 704 return item.el.attr('data-title') + '<small>' + item.el.attr('data-credit') + '</small>'; 705 } 706 }, 707 zoom: { 708 enabled: true, // By default it's false, so don't forget to enable it 709 duration: 300, // duration of the effect, in milliseconds 710 easing: 'ease-in-out', // CSS transition easing function 711 // The "opener" function should return the element from which popup will be zoomed in 712 // and to which popup will be scaled down 713 // By defailt it looks for an image tag: 714 opener: function(openerElement) { 715 // openerElement is the element on which popup was initialized, in this case its <a> tag 716 // you don't need to add "opener" option if this code matches your needs, it's defailt one. 717 return openerElement.is('img') ? openerElement : openerElement.find('img'); 718 } 719 } 720 721 }); 722 }); 723 724 $("body").on("swiperight", ".mfp-img", function () { 725 $(".gallery-captions").magnificPopup("prev"); 726 }); 727 $("body").on("swipeleft", ".mfp-img", function () { 728 $(".gallery-captions").magnificPopup("next"); 729 }); 730 731 732 /*============================== 733 Single Images 734 ==============================*/ 735 // Initialize popup as usual 736 $('.single-img').magnificPopup({ 737 delegate: 'a', 738 type: 'image', 739 gallery: { 740 enabled: false 741 }, 742 zoom: { 743 enabled: true, // By default it's false, so don't forget to enable it 744 duration: 300, // duration of the effect, in milliseconds 745 easing: 'ease-in-out', // CSS transition easing function 746 // The "opener" function should return the element from which popup will be zoomed in 747 // and to which popup will be scaled down 748 // By defailt it looks for an image tag: 749 opener: function(openerElement) { 750 // openerElement is the element on which popup was initialized, in this case its <a> tag 751 // you don't need to add "opener" option if this code matches your needs, it's defailt one. 752 return openerElement.is('img') ? openerElement : openerElement.find('img'); 753 } 754 } 755 756 }); 757 758 /*============================== 759 Single Images Buttons 760 ==============================*/ 761 // Initialize popup as usual 762 $('.image-popup').magnificPopup({ 763 //delegate: 'a', 764 type: 'image', 765 }); 766 767 768 769 770 /*============================== 771 Toolbar 772 ==============================*/ 773 var toolbar_toggle = (function() { 774 775 // Cash 776 var toolbar_wpr = $('.toolbar'); 777 778 // btn's 779 var our_hotels_btn = $("a[href='#our_hotels']"); 780 var book_now_btn = $("a[href='#book_now']"); 781 var book_now_img = $("#book_now_img"); 782 var services_btn = $("a[href='#our_services']"); 783 var collapsed_main_nav_btn = $("a[href='#collapsed-main-nav']"); 784 785 // wpr's 786 var our_hotels_wpr = $('.toolbar-hotels'); 787 var book_now_wpr = $('.toolbar-book-now:not(.quick-availability)'); 788 var services_wpr = $('.our-services'); 789 var collapsed_main_nav_wpr = $('#collapsed-main-nav'); 790 791 // Functions 792 function setHeaderContainer(){ 793 if( our_hotels_wpr.is(':hidden') && 794 book_now_wpr.is(':hidden') && 795 services_wpr.is(':hidden')){ 796 797 $('#header_container').removeClass('dropdown-open-def'); 798 } 799 else{ 800 if($(window).outerWidth() > 767 && book_now_wpr.is(':visible')){ 801 $('#header_container').removeClass('dropdown-open-def'); 802 } 803 } 804 if($(window).outerWidth() < 768){ 805 if(collapsed_main_nav_wpr.is(':hidden')){ 806 $('#header_container').removeClass('dropdown-open-def'); 807 } 808 } 809 810 811 if( our_hotels_wpr.is(':visible') || 812 book_now_wpr.is(':visible') || 813 services_wpr.is(':visible')){ 814 815 if(! ($(window).outerWidth() > 767 && book_now_wpr.is(':visible')) ){ 816 $('#header_container').addClass('dropdown-open-def'); 817 } 818 } 819 if($(window).outerWidth() < 768){ 820 if(collapsed_main_nav_wpr.is(':visible')){ 821 $('#header_container').addClass('dropdown-open-def'); 822 } 823 } 824 825 } 826 827 function click_toggle(e) { 828 if (our_hotels_btn.is(e.target)) { 829 e.preventDefault();
830 our_hotels_wpr.toggle(); 831 our_hotels_btn.toggleClass("active"); 832 } else if (book_now_btn.is(e.target)) { 833 e.preventDefault(); 834 book_now_wpr.toggle(); 835 } else if (book_now_img.is(e.target)) { 836 e.preventDefault(); 837 book_now_wpr.toggle(); 838 } else if (services_btn.is(e.target)) { 839 e.preventDefault(); 840 services_wpr.toggle(); 841 services_btn.toggleClass("active"); 842 } else if (collapsed_main_nav_btn.is(e.target)) { 843 e.preventDefault(); 844 collapsed_main_nav_wpr.toggle(); 845 collapsed_main_nav_btn.toggleClass("active"); 846 } 847 848 setHeaderContainer(); 849 } 850 851 function close(e) { 852 853 // If any visible 854 if (our_hotels_wpr.is(':visible')) { 855 856 var button = our_hotels_btn; 857 var container = our_hotels_wpr; 858 if (!container.is(e.target) && container.has(e.target).length === 0 && !button.is(e.target)) { 859 container.hide(); 860 our_hotels_btn.toggleClass("active"); 861 } 862 863 } else if (book_now_wpr.is(':visible')) { 864 865 var button = book_now_btn; 866 var image = book_now_img; 867 var container = book_now_wpr; 868 var datepicker = $(".uk-datepicker"); 869 if (!container.is(e.target) && !datepicker.is(e.target) && !button.is(e.target) && !image.is(e.target) && container.has(e.target).length === 0 && datepicker.has(e.target).length === 0) { 870 container.hide(); 871 } 872 873 } else if (services_wpr.is(':visible')) { 874 875 var button = services_btn; 876 var container = services_wpr; 877 if (!container.is(e.target) && container.has(e.target).length === 0 && !button.is(e.target)) { 878 container.hide(); 879 services_btn.toggleClass("active"); 880 } 881 882 } else if (collapsed_main_nav_wpr.is(':visible') || $(window).outerWidth() > 767) { 883 884 var button = collapsed_main_nav_btn; 885 var container = collapsed_main_nav_wpr; 886 if (!container.is(e.target) && container.has(e.target).length === 0 && !button.is(e.target)) { 887 container.hide(); 888 collapsed_main_nav_btn.toggleClass("active"); 889 } 890 } 891 892 setHeaderContainer(); 893 } 894 895 896 // Events 897 toolbar_wpr.find('a').on('click', click_toggle); 898 $(document).on('mouseup', close); 899 our_hotels_wpr.find('.close, .menu-close').on('click', function() { 900 our_hotels_wpr.toggle(); 901 our_hotels_btn.toggleClass("active"); 902 }); 903 services_wpr.find('.close, .menu-close').on('click', function() { 904 services_wpr.toggle(); 905 services_btn.toggleClass("active"); 906 }); 907 collapsed_main_nav_wpr.find('.close, .menu-close').on('click', function() { 908 collapsed_main_nav_wpr.toggle(); 909 collapsed_main_nav_btn.toggleClass("active"); 910 }); 911 912 $(window).resize(function() { 913 setHeaderContainer(); 914 }); 915 916 })() 917 918 919 920 921 922 /*============================== 923 Card 924 ==============================*/ 925 $(".open-content, .card-dropdown-icon").click(function(event) { 926 event.preventDefault(); 927 var parent = $(this).closest(".card-horizontal"); 928 var icon = $(parent).find(".card-dropdown-icon"); 929 $(icon).toggleClass("open"); 930 var open = $(parent).find(".card-dropdown-content"); 931 $(open).slideToggle(); 932 }); 933 934 $(".option-icon").click(function(event) { 935 event.preventDefault(); 936 $(this).toggleClass("open"); 937 var parent = $(this).closest(".well"); 938 var open = $(parent).find(".option-content"); 939 $(open).slideToggle(); 940 }); 941 942 943 /*============================== 944 Timepicker 945 ==============================*/ 946 if($('.timepicker-input').length > 0){ 947 $('.timepicker-input').each(function(){ 948 var minTime = $(this).data("min-time"); 949 var maxTime = $(this).data("max-time"); 950 if(!minTime){ 951 minTime = '7:00am'; 952 } 953 if(!maxTime){ 954 maxTime = '22:30pm'; 955 } 956 $(this).timepicker({'minTime': minTime,'maxTime': maxTime, "timeFormat": "H:i"}); 957 }); 958 } 959 960 //bug fix datepicker, timepicker for mobile browsers 961 if($(".uk-touch").length > 0){ 962 //console.log("[data-uk-datepicker]" + $("[data-uk-datepicker]").length) 963 //console.log("[timepicker-input]" + $(".timepicker-input").length) 964 $("[data-uk-datepicker]").each(function(i, obj){ 965 ////$(this).after("<span class='error'>"+$("[data-uk-datepicker]").length+"::</span"); 966 $(this).prop("readonly", true); 967 }) 968 $("[data-xsuk-datepicker]").each(function(i, obj){ 969 ////$(this).after("<span class='error'>"+$("[data-uk-datepicker]").length+"::</span"); 970 $(this).prop("readonly", true); 971 }) 972 $('.timepicker-input').each(function(i, obj){ 973 ////$(this).after("<span class='error'>"+$(".timepicker-input").length+"::</span"); 974 $(this).timepicker('option', {'disableTouchKeyboard': true}); 975 }) 976 977 } 978 979 /*============================== 980 Gallery horizontal 981 ==============================*/ 982 gallery_horizontal = (function() { 983 984 $('.gallery-horizontal').each(function(index, value) { 985 986 images = $(value).find('.image-link').length 987 988 // Set up 989 if (images <= 4) { 990 image_width = 25; 991 } else { 992 image_width = 100 / images; 993 } 994 995 $(value).find('.image-link').css({ 996 'width': 'calc(' + image_width + '% - ' + 10 + 'px)' 997 }); 998 999 // Event 1000 $(value).find('.image-link').hover(function() { 1001 1002 // If there are more than one horizontal gallerys on the page need to re-cal 1003 images = $(value).find('.image-link').length 1004 if (images <= 4) { 1005 image_width = 25; 1006 image_width_grow = 40; 1007 dif = image_width_grow - image_width; 1008 image_width_2 = dif / (images - 1); 1009 } else { 1010 image_width = 100 / images; 1011 image_width_grow = (image_width * 3); 1012 dif = image_width_grow - image_width; 1013 image_width_2 = dif / (images - 1); 1014 } 1015 1016 $(value).find('.image-link').css({ 1017 'width': 'calc(' + (image_width - image_width_2) + '% - ' + 10 + 'px)' 1018 }); 1019 $(this).css({ 1020 'width': 'calc(' + image_width_grow + '% - ' + 10 + 'px)' 1021 }); 1022 1023 }, function() { 1024 1025 $(value).find('.image-link').css({ 1026 'width': 'calc(' + image_width + '% - ' + 10 + 'px)' 1027 }); 1028 1029 }); 1030 1031 }); 1032 1033 1034 })() 1035 1036 1037 /*============================== 1038 Form toggle 1039 ==============================*/ 1040 // Form_toggle = (function() { 1041 // 1042 // $('.search-block h3').on('click', function() { 1043 // var parent = $(this).parent(); 1044 // $(parent).find('.search-block-content').slideToggle('fast'); 1045 // $(parent).toggleClass('open'); 1046 // }); 1047 // 1048 // })() 1049 1050 1051 /*============================== 1052 Book now Form 1053 ==============================*/ 1054 1055 book_now_form = (function() { 1056 1057 // Cash 1058// var wpr = $(".toolbar-book-now"); 1059// var region = wpr.find('.region'); 1060// var region_inputs = wpr.find('.region-inputs'); 1061// var form = wpr.find('.form'); 1062// var room = wpr.find('select[name=rooms]'); 1063 var wpr, region, region_inputs, form, room; 1064 1065 // Functions 1066 function change_region() { 1067 1068 wpr = $(this).closest(".toolbar-book-now"); 1069 region = wpr.find('.region'); 1070 // console.log(region) 1071 region_inputs = wpr.find('.region-inputs'); 1072 form = wpr.find('.form'); 1073 room = wpr.find('select[name=rooms]'); 1074 selected = $(region).find(':selected'); 1075 str_selected_hotels = selected.data('hotels'); 1076 1077 $(region).find('.region-label').show(); 1078 1079 if (str_selected_hotels) { 1080 $('.region-label').hide(); 1081 var arr_hotels = str_selected_hotels.split(','); 1082 } else { 1083 str_selected_hotels = ""; 1084 } 1085 1086 // Reset 1087 region_inputs.find('input').closest('.full-width').hide(); 1088 region_inputs.find('input').prop('checked', false); 1089 1090 // Set 1091 $.each(arr_hotels, function(index, value) { 1092 var input = wpr.find('input[value=' + value + ']'); 1093 input.closest('.full-width').show(); 1094 input.prop('checked', true); 1095 }); 1096 1097 if (str_selected_hotels == "") { 1098 wpr.find('.wide_res_hotels').val(null); 1099 } else { 1100 str_selected_hotels = '[' + str_selected_hotels.replace(/,/g, "][") + ']'; 1101 wpr.find('.wide_res_hotels').val(str_selected_hotels); 1102 } 1103 1104 } 1105 1106 function change_hotel() { 1107 wpr = $(this).closest(".toolbar-book-now"); 1108 var hotel = $(this).val(); 1109 var current_hotel_list = wpr.find('.wide_res_hotels').val(); 1110 if (current_hotel_list.indexOf('[' + hotel + ']') >= 0) { 1111 wpr.find('.wide_res_hotels').val(current_hotel_list.replace('[' + hotel + ']', '')); 1112 } else { 1113 wpr.find('.wide_res_hotels').val(current_hotel_list + '[' + hotel + ']') 1114 } 1115 } 1116 1117 // Events 1118 if($(".region").length > 0){ 1119 $(".region").each(change_region); 1120 } 1121 $(".toolbar-book-now .region").on('change', change_region); 1122 $(".toolbar-book-now .region-inputs").find('input').on('change', change_hotel); 1123 $('.toolbar-book-now select[name=rooms]').on('change', function() { 1124 1125 wpr = $(this).closest(".toolbar-book-now"); 1126 change_room.change(wpr, $(this)); 1127 }); 1128 if(form){ 1129 form.validate({ 1130 submitHandler: function(form) { 1131 SearchOverlay.start(); 1132 form.submit(); 1133 } 1134 }); 1135 } 1136 1137 })() 1138 1139 1140 /*============================== 1141 Book now Form 1142 ==============================*/ 1143 1144 reservations_form = (function() { 1145 1146 // Cash 1147 var wpr = $(".reservations-form"); 1148 var room = wpr.find('select[name=rooms]'); 1149 1150 // Events 1151 $(".reservations-form select[name=rooms]").on('change', function() { 1152 wpr = $(this).closest(".reservations-form"); 1153 change_room.change(wpr, $(this)); 1154 }); 1155 1156 })() 1157 1158 1159 /*============================== 1160 Change room 1161 ==============================*/ 1162 1163 change_room = (function() { 1164 1165 // Functions 1166 function change_room(wpr, room) { 1167 var selected = $(room).find(':selected'); 1168 var int_selected_room = selected.val(); 1169 // Reset 1170 for (var i = 2; i <= 5; i++) { 1171 if (int_selected_room < i) {
1172 wpr.find('.w_res_room[data-room="' + i + '"]').slideUp(); 1173 } 1174 } 1175 // Set 1176 for (var i = 1; i <= int_selected_room; i++) { 1177 wpr.find('.w_res_room[data-room="' + i + '"]').slideDown(); 1178 } 1179 } 1180 1181 // Reveal 1182 return { 1183 change: change_room 1184 } 1185 1186 })() 1187 1188 1189 /*============================== 1190 Check_availability 1191 ==============================*/ 1192 check_availability = (function() { 1193 1194 // Cash 1195 var $button = $('.check-availability'); 1196 var $drop_wpr = $($($button).data('drop')); 1197 var room = $drop_wpr.find($('.calendar-availability select[name=rooms]')); 1198 1199 1200 // Functions 1201 function close(e) { 1202 1203 if ($drop_wpr.find('.content').is(':visible')) { 1204 //console.log("hide"); 1205 var button = $button; 1206 var container = $drop.find('.content'); 1207 var datepicker = $(".uk-datepicker"); 1208 if (!container.is(e.target) && !datepicker.is(e.target) && datepicker.has(e.target).length === 0 && container.has(e.target).length === 0 && !button.is(e.target)) { 1209 //console.log("hide"); 1210 container.hide(); 1211 } 1212 } 1213 } 1214 1215 // Events 1216 $button.on('click', function(e) { 1217 e.preventDefault(); 1218 $drop = $($(this).data('drop')); 1219 $($drop).find('.content').slideToggle(); 1220 }); 1221 room.on('change', function() { 1222 var wrp = $drop_wpr.find(".calendar-availability"); 1223 change_room.change(wrp, $(this)) 1224 }); 1225 $(document).on('mouseup', close); 1226 1227 })() 1228 1229 1230 /*============================== 1231 Search Overlay 1232 ==============================*/ 1233 SearchOverlay = (function() { 1234 1235 // Functions 1236 function randomMessage() { 1237 var items = Array("<span>Preparing Rooms...</span>", 1238 "<span>Mowing lawns...</span>", 1239 "<span>Turning down the bedrooms...</span>", 1240 "<span>Arranging the flowers...</span>", 1241 "<span>Chilling the champagne...</span>", 1242 "<span>Polishing glasses...</span>", 1243 "<span>Peeling the potatoes...</span>", 1244 "<span>Mixing the drinks...</span>", 1245 "<span>Baking the scones...</span>" 1246 ); 1247 setTimeout(function() { 1248 $('#searchOverlayText').html(items[Math.floor(Math.random() * items.length)]); 1249 randomMessage(); 1250 }, Math.random() * 750 + 500); 1251 } 1252 1253 function startSearchOverlay() { 1254 target = $('.header'); 1255 $('html, body').animate({ 1256 scrollTop: 0 1257 }, 0); 1258 $('#book_now').fadeOut("fast"); 1259 $('#book_now_box').fadeOut("fast"); 1260 $('#searchOverlay').fadeIn("fast"); 1261 $('#searchOverlayDiv').fadeIn("slow"); 1262 $('#searchOverlayText').html("<span>Searching...</span>"); 1263 setTimeout(function() { 1264 $('#searchOverlayText').html("<span>Preparing Rooms</span>"); 1265 randomMessage(); 1266 }, 2000); 1267 } 1268 1269 return { 1270 start: startSearchOverlay 1271 } 1272 1273 })() 1274 1275 1276 /*============================== 1277 Filter Spa 1278 ==============================*/ 1279 1280 $('.spa-mobile-button').on('click', function() { 1281 $('.spa-filter').toggleClass('open'); 1282 }); 1283 1284 $('.blog-mobile-button').on('click', function() { 1285 $('.blog-filters-wpr .border-thick-box').toggleClass('open'); 1286 }); 1287 1288 1289 /*============================== 1290 Wishlist 1291 ==============================*/ 1292 1293 Wishlist = (function() { 1294 1295 // Cash 1296 var wishlist_btn = $('.wishlist-add-btn'); 1297 1298 // Functions 1299 function addToWishlist() { 1300 1301 var thisbtn = $(this); 1302 1303 var category = $(this).data("category"); 1304 var name = $(this).data("name"); 1305 var image = $(this).data("image"); 1306 var link = $(this).data("link"); 1307 1308 if (thisbtn.attr('href') == '/wishlist') { 1309 window.location.href = "/account-wishlist"; 1310 } 1311 1312 $.ajax('/reservations/wishlist_add', { 1313 cache: true, 1314 data: { 1315 category: category, 1316 name: name, 1317 image: image, 1318 link: link, 1319 }, 1320 success: function(res) { 1321 if (res != "success") { 1322 alert(res); 1323 } else { 1324 thisbtn.text('View wish list').button("refresh"); 1325 thisbtn.removeClass("wishlist-add-btn"); 1326 thisbtn.attr('href', '/account-wishlist'); 1327 } 1328 } 1329 }); 1330 1331 } 1332 1333 // Events 1334 wishlist_btn.on('click', addToWishlist) 1335 1336 })() 1337 1338 1339 1340 1341 /*============================== 1342 REGISTER ACCOUNT 1343 ==============================*/ 1344 1345 register_account = (function() { 1346 1347 // Cash 1348 var next = $('.jsn_registration_controls .next-button'); 1349 var prev = $('.jsn_registration_controls .prev-button'); 1350 var Register = $('.jsn_registration_controls .button-primary'); 1351 1352 // Events 1353 next.on('click', function() { 1354 if ($(this).hasClass('prev-button')) { 1355 $(this).removeClass('prev-button'); 1356 $(this).addClass('next-button'); 1357 $(this).addClass('pull-right'); 1358 $(this).text('Next'); 1359 Register.hide(); 1360 $('.nav.nav-tabs a:first').tab('show'); 1361 } else { 1362 $(this).removeClass('pull-right'); 1363 $(this).addClass('prev-button'); 1364 $(this).text('Prev'); 1365 Register.show(); 1366 $('.nav.nav-tabs a:last').tab('show'); 1367 } 1368 }); 1369 1370 1371 $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) { 1372 if ($(e.target).attr('aria-controls') == 'Contact') { 1373 next.removeClass('pull-right'); 1374 next.addClass('prev-button'); 1375 next.text('Prev'); 1376 Register.show(); 1377 } else { 1378 next.removeClass('prev-button'); 1379 next.addClass('next-button'); 1380 next.addClass('pull-right'); 1381 next.text('Next'); 1382 Register.hide(); 1383 } 1384 }) 1385 1386 1387 })() 1388 1389 1390 /*============================== 1391 Side Menu 1392 ==============================*/ 1393 1394 side_menu = (function() { 1395 1396 // Cash 1397 headers_list = $('.headers-list'); 1398 heading = headers_list.find('.heading'); 1399 1400 // Events 1401 heading.find(" > span").on('click', function(e) { 1402 var $heading = $(this).closest(".heading"); 1403 if ( $heading.find("a").first().attr('href') == '#' ) { 1404 e.preventDefault(); 1405 } 1406 1407 sub_list = $heading.find('ul'); 1408 if (!$heading.hasClass('close-list')) { 1409 sub_list.slideUp("fast"); 1410 $heading.addClass('close-list'); 1411 } else { 1412 $heading.removeClass('close-list'); 1413 sub_list.slideDown("fast"); 1414 } 1415 }); 1416 1417 })() 1418 1419 1420 /*============================== 1421 blog filter Side 1422 ==============================*/ 1423 blog_filter_menu = (function() { 1424 1425 // Cash 1426 $wpr = $('.blog-filters-wpr'); 1427 $form = $wpr.find('.form'); 1428 $inputs = $wpr.find('select, input'); 1429 1430 1431 // Events 1432 $inputs.on('change', function() { 1433 $form.submit(); 1434 }); 1435 1436 })() 1437 1438 1439 1440 /*============================== 1441 Affix 1442 ==============================*/ 1443 1444 blog_affix = (function () { 1445 1446 // Cash 1447 window_width = $( window ).width(); 1448 $wpr = $('.SidebarAffix'); 1449 $Sidebar = $('#SidebarAffix'); 1450 1451 // Setup 1452 if ( window_width > 1023) { 1453// $Sidebar.affix({ 1454// offset: { 1455// top: function() { 1456// return (this.top = $('.toolbar').outerHeight(true) + $('.main-nav').outerHeight(true)) 1457// }, 1458// bottom: function() { 1459// return (this.bottom = $('.footer').outerHeight(true) + 60) 1460// } 1461// } 1462// }); 1463 } 1464 1465 $(window).resize(function() { 1466 if ( window_width > 1023) { 1467 $wpr_width = $wpr.width(); 1468 $Sidebar.width($wpr_width); 1469 } 1470 }); 1471 1472 if ( window_width > 1023) { 1473 $wpr_width = $wpr.width(); 1474 $Sidebar.width($wpr_width); 1475 } 1476 1477 $(window).scroll(function() { 1478 if ( window_width > 1023) { 1479 $wpr_width = $wpr.width(); 1480 $Sidebar.width($wpr_width); 1481 } 1482 }); 1483 1484 })() 1485 1486 1487 /*============================== 1488 Col Heights 1489 ==============================*/ 1490 1491// col_Heights = (function () { 1492// 1493// 1494// 1495// 1496// return { 1497// col_Setup: col_Setup 1498// } 1499// 1500// })() 1501 1502 // Setup on page load 1503 function col_Setup(col) { 1504 if (typeof col === 'undefined') { col = ''; } 1505 if($('.row').length > 0){ 1506 1507 $('.row').each( function () { 1508 1509 //only if this row has cards and not other rows 1510 if($(this).find(".row").length == 0 && $(this).find(".card").length > 0){ 1511 if(col){ 1512 $targets = $(this).find(col + ' .card:not(.card-horizontal)'); 1513 }else{ 1514 $targets = $(this).find('.card:not(.card-horizontal)'); 1515 } 1516 1517 // Get an array of all element heights 1518 var elementHeights = $targets.map(function() { 1519 return $(this).outerHeight(); 1520 }).get(); 1521 1522 if(elementHeights.length > 0){ 1523 //console.log("2"); 1524 //console.log(elementHeights); 1525 1526 // Math.max takes a variable number of arguments 1527 // `apply` is equivalent to passing each height as an argument 1528 var minHeight = Math.max.apply(null, elementHeights); 1529 1530 // Set each height to the max height 1531 $targets.css('min-height', minHeight); 1532 } 1533 } 1534 }); 1535 } 1536 } 1537 1538 1539 $( window ).on('load', function(){ 1540 col_Setup(); 1541 }); 1542 1543 $(window).on('resize', function(e) { 1544 $('.row').find('.card:not(.card-horizontal)').css('min-height', 0); 1545 if($(window).width() > 769){ 1546 1547 col_Setup(); 1548 } 1549// $.each( $('.row'), function () { 1550// $targets = $(this).find('.card:not(.card-horizontal)');
1550 //added :not(....) stefman 2016.07.18 1551// 1552// // Get an array of all element heights 1553// var elementHeights = $targets.map(function() { 1554// return $(this).height()+2; 1555// }).get(); 1556// 1557// // Math.max takes a variable number of arguments 1558// // `apply` is equivalent to passing each height as an argument 1559// var minHeight = Math.max.apply(null, elementHeights); 1560// 1561// // Set each height to the max height 1562// $targets.css('min-height', minHeight); 1563// }); 1564 1565 }); 1566 1567 /** 1568 * ================================= 1569 * call col_Setup on filter click 1570 * ================================= 1571 */ 1572 if($(".filter-list .filter").length > 0){ 1573 $(".filter-list").on("click", ".filter", function(){ 1574 var targetCol = $(this).data("filter"); 1575 if(targetCol){ 1576 $(targetCol).find('.card:not(.card-horizontal)').css('min-height', 0); 1577 if($(window).width() > 769){ 1578 1579 col_Setup(targetCol); 1580 } 1581 } 1582 }); 1583 } 1584 1585 1586 1587 /*------------------------ 1588 * validate rsforms 1589 ----------------------- */ 1590 if($(".rsform").length > 0){ 1591 $(".rsform").validate({ 1592 submitHandler: function(form) { 1593 // do other things for a valid form 1594 1595 // ADDING CAPTCHA V3 TO RSFORMS 1596 grecaptcha.ready(function() { 1597 grecaptcha.execute('6Lc0yXQqAAAAAP1Tx-QAbdsD9SwZ5jGyGm5D3E7z', {action: 'rsform'}).then(function (token) { 1598 $('.rsform').prepend('<input type="hidden" name="token" value="' + token + '">'); 1599 form.submit(); 1600 }); 1601 }); 1602 } 1603 }); 1604 } 1605 1606 /*------------------------ 1607 * Form validate 1608 ----------------------- */ 1609 if($(".form-validate").length > 0){ 1610 $(".form-validate").validate({ 1611 errorPlacement: function(error, element) { 1612 error.appendTo( element.parent()); 1613 } 1614 }); 1615 } 1616 /*------------------------ 1617 * booking forms 1618 * with overlay once valid 1619 ----------------------- */ 1620 if($(".form-with-background").length > 0){ 1621 $(".form-with-background").on("submit", function(event){ 1622 if ($(this).attr("id")=='booking') { 1623 //don't do this for the booking form 1624 } else {
1625 if($(this).valid()){ 1626 //this.style.display='none'; document.getElementById('formSending').display='block'; SearchOverlay.start(); 1627 $(this).find("[type='submit']").hide(); 1628 $(this).find(".form-sending").first().show(); 1629 $(".booking-error").hide(); 1630 SearchOverlay.start(); 1631 } 1632 } 1633 }); 1634 } 1635 /* CV2 validation rule */ 1636 /* add like thi: data-rule-cvcode="true" */ 1637 $.validator.addMethod("cvcode", function(value, element) { 1638 return this.optional( element ) || /^[0-9]+$/.test( value ); 1639 }, 'Please enter a valid security code.'); 1640 1641 $.validator.addMethod("phonenumber", function(value, element) { 1642 return this.optional( element ) || /^[0-9-\+\(\) ]+$/.test( value ); 1643 }, 'Please enter a valid phone number.'); 1644 1645 $.validator.addMethod("sameroomdetails", function(value, element) { 1646 if(!$("#bolSameDetailsRooms").is(":checked")){ 1647 return value != ""; 1648 }else{ 1649 return true; 1650 } 1651 }, 'This field is required.'); 1652 1653 /* ------------------------------ 1654 | Used on final booking page 1655 ------------------------------ */ 1656 $.validator.addMethod('cardExp', function(value, element, params) { 1657 var minMonth = new Date().getMonth() + 1; 1658 var minYear = new Date().getFullYear(); 1659 var month = parseInt($(params.month).val(), 10); 1660 var year = parseInt($(params.year).val(), 10); 1661 return (year > minYear || (year === minYear && month >= minMonth)); 1662 }, 'Your card expiration date is invalid.'); 1663 1664 if($(".form-booking-final").length > 0){ 1665 1666 $(".form-booking-final").validate({ 1667 rules: { 1668 res_card_exp_month:{ 1669 required: true 1670 }, 1671 res_card_exp_year:{ 1672 required:true, 1673 cardExp:{ 1674 month: "#res_card_exp_month", 1675 year: "#res_card_exp_year" 1676 } 1677 } 1678 }, 1679 errorPlacement: function(error, element) { 1680 error.appendTo( element.parent()); 1681 }, 1682 showErrors: function(errorMap, errorList){ 1683 // 'this' refers to the form 1684 var errors = this.numberOfInvalids(); 1685 if (errors) { 1686 var message = errors == 1 1687 ? 'You missed 1 field. It has been highlighted' 1688 : 'You missed ' + errors + ' fields. They have been highlighted.'; 1689 1690 if($(".form-booking-final .hph-progress-bar li").length > 1){ 1691 message += "<br />Use the room tabs to select between rooms."; 1692 /*$(".form-booking-final .hph-progress-bar a").each(function(){ 1693 var $this = $(this); 1694 var $thisParent = $(this).closest("li"); 1695 var tabPaneId = $this.attr("href"); 1696 var completed = false; 1697 $(tabPaneId).find(":input, select, textarea").each(function(){ 1698 if(errorMap.hasOwnProperty($(this).attr("name"))){ 1699 completed = false; 1700 return false; 1701 } 1702 }); 1703 if(completed){ 1704 $thisParent.addClass("done"); 1705 }else{ 1706 $thisParent.removeClass("done"); 1707 } 1708 });*/ 1709 } 1710 $(".booking-error div").html(message); 1711 $(".booking-error").show(); 1712 //console.log(errorList); 1713 //console.log(errorMap); 1714 //console.log("show error" + message); 1715 } else { 1716 $(".booking-error").hide(); 1717 //console.log("hide error"+message); 1718 } 1719 this.defaultShowErrors(); 1720 } 1721 }); 1722 } 1723 1724 // $('#region_select, #region_select_quick, #wide_res_region_redeem').selectpicker({ 1725 // showSubtext: true, 1726 // }); 1727 1728 // /*============================== 1729 // Book Now Select 1730 // ==============================*/ 1731 // $('.region-book-now ul.dropdown-menu > li').on('click', function(){ 1732 // filterOption = $('.region-book-now button .filter-option'); 1733 // // remove selected classes 1734 // filterOption.removeClass('optionChild').removeClass('optionGroup'); 1735 // // add selected class 1736 // filterOption.addClass($(this).find('a').attr('class')); 1737 // }); 1738 // $('.region-book-now button .filter-option').on('DOMSubtreeModified', function(){ 1739 // // remove last space 1740 // text = $(this).contents().first().text().slice(0, -2); 1741 // //alert(text); 1742 // $(this).contents().first().text(text); 1743 // }); 1744 1745 // $('.region-quick ul.dropdown-menu > li').on('click', function(){ 1746 // filterOption = $('.region-quick button .filter-option'); 1747 // // remove selected classes 1748 // filterOption.removeClass('optionChild').removeClass('optionGroup'); 1749 // // add selected class 1750 // filterOption.addClass($(this).find('a').attr('class')); 1751 // }); 1752 // $('.region-quick button .filter-option').on('DOMSubtreeModified', function(){ 1753 // // remove last space 1754 // text = $(this).contents().first().text().slice(0, -2); 1755 // //alert(text); 1756 // $(this).contents().first().text(text); 1757 // }); 1758 1759 // $('.region-redeem ul.dropdown-menu > li').on('click', function(){ 1760 // filterOption = $('.region-redeem button .filter-option'); 1761 // // remove selected classes 1762 // filterOption.removeClass('optionChild').removeClass('optionGroup'); 1763 // // add selected class 1764 // filterOption.addClass($(this).find('a').attr('class')); 1765 // }); 1766 // $('.region-redeem button .filter-option').on('DOMSubtreeModified', function(){ 1767 // // remove last space 1768 // text = $(this).contents().first().text().slice(0, -2); 1769 // //alert(text); 1770 // $(this).contents().first().text(text); 1771 // }); 1772 1773 /*============================== 1774 Services Menu 1775 ==============================*/ 1776 $(".our-services .navbar-nav > li" ).mouseenter(function() { 1777 $(".our-services .navbar-nav > li").removeClass('open-def'); 1778 $(this).addClass('open-def'); 1779 }); 1780}); 1781 1782 1783 1784/*============================== 1785 Room Price Display 1786 ==============================*/ 1787 1788(function($) { 1789 $(function() { 1790 1791 $('.roomPriceDisplay').each(function() { 1792 1793 var _thisPriceDisplay = $(this); 1794 var _thisPrice = $(this).find(".roomPrice"); 1795 1796 var params = []; 1797 // console.log(params); 1798 var date = new Date(); 1799 params.push({ 1800 name: 'year_month', 1801 value: date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) 1802 }); 1803 params.push({ 1804 name: 'adults', 1805 value: 2 1806 }); 1807 params.push({ 1808 name: 'children', 1809 value: 0 1810 }); 1811 params.push({ 1812 name: 'infants', 1813 value: 0 1814 }); 1815 params.push({ 1816 name: 'hotel_code', 1817 value: _thisPriceDisplay.find(".room_price_hotel_code").val() 1818 }); 1819 params.push({ 1820 name: 'room_code', 1821 value: _thisPriceDisplay.find(".room_price_room_code").val() 1822 }); 1823 params.push({ 1824 name: 'best', 1825 value: 1 1826 }); 1827 1828 1829 $.ajax('/reservations/calendar', { 1830 cache: true, 1831 data: params, 1832 dataType: 'json', 1833 success: function(res) { 1834 1835 var date = new Date(); 1836 if (date.getMonth() == 11) { 1837 var date = new Date(date.getFullYear() + 1, 0, 1); 1838 } else { 1839 var date = new Date(date.getFullYear(), date.getMonth() + 1, 1); 1840 } 1841 params.push({ 1842 name: 'year_month', 1843 value: date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) 1844 }); 1845 $.ajax('/reservations/calendar', { 1846 cache: true, 1847 data: params, 1848 dataType: 'json', 1849 success: function(nextres) { 1850 1851 if (res > 0 && res <= nextres) { 1852 res = res; 1853 } else { 1854 res = nextres; 1855 } 1856 _thisPrice.fadeOut("slow", function() { 1857 _thisPrice.text("£" + res.toFixed(2)); 1858 _thisPrice.fadeIn("slow"); 1859 }); 1860 } 1861 }); 1862 1863 1864 } 1865 }); 1866 1867 1868 }); 1869 1870 }); 1871}); 1872 1873(function($){ 1874 /* ---------------------------- 1875 * Adjust slick tricolumns 1876 ----------------------------- */ 1877 $(function(){ 1878 adjustSlickTriColumn(); 1879 adjustSlickFourColumn(); 1880 adjustSlickDuoDifferentColumns(); 1881 $(window).resize(function(){
1882 adjustSlickTriColumn(); 1883 adjustSlickFourColumn(); 1884 adjustSlickDuoDifferentColumns(); 1885 }) 1886 }); 1887 function adjustSlickTriColumn(){ 1888 if($(".offers").length > 0 && $(".offers .row .small-slider").length == 3){ 1889 $(".offers .row .small-slider").outerHeight("auto"); 1890 if($(window).outerWidth() > 767){ 1891 //var height = $(".offers .row").outerHeight(); 1892 //console.log(height); 1893 var height = 0; 1894 $(".offers .row .small-slider").each(function(){ 1895 //console.log($(this).outerHeight()+" vs "+ height); 1896 var this_height = $(this).find(".slick-track").outerHeight(); 1897 if(this_height == "" || typeof this_height === "undefined"){ 1898 this_height = $(this).outerHeight(); 1899 } 1900 if( this_height > height){ 1901 height = $(this).find(".slick-track").outerHeight(); 1902 } 1903 }); 1904 if(height > 0){ 1905 $(".offers .row .small-slider").outerHeight(height); 1906 } 1907 } 1908 } 1909 } 1910 function adjustSlickFourColumn(){ 1911 if($(".offers").length > 0 && $(".offers .row .small-slider").length == 4){ 1912 $(".offers .row .small-slider").outerHeight("auto"); 1913 if($(window).outerWidth() > 767){ 1914 //var height = $(".offers .row").outerHeight(); 1915 //console.log(height); 1916 var height = 0; 1917 $(".offers .row .small-slider").each(function(){ 1918 //console.log($(this).outerHeight()+" vs "+ height); 1919 var this_height = $(this).find(".slick-track").outerHeight(); 1920 if(this_height == "" || typeof this_height === "undefined"){ 1921 this_height = $(this).outerHeight(); 1922 } 1923 if( this_height > height){ 1924 height = $(this).find(".slick-track").outerHeight(); 1925 } 1926 }); 1927 if(height > 0){ 1928 $(".offers .row .small-slider").outerHeight(height); 1929 } 1930 } 1931 } 1932 } 1933 function adjustSlickDuoDifferentColumns(){ 1934 if($(".offers").length > 0 && $(".offers .row .small-slider").length == 1 && $(".offers .row .medium-slider").length == 1){ 1935 $(".offers .row .small-slider").outerHeight("auto"); 1936 $(".offers .row .medium-slider").outerHeight("auto"); 1937 if($(window).outerWidth() > 767){ 1938 //var height = $(".offers .row").outerHeight(); 1939 //console.log(height); 1940 var height = 0; 1941 $(".offers .row .small-slider").each(function(){ 1942 //console.log($(this).outerHeight()+" vs "+ height); 1943 var this_height = $(this).find(".slick-track").outerHeight(); 1944 if(this_height == "" || typeof this_height === "undefined"){ 1945 this_height = $(this).outerHeight(); 1946 } 1947 if( this_height > height){ 1948 height = $(this).find(".slick-track").outerHeight(); 1949 } 1950 }); 1951 $(".offers .row .medium-slider").each(function(){ 1952 //console.log($(this).outerHeight()+" vs "+ height); 1953 var this_height = $(this).find(".slick-track").outerHeight(); 1954 if(this_height == "" || typeof this_height === "undefined"){ 1955 this_height = $(this).outerHeight(); 1956 } 1957 if( this_height > height){ 1958 height = $(this).find(".slick-track").outerHeight(); 1959 } 1960 }); 1961 if(height > 0){ 1962 $(".offers .row .small-slider").outerHeight(height); 1963 $(".offers .row .medium-slider").outerHeight(height); 1964 } 1965 } 1966 } 1967 } 1968 1969 /* ---------------------------- 1970 * Hide paragraphs - Read more button - Home page and Hotel home page 1971 ----------------------------- */ 1972 $(function(){ 1973 showFirstParagraphOnly(); 1974 $(window).resize(function(){ 1975 showFirstParagraphOnly(); 1976 }) 1977 }); 1978 function showFirstParagraphOnly(){ 1979 if($(window).outerWidth() < 768){ 1980 $(".mobile-short-text .text-content").each(function(){ 1981 if($(this).children().length > 1){ 1982 // hide from second paragraph if not click read more/less yet 1983 if(!($(this).hasClass('open') || $(this).hasClass('closed'))){ 1984 $(this).children().each(function(index){ 1985 if(index > 0 && !($(this).hasClass('read-more') || $(this).hasClass('read-less'))){ 1986 $(this).hide(); 1987 } 1988 }); 1989 } 1990 // if resizing show read more 1991 if($(this).children('.read-more').is(":hidden") && $(this).children('.read-less').is(":hidden")){ 1992 $(this).children('.read-more').show(); 1993 } 1994 } 1995 }); 1996 } 1997 else{ 1998 // rest open/close for text-content div 1999 $(".mobile-short-text .text-content").removeClass('closed').removeClass('open') 2000 // reset paragraphs 2001 $(".mobile-short-text .text-content p").each(function(){ 2002 $(this).show(); 2003 }); 2004 // remove Read more buttons 2005 $(".mobile-short-text .text-content p.read-more").hide(); 2006 $(".mobile-short-text .text-content p.read-less").hide(); 2007 } 2008 } 2009 $(document).ready(function(){ 2010 $(".mobile-short-text .text-content").each(function(){ 2011 $(this).append('<p class="read-more" style="display: none">Read more</p>'); 2012 $(this).append('<p class="read-less" style="display: none">Read less</p>'); 2013 }); 2014 showFirstParagraphOnly(); 2015 2016 $(".mobile-short-text .text-content p.read-more").on("click", function(e){ 2017 // mark text-content as open 2018 $(this).parent().removeClass('closed').addClass('open') 2019 // show paragraphs 2020 $(this).parent().children().each(function(index){ 2021 if(index > 0 && !($(this).hasClass('read-more') || $(this).hasClass('read-less'))){ 2022 $(this).slideDown('slow'); 2023 } 2024 }); 2025 // change to read less 2026 $(this).hide(); 2027 $(this).parent().children('.read-less').show(); 2028 }); 2029 $(".mobile-short-text .text-content p.read-less").on("click", function(e){ 2030 // mark text-content as open 2031 $(this).parent().removeClass('open').addClass('closed') 2032 // show paragraphs 2033 $(this).parent().children().each(function(index){ 2034 if(index > 0 && !($(this).hasClass('read-more') || $(this).hasClass('read-less'))){ 2035 $(this).slideUp('slow'); 2036 } 2037 }); 2038 // change to read less 2039 $(this).hide(); 2040 $(this).parent().children('.read-more').show(); 2041 }); 2042 }); 2043 2044 /* ---------------------------- 2045 * Home Slider Caption 2046 ----------------------------- */ 2047 $(function(){ 2048 adjustSliderCaption(); 2049 $(window).resize(function(){
2050 adjustSliderCaption(); 2051 }) 2052 }); 2053 function adjustSliderCaption(){ 2054 if($(window).outerWidth() > 1023){ 2055 $(".home-caption").each(function(){ 2056 title = $(this).find('.caption-title'); 2057 content = $(this).find('.caption-content'); 2058 if(title.outerWidth()*2 > content.outerWidth()){ 2059 title.css('white-space','normal'); 2060 } 2061 }); 2062 } 2063 } 2064 2065 /* ---------------------------- 2066 * Our Services Menu 2067 ----------------------------- */ 2068 $(function(){ 2069 adjustServicesHeights(); 2070 $(window).resize(function(){ 2071 adjustServicesHeights(); 2072 }) 2073 }); 2074 function adjustServicesHeights(){ 2075 if($(window).outerWidth() > 767){ 2076 // open our-services dropdows - for calculations 2077 previousCssServices = $('.our-services').attr('style'); 2078 $('.our-services').css('visibility', 'hidden'); 2079 $('.our-services').css('display', 'block'); 2080 $('.our-services').css('min-height', '0'); 2081 2082 max = $('.our-services .navbar-nav').outerHeight(); 2083 $('.our-services .dropdown-wrp').each(function(){ 2084 // open dropdown 2nd level - for calculation 2085 previousCss = $(this).attr('style'); 2086 $(this).css('visibility', 'hidden'); 2087 $(this).css('display', 'block'); 2088 $(this).css('min-height', '0'); 2089 2090 // get highest dropdown 2091 if($(this).outerHeight() > max){ 2092 max = $(this).outerHeight(); 2093 } 2094 2095 // close dropdown - after calculation 2096 $(this).attr('style', previousCss ? previousCss : ''); 2097 }); 2098 // close our-services dropdows - after calculations 2099 $('.our-services').attr('style', previousCssServices ? previousCssServices : ''); 2100 2101 // set heights 2102 $('.our-services .dropdown-wrp').css('min-height', max); 2103 $('.our-services').css('min-height',max+47); 2104 } 2105 else{ 2106 $('.our-services').css('min-height',0); 2107 } 2108 } 2109 2110 /** 2111 * submit user form with ajax 2112 */ 2113 $(document).ready(function(){ 2114 2115 $("#modal_userlogin_form").on("submit", function(e){ 2116 e.preventDefault(); 2117 2118 var $form = $(this); 2119 var url = $form.attr("action"); 2120 var dataToSend = $form.serialize(); 2121 var $modal = $("#login_modal1"); 2122 var $ajax_response = $modal.find(".ajax_response").first(); 2123 var $user_option_bar = $("#user_option_bar"); 2124 2125 $ajax_response.html("<p class='text-warning'>Loading... please wait</p>"); 2126 2127 $.ajax({ 2128 method:"post", 2129 url:url, 2130 data:dataToSend + "&ajax_rq=1" 2131 }).done(function(data){ 2132 if(data.header == "success"){ 2133 //hide the login, register bar 2134 $user_option_bar.hide(); 2135 2136 //populate the input fields 2137 if(data.userData){ 2138 $.each(data.userData, function(name, value){ 2139 if(value){ 2140 //find the input 2141 var $input = $("[name="+name+"]"); 2142 if($input.length > 0){ 2143 $input.val(value); 2144 } 2145 } 2146 }); 2147 } 2148 //hide modal 2149 $modal.modal('hide'); 2150 }else{ 2151 $ajax_response.html(data.msg); 2152 } 2153 }).fail(function(){ 2154 $modal.modal('hide'); 2155 }); 2156 }); 2157 }); 2158 2159 /* ---------------------------- 2160 * Sticky Nav 2161 ----------------------------- */ 2162 $(function(){ 2163 adjustStickyNav(); 2164 $(window).resize(function(){ 2165 adjustStickyNav(); 2166 }) 2167 }); 2168 function adjustStickyNav(){ 2169 $('.space-toolbar').css('height', $('.toolbar').height()); 2170 $('.space-main-nav').css('height', $('.main-nav').height()); 2171 } 2172 2173})(jQuery) 2174 2175 2176 2177// Portmeirion Village - poss delete above this 2178 2179 2180// Task on resize 2181function resizeTasks(){ 2182 // Navbar 2183 if($(window).outerWidth() <= 767){ 2184 $('.header .navbar-nav').removeClass('hovernav'); 2185 } 2186 else{ 2187 $('.header .navbar-nav').addClass('hovernav'); 2188 $('.header .dropdown').removeClass('open'); 2189 } 2190 2191 // Section boxes 2192 if($(window).outerWidth() > 991){ 2193 $('.section-boxes .match-height').matchHeight(); 2194 } 2195 2196 // Slider boxes 2197 $('.slider-boxes .match-height').matchHeight({byRow:false}); 2198 2199 // Card boxes 2200 if($(window).outerWidth() > 767){ 2201 $('.multi_row_grid_container .match-height').matchHeight({byRow:false}); 2202 } 2203 2204 // Slider boxes - slick arrows 2205 if($(window).outerWidth() <= 767){ 2206 imageHeight = $('.slider-boxes .image').height(); 2207 $('.slider-boxes .slick-prev').css('top', imageHeight/2 + 'px'); 2208 $('.slider-boxes .slick-next').css('top', imageHeight/2 + 'px'); 2209 } 2210 else{ 2211 $('.slider-boxes .slick-prev').css('top', '50%'); 2212 $('.slider-boxes .slick-next').css('top', '50%'); 2213 } 2214 2215 // Match Height 2216 $('.boxes-grid .box .box-content').matchHeight({ 2217 byRow: true 2218 }); 2219 2220 $('.booking-bar-state').matchHeight({ 2221 byRow: true 2222 }); 2223} 2224 2225function showGuests(value){ 2226 if(value){ 2227 $('.rooms-details').show(0); 2228 $('.rooms-details-placeholders').hide(0); 2229 2230 for(i=1; i<=5; i+=1){ 2231 id = "#guests_" + i; 2232 2233 if(i<=value){ 2234 if(!$(id).is(':visible')){ 2235 $(id).slideDown(); 2236 } 2237 } 2238 else{ 2239 if($(id).is(':visible')){ 2240 $(id).slideUp(); 2241 } 2242 } 2243 } 2244 } 2245 else{ 2246 $('.rooms-details').hide(0); 2247 $('.rooms-details-placeholders').show(0); 2248 } 2249} 2250 2251function showGuestsPage(value){ 2252 if(value){ 2253 $('#form_book_now_page .rooms-details').show(0); 2254 $('#form_book_now_page .rooms-details-placeholders').hide(0); 2255 2256 for(i=1; i<=5; i+=1){ 2257 id = "#guestsPage_" + i; 2258 2259 if(i<=value){ 2260 if(!$(id).is(':visible')){ 2261 $(id).slideDown(); 2262 } 2263 } 2264 else{ 2265 if($(id).is(':visible')){ 2266 $(id).slideUp(); 2267 } 2268 } 2269 } 2270 } 2271 else{ 2272 $('#form_book_now_page .rooms-details').hide(0); 2273 $('#form_book_now_page .rooms-details-placeholders').show(0); 2274 } 2275} 2276 2277$(document).ready(function() { 2278 // Header Nav 2279 $('#mobile_menu_hb').click(function(){ 2280 if($('#navbar-collapse-1').is(':hidden')){ 2281 $('.header').addClass('navbar-open'); 2282 $('body').addClass('no-scroll'); 2283 } 2284 else{ 2285 $('.header').removeClass('navbar-open'); 2286 $('body').removeClass('no-scroll'); 2287 } 2288 2289 replacement = $(this).data('src-replacement'); 2290 src = $(this).attr('src'); 2291 $(this).attr('src', replacement);
2292 $(this).data('src-replacement', src); 2293 }); 2294 2295 // Navbar click 2296 $('.header .navbar-nav .dropdown-toggle').click(function(e){ 2297 if($(window).outerWidth() > 767){ 2298 e.preventDefault(); 2299 window.location = this.href; 2300 } 2301 }); 2302 2303 /*=============================== 2304 Subscribe 2305 ================================*/ 2306 $('.newsletter-form').submit(function(e){ 2307 var form = $(this); 2308 var result = "#"+$(this).data("res"); 2309 if(form.find("input[name='email']").val() != NaN){ 2310 $.ajax({ 2311 type: "POST", 2312 url:form.attr('action'), 2313 data: form.serialize(), 2314 success:function(data){ 2315 if(data.header == "success"){ 2316 form.slideToggle(); 2317 $(result).addClass("success"); 2318 $(result).removeClass("error"); 2319 } 2320 else if(data.header == "error"){ 2321 $(result).addClass("error"); 2322 $(result).removeClass("success"); 2323 } 2324 $(result).show().html(data.message); 2325 } 2326 }); 2327 } 2328 e.preventDefault(); 2329 }); 2330 2331 // 2332 // BOOK NOW 2333 // 2334 2335 $('#arrivalDate').datepicker(); 2336 2337 var dataNightsHotel = []; 2338 var dataNightsCampers = []; 2339 for(var i=1; i<15; i++){dataNightsHotel.push({id: i, text: i.toString()});} 2340 for(var i=1; i<15; i++){dataNightsCampers.push({id: i, text: i.toString()});} 2341 var dataNightsCottage = [{id: 3,text: '3 nights (Friday - Sunday)'},{id: 4,text: '4 nights (Monday - Thursday)'},{id: 7,text: '7 nights (arrive Friday or Monday)'}]; 2342 2343 var dataRoomsHotel = []; 2344 var dataRoomsCottage = []; 2345 var dataRoomsCampers = []; 2346 for(var i=1; i<6; i++){dataRoomsHotel.push({id: i, text: i.toString()});} 2347 for(var i=1; i<5; i++){dataRoomsCottage.push({id: i, text: i.toString()});} 2348 for(var i=1; i<6; i++){dataRoomsCampers.push({id: i, text: i.toString()});} 2349 2350 var dataAdultsHotel = []; 2351 var dataAdultsCottage = []; 2352 var dataAdultsCampers = []; 2353 for(var i=1; i<=4; i++){dataAdultsHotel.push({id: i, text: i.toString()});} 2354 for(var i=1; i<=8; i++){dataAdultsCottage.push({id: i, text: i.toString()});} 2355 for(var i=1; i<=8; i++){dataAdultsCampers.push({id: i, text: i.toString()});} 2356 2357 var dataChildrenHotel = []; 2358 var dataChildrenCottage = []; 2359 var dataChildrenCampers = []; 2360 for(var i=0; i<=2; i++){dataChildrenHotel.push({id: i, text: i.toString()});} 2361 for(var i=0; i<=8; i++){dataChildrenCottage.push({id: i, text: i.toString()});} 2362 for(var i=0; i<=8; i++){dataChildrenCampers.push({id: i, text: i.toString()});} 2363 2364 var dataInfantsHotel = []; 2365 var dataInfantsCottage = []; 2366 var dataInfantsCampers = []; 2367 for(var i=0; i<=2; i++){dataInfantsHotel.push({id: i, text: i.toString()});} 2368 for(var i=0; i<=8; i++){dataInfantsCottage.push({id: i, text: i.toString()});} 2369 for(var i=0; i<=8; i++){dataInfantsCampers.push({id: i, text: i.toString()});} 2370 2371 // initialization 2372 $('#accomodationType').select2({ 2373 placeholder: '--- Please select ---', 2374 minimumResultsForSearch: Infinity 2375 }); 2376 2377 var accomodationType = $('#accomodationType').val(); 2378 if(accomodationType == 'PMLTDSERV'){ 2379 $('#noNights').empty().trigger("change"); 2380 $('#noNights').select2({ 2381 minimumResultsForSearch: Infinity, 2382 data: dataNightsHotel 2383 }); 2384 2385 $('#noRooms').empty().trigger("change"); 2386 $('#noRooms').select2({ 2387 minimumResultsForSearch: Infinity, 2388 data: dataRoomsHotel 2389 }); 2390 2391 $('.noRoomsTexts').show(); 2392 $('.noCampersTexts').hide(); 2393 $('.noCottagesTexts').hide(); 2394 2395 $('#noAdults1').empty().trigger("change"); 2396 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2397 $('#noChildren1').empty().trigger("change"); 2398 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2399 $('#noInfants1').empty().trigger("change"); 2400 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2401 $('#noAdults2').empty().trigger("change"); 2402 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2403 $('#noChildren2').empty().trigger("change"); 2404 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2405 $('#noInfants2').empty().trigger("change"); 2406 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2407 $('#noAdults3').empty().trigger("change"); 2408 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2409 $('#noChildren3').empty().trigger("change"); 2410 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2411 $('#noInfants3').empty().trigger("change"); 2412 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2413 $('#noAdults4').empty().trigger("change"); 2414 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2415 $('#noChildren4').empty().trigger("change"); 2416 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2417 $('#noInfants4').empty().trigger("change"); 2418 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2419 $('#noAdults5').empty().trigger("change"); 2420 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2421 $('#noChildren5').empty().trigger("change"); 2422 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2423 $('#noInfants5').empty().trigger("change"); 2424 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2425 2426 var value = parseInt($('#noRooms').val()); 2427 showGuests(value); 2428 } 2429 else if(accomodationType == 'PMLTDSELF'){ 2430 $('#noNights').empty().trigger("change"); 2431 $('#noNights').select2({ 2432 minimumResultsForSearch: Infinity, 2433 data: dataNightsCottage 2434 }); 2435 $('#noNights').parent().parent().removeClass('col-xs-6'); 2436 $('#noNights').parent().parent().addClass('col-xs-12'); 2437 2438 $('#noRooms').empty().trigger("change"); 2439 $('#noRooms').select2({ 2440 minimumResultsForSearch: Infinity, 2441 data: dataRoomsCottage 2442 }); 2443 2444 $('.noRoomsTexts').hide(); 2445 $('.noCampersTexts').hide(); 2446 $('.noCottagesTexts').show(); 2447 2448 $('#noAdults1').empty().trigger("change"); 2449 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2450 $('#noChildren1').empty().trigger("change"); 2451 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2452 $('#noInfants1').empty().trigger("change"); 2453 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2454 $('#noAdults2').empty().trigger("change"); 2455 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2456 $('#noChildren2').empty().trigger("change"); 2457 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2458 $('#noInfants2').empty().trigger("change"); 2459 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2460 $('#noAdults3').empty().trigger("change"); 2461 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2462 $('#noChildren3').empty().trigger("change"); 2463 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2464 $('#noInfants3').empty().trigger("change"); 2465 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2466 $('#noAdults4').empty().trigger("change"); 2467 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2468 $('#noChildren4').empty().trigger("change"); 2469 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2470 $('#noInfants4').empty().trigger("change"); 2471 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2472 $('#noAdults5').empty().trigger("change"); 2473 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2474 $('#noChildren5').empty().trigger("change"); 2475 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2476 $('#noInfants5').empty().trigger("change"); 2477 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2478 2479 var value = parseInt($('#noRooms').val()); 2480 showGuests(value); 2481 } 2482 else if(accomodationType == 'PMLTDCAMP') { 2483 $('#noNights').empty().trigger("change"); 2484 $('#noNights').select2({ 2485 minimumResultsForSearch: Infinity, 2486 data: dataNightsCampers 2487 }); 2488 $('#noNights').parent().parent().removeClass('col-xs-6'); 2489 $('#noNights').parent().parent().addClass('col-xs-12'); 2490 2491 $('#noRooms').empty().trigger("change"); 2492 $('#noRooms').select2({ 2493 minimumResultsForSearch: Infinity, 2494 data: dataRoomsCampers 2495 }); 2496 2497 $('.noRoomsTexts').hide(); 2498 $('.noCampersTexts').show(); 2499 $('.noCottagesTexts').hide(); 2500 2501 $('#noAdults1').empty().trigger("change"); 2502 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2503 $('#noChildren1').empty().trigger("change"); 2504 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2505 $('#noInfants1').empty().trigger("change"); 2506 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2507 $('#noAdults2').empty().trigger("change"); 2508 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2509 $('#noChildren2').empty().trigger("change"); 2510 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2511 $('#noInfants2').empty().trigger("change"); 2512 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2513 $('#noAdults3').empty().trigger("change"); 2514 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2515 $('#noChildren3').empty().trigger("change"); 2516 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2517 $('#noInfants3').empty().trigger("change"); 2518 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2519 $('#noAdults4').empty().trigger("change"); 2520 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2521 $('#noChildren4').empty().trigger("change"); 2522 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2523 $('#noInfants4').empty().trigger("change"); 2524 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2525 $('#noAdults5').empty().trigger("change"); 2526 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2527 $('#noChildren5').empty().trigger("change"); 2528 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2529 $('#noInfants5').empty().trigger("change"); 2530 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2531 2532 var value = parseInt($('#noRooms').val()); 2533 showGuests(value); 2534 } 2535 else{ 2536 $('#noNights').select2({ 2537 placeholder: '0', 2538 minimumResultsForSearch: Infinity, 2539 language: { 2540 "noResults": function(){ 2541 return "Please select accomodation type"; 2542 } 2543 }, 2544 escapeMarkup: function(markup){ 2545 return markup; 2546 } 2547 }); 2548 $('#noRooms').select2({ 2549 placeholder: '0', 2550 minimumResultsForSearch: Infinity, 2551 language: { 2552 "noResults": function(){ 2553 return "Please select accomodation type"; 2554 } 2555 }, 2556 escapeMarkup: function(markup){ 2557 return markup; 2558 } 2559 }); 2560 } 2561 2562 // Re-set old inputs 2563 $('#noNights').val($('#noNights').data('old')); 2564 $('#noNights').trigger('change'); 2565 2566 $('#noRooms').val($('#noRooms').data('old')); 2567 $('#noRooms').trigger('change'); 2568 2569 var value = parseInt($('#noRooms').val()); 2570 showGuests(value); 2571 2572 for(var i = 1; i <= 5; i++) { 2573 $('#noAdults' + i).val($('#noAdults' + i).data('old')) 2574 $('#noAdults' + i).trigger('change'); 2575 2576 $('#noChildren' + i).val($('#noChildren' + i).data('old')) 2577 $('#noChildren' + i).trigger('change'); 2578 2579 $('#noInfants' + i).val($('#noInfants' + i).data('old')) 2580 $('#noInfants' + i).trigger('change'); 2581 } 2582 2583 $('#noAdults').select2({ 2584 placeholder: '0', 2585 minimumResultsForSearch: Infinity, 2586 language: { 2587 "noResults": function(){ 2588 return "Please select accomodation type"; 2589 } 2590 }, 2591 escapeMarkup: function(markup){ 2592 return markup; 2593 } 2594 }); 2595 $('#noChildren').select2({ 2596 placeholder: '0', 2597 minimumResultsForSearch: Infinity, 2598 language: { 2599 "noResults": function(){ 2600 return "Please select accomodation type"; 2601 } 2602 }, 2603 escapeMarkup: function(markup){ 2604 return markup; 2605 } 2606 }); 2607 $('#noInfants').select2({ 2608 placeholder: '0', 2609 minimumResultsForSearch: Infinity, 2610 language: { 2611 "noResults": function(){ 2612 return "Please select accomodation type"; 2613 } 2614 }, 2615 escapeMarkup: function(markup){ 2616 return markup; 2617 } 2618 }); 2619 // $('#noAdults1').select2({minimumResultsForSearch: Infinity}); 2620 // $('#noChildren1').select2({minimumResultsForSearch: Infinity}); 2621 // $('#noInfants1').select2({minimumResultsForSearch: Infinity}); 2622 // $('#noAdults2').select2({minimumResultsForSearch: Infinity}); 2623 // $('#noChildren2').select2({minimumResultsForSearch: Infinity}); 2624 // $('#noInfants2').select2({minimumResultsForSearch: Infinity}); 2625 // $('#noAdults3').select2({minimumResultsForSearch: Infinity}); 2626 // $('#noChildren3').select2({minimumResultsForSearch: Infinity}); 2627 // $('#noInfants3').select2({minimumResultsForSearch: Infinity}); 2628 // $('#noAdults4').select2({minimumResultsForSearch: Infinity}); 2629 // $('#noChildren4').select2({minimumResultsForSearch: Infinity}); 2630 // $('#noInfants4').select2({minimumResultsForSearch: Infinity}); 2631 // $('#noAdults5').select2({minimumResultsForSearch: Infinity}); 2632 // $('#noChildren5').select2({minimumResultsForSearch: Infinity}); 2633 // $('#noInfants5').select2({minimumResultsForSearch: Infinity}); 2634 2635 // change events 2636 $('#accomodationType').change(function(){ 2637 var value = $(this).val(); 2638 if(value == 'PMLTDSERV'){ 2639 $('#noNights').empty().trigger("change"); 2640 $('#noNights').select2({ 2641 minimumResultsForSearch: Infinity, 2642 data: dataNightsHotel 2643 }); 2644 $('#noNights').parent().parent().removeClass('col-xs-12'); 2645 $('#noNights').parent().parent().addClass('col-xs-6'); 2646 2647 $('#noRooms').empty().trigger("change"); 2648 $('#noRooms').select2({ 2649 minimumResultsForSearch: Infinity, 2650 data: dataRoomsHotel 2651 }); 2652
2653 $('.noRoomsTexts').show(); 2654 $('.noCottagesTexts').hide(); 2655 $('.noCampersTexts').hide(); 2656 2657 $('#noAdults1').empty().trigger("change"); 2658 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2659 $("#noAdults1").select2("val", "2"); 2660 $('#noChildren1').empty().trigger("change"); 2661 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2662 $('#noInfants1').empty().trigger("change"); 2663 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2664 $('#noAdults2').empty().trigger("change"); 2665 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2666 $("#noAdults2").select2("val", "2"); 2667 $('#noChildren2').empty().trigger("change"); 2668 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2669 $('#noInfants2').empty().trigger("change"); 2670 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2671 $('#noAdults3').empty().trigger("change"); 2672 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2673 $("#noAdults3").select2("val", "2"); 2674 $('#noChildren3').empty().trigger("change"); 2675 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2676 $('#noInfants3').empty().trigger("change"); 2677 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2678 $('#noAdults4').empty().trigger("change"); 2679 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2680 $("#noAdults4").select2("val", "2"); 2681 $('#noChildren4').empty().trigger("change"); 2682 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2683 $('#noInfants4').empty().trigger("change"); 2684 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2685 $('#noAdults5').empty().trigger("change"); 2686 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2687 $("#noAdults5").select2("val", "2"); 2688 $('#noChildren5').empty().trigger("change"); 2689 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2690 $('#noInfants5').empty().trigger("change"); 2691 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2692 2693 var value = parseInt($('#noRooms').val()); 2694 showGuests(value); 2695 $('#book_error').hide(); 2696 } 2697 else if(value == 'PMLTDSELF'){ 2698 $('#noNights').empty().trigger("change"); 2699 $('#noNights').select2({ 2700 minimumResultsForSearch: Infinity, 2701 data: dataNightsCottage 2702 }); 2703 $('#noNights').parent().parent().removeClass('col-xs-6'); 2704 $('#noNights').parent().parent().addClass('col-xs-12'); 2705 2706 $('#noRooms').empty().trigger("change"); 2707 $('#noRooms').select2({ 2708 minimumResultsForSearch: Infinity, 2709 data: dataRoomsCottage 2710 }); 2711 2712 $('.noRoomsTexts').hide(); 2713 $('.noCampersTexts').hide(); 2714 $('.noCottagesTexts').show(); 2715 2716 $('#noAdults1').empty().trigger("change"); 2717 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2718 $("#noAdults1").select2("val", "2"); 2719 $('#noChildren1').empty().trigger("change"); 2720 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2721 $('#noInfants1').empty().trigger("change"); 2722 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2723 $('#noAdults2').empty().trigger("change"); 2724 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2725 $("#noAdults2").select2("val", "2"); 2726 $('#noChildren2').empty().trigger("change"); 2727 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2728 $('#noInfants2').empty().trigger("change"); 2729 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2730 $('#noAdults3').empty().trigger("change"); 2731 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2732 $("#noAdults3").select2("val", "2"); 2733 $('#noChildren3').empty().trigger("change"); 2734 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2735 $('#noInfants3').empty().trigger("change"); 2736 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2737 $('#noAdults4').empty().trigger("change"); 2738 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2739 $("#noAdults4").select2("val", "2"); 2740 $('#noChildren4').empty().trigger("change"); 2741 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2742 $('#noInfants4').empty().trigger("change"); 2743 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2744 $('#noAdults5').empty().trigger("change"); 2745 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2746 $("#noAdults5").select2("val", "2"); 2747 $('#noChildren5').empty().trigger("change"); 2748 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2749 $('#noInfants5').empty().trigger("change"); 2750 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2751 2752 var value = parseInt($('#noRooms').val()); 2753 showGuests(value); 2754 $('#book_error').hide(); 2755 } else if(value == 'PMLTDCAMP') { 2756 $('#noNights').empty().trigger("change"); 2757 $('#noNights').select2({ 2758 minimumResultsForSearch: Infinity, 2759 data: dataNightsCampers 2760 }); 2761 $('#noNights').parent().parent().removeClass('col-xs-6'); 2762 $('#noNights').parent().parent().addClass('col-xs-12'); 2763 2764 $('#noRooms').empty().trigger("change"); 2765 $('#noRooms').select2({ 2766 minimumResultsForSearch: Infinity, 2767 data: dataRoomsCampers 2768 }); 2769
2770 $('.noRoomsTexts').hide(); 2771 $('.noCampersTexts').show(); 2772 $('.noCottagesTexts').hide(); 2773 2774 $('#noAdults1').empty().trigger("change"); 2775 $('#noAdults1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2776 $("#noAdults1").select2("val", "2"); 2777 $('#noChildren1').empty().trigger("change"); 2778 $('#noChildren1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2779 $('#noInfants1').empty().trigger("change"); 2780 $('#noInfants1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2781 $('#noAdults2').empty().trigger("change"); 2782 $('#noAdults2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2783 $("#noAdults2").select2("val", "2"); 2784 $('#noChildren2').empty().trigger("change"); 2785 $('#noChildren2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2786 $('#noInfants2').empty().trigger("change"); 2787 $('#noInfants2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2788 $('#noAdults3').empty().trigger("change"); 2789 $('#noAdults3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2790 $("#noAdults3").select2("val", "2"); 2791 $('#noChildren3').empty().trigger("change"); 2792 $('#noChildren3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2793 $('#noInfants3').empty().trigger("change"); 2794 $('#noInfants3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2795 $('#noAdults4').empty().trigger("change"); 2796 $('#noAdults4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2797 $("#noAdults4").select2("val", "2"); 2798 $('#noChildren4').empty().trigger("change"); 2799 $('#noChildren4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2800 $('#noInfants4').empty().trigger("change"); 2801 $('#noInfants4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2802 $('#noAdults5').empty().trigger("change"); 2803 $('#noAdults5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2804 $("#noAdults5").select2("val", "2"); 2805 $('#noChildren5').empty().trigger("change"); 2806 $('#noChildren5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 2807 $('#noInfants5').empty().trigger("change"); 2808 $('#noInfants5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 2809 2810 var value = parseInt($('#noRooms').val()); 2811 showGuests(value); 2812 $('#book_error').hide(); 2813 } 2814 }); 2815 2816 $('#noRooms').change(function(){ 2817 var value = parseInt($('#noRooms').val()); 2818 showGuests(value); 2819 }); 2820 2821 2822 2823 // open close events 2824 $('.bookNowButton').click(function(e){ 2825 e.preventDefault(); 2826 pos = $(window).scrollTop(); 2827 $("html, body").animate({ scrollTop: 0 }, "slow"); 2828 // $('#book_now').css('top', pos + 'px'); 2829 // $('#book_now_box').css('top', pos + 'px'); 2830 $('#book_now').show(); 2831 $('#book_now_box').show(); 2832 $('body').addClass('book-on'); 2833 }); 2834 $('#book_now, #book_now_close').click(function(e){ 2835 $('body').removeClass('book-on'); 2836 $('#book_now').hide(); 2837 $('#book_now_box').hide(); 2838 }); 2839 2840 // submit 2841 $('#form_book_now').submit(function(e){ 2842 var accomodationType = $('#accomodationType').val(); 2843 2844 if(accomodationType == "PMLTDSERV"){ 2845 $(this).attr('action', '/reservations/hotels'); 2846 SearchOverlay.start(); 2847 } 2848 else if(accomodationType == "PMLTDSELF"){ 2849 $(this).attr('action', '/reservations/results'); 2850 SearchOverlay.start(); 2851 } 2852 else if(accomodationType == "PMLTDCAMP") { 2853 $(this).attr('action', '/reservations/results'); 2854 } 2855 else{ 2856 $('#book_error').show(0); 2857 e.preventDefault(); 2858 } 2859 2860 }); 2861 2862 // 2863 // BOOK NOW END 2864 // 2865 2866 // 2867 // BOOK NOW PAGE START 2868 // 2869 2870 // initialization 2871 $('#accomodationTypePage').select2({ 2872 placeholder: '--- Please select ---', 2873 minimumResultsForSearch: Infinity 2874 }); 2875 2876 var accomodationType = $('#accomodationTypePage').val(); 2877 if(accomodationType == 'PMLTDSERV'){ 2878 $('#noNightsPage').empty().trigger("change"); 2879 $('#noNightsPage').select2({ 2880 minimumResultsForSearch: Infinity, 2881 data: dataNightsHotel 2882 }); 2883 2884 $('#noRoomsPage').empty().trigger("change"); 2885 $('#noRoomsPage').select2({ 2886 minimumResultsForSearch: Infinity, 2887 data: dataRoomsHotel 2888 }); 2889 2890 $('#noAdultsPage1').empty().trigger("change"); 2891 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2892 $('#noChildrenPage1').empty().trigger("change"); 2893 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2894 $('#noInfantsPage1').empty().trigger("change"); 2895 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2896 $('#noAdultsPage2').empty().trigger("change"); 2897 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2898 $('#noChildrenPage2').empty().trigger("change"); 2899 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2900 $('#noInfantsPage2').empty().trigger("change"); 2901 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2902 $('#noAdultsPage3').empty().trigger("change"); 2903 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2904 $('#noChildrenPage3').empty().trigger("change"); 2905 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2906 $('#noInfantsPage3').empty().trigger("change"); 2907 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2908 $('#noAdultsPage4').empty().trigger("change"); 2909 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2910 $('#noChildrenPage4').empty().trigger("change"); 2911 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2912 $('#noInfantsPage4').empty().trigger("change"); 2913 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2914 $('#noAdultsPage5').empty().trigger("change"); 2915 $('#noAdultsPage5').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 2916 $('#noChildrenPage5').empty().trigger("change"); 2917 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 2918 $('#noInfantsPage5').empty().trigger("change"); 2919 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 2920 2921 var value = parseInt($('#noRoomsPage').val()); 2922 showGuestsPage(value); 2923 } 2924 else if(accomodationType == 'PMLTDSELF'){ 2925 $('#noNightsPage').empty().trigger("change"); 2926 $('#noNightsPage').select2({ 2927 minimumResultsForSearch: Infinity, 2928 data: dataNightsCottage 2929 }); 2930 $('#noNightsPage').parent().parent().removeClass('col-xs-6'); 2931 $('#noNightsPage').parent().parent().addClass('col-xs-12'); 2932 2933 $('#noRoomsPage').empty().trigger("change"); 2934 $('#noRoomsPage').select2({ 2935 minimumResultsForSearch: Infinity, 2936 data: dataRoomsCottage 2937 }); 2938 2939 $('.noRoomsTexts').hide(); 2940 $('.noCottagesTexts').show(); 2941 $('.noCampersTexts').hide(); 2942 2943 $('#noAdultsPage1').empty().trigger("change"); 2944 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2945 $('#noChildrenPage1').empty().trigger("change"); 2946 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2947 $('#noInfantsPage1').empty().trigger("change"); 2948 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2949 $('#noAdultsPage2').empty().trigger("change"); 2950 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2951 $('#noChildrenPage2').empty().trigger("change"); 2952 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2953 $('#noInfantsPage2').empty().trigger("change"); 2954 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2955 $('#noAdultsPage3').empty().trigger("change"); 2956 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2957 $('#noChildrenPage3').empty().trigger("change"); 2958 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2959 $('#noInfantsPage3').empty().trigger("change"); 2960 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2961 $('#noAdultsPage4').empty().trigger("change"); 2962 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2963 $('#noChildrenPage4').empty().trigger("change"); 2964 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2965 $('#noInfantsPage4').empty().trigger("change"); 2966 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2967 $('#noAdultsPage5').empty().trigger("change"); 2968 $('#noAdultsPage5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 2969 $('#noChildrenPage5').empty().trigger("change"); 2970 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 2971 $('#noInfantsPage5').empty().trigger("change"); 2972 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 2973 2974 var value = parseInt($('#noRoomsPage').val()); 2975 showGuestsPage(value); 2976 } 2977 else if(accomodationType == 'PMLTDCAMP'){ 2978 $('#noNightsPage').empty().trigger("change"); 2979 $('#noNightsPage').select2({ 2980 minimumResultsForSearch: Infinity, 2981 data: dataNightsCampers 2982 }); 2983 $('#noNightsPage').parent().parent().removeClass('col-xs-6'); 2984 $('#noNightsPage').parent().parent().addClass('col-xs-12'); 2985 2986 $('#noRoomsPage').empty().trigger("change"); 2987 $('#noRoomsPage').select2({ 2988 minimumResultsForSearch: Infinity, 2989 data: dataRoomsCampers 2990 }); 2991 2992 $('.noRoomsTexts').hide(); 2993 $('.noCottagesTexts').hide(); 2994 $('.noCampersTexts').show(); 2995 2996 $('#noAdultsPage1').empty().trigger("change"); 2997 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 2998 $('#noChildrenPage1').empty().trigger("change"); 2999 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3000 $('#noInfantsPage1').empty().trigger("change"); 3001 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3002 $('#noAdultsPage2').empty().trigger("change"); 3003 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3004 $('#noChildrenPage2').empty().trigger("change"); 3005 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3006 $('#noInfantsPage2').empty().trigger("change"); 3007 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3008 $('#noAdultsPage3').empty().trigger("change"); 3009 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3010 $('#noChildrenPage3').empty().trigger("change"); 3011 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3012 $('#noInfantsPage3').empty().trigger("change"); 3013 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3014 $('#noAdultsPage4').empty().trigger("change"); 3015 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3016 $('#noChildrenPage4').empty().trigger("change"); 3017 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3018 $('#noInfantsPage4').empty().trigger("change"); 3019 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3020 $('#noAdultsPage5').empty().trigger("change"); 3021 $('#noAdultsPage5').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3022 $('#noChildrenPage5').empty().trigger("change"); 3023 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3024 $('#noInfantsPage5').empty().trigger("change"); 3025 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3026 3027 var value = parseInt($('#noRoomsPage').val()); 3028 showGuestsPage(value); 3029 } 3030 else{ 3031 $('#noNightsPage').select2({ 3032 placeholder: '0', 3033 minimumResultsForSearch: Infinity, 3034 language: { 3035 "noResults": function(){ 3036 return "Please select accomodation type"; 3037 } 3038 }, 3039 escapeMarkup: function(markup){ 3040 return markup; 3041 } 3042 }); 3043 $('#noRoomsPage').select2({ 3044 placeholder: '0', 3045 minimumResultsForSearch: Infinity, 3046 language: { 3047 "noResults": function(){ 3048 return "Please select accomodation type"; 3049 } 3050 }, 3051 escapeMarkup: function(markup){ 3052 return markup; 3053 } 3054 }); 3055 } 3056 3057 // Re-set old inputs 3058 $('#noNightsPage').val($('#noNightsPage').data('old')); 3059 $('#noNightsPage').trigger('change'); 3060 3061 $('#noRoomsPage').val($('#noRoomsPage').data('old')); 3062 $('#noRoomsPage').trigger('change'); 3063 3064 var value = parseInt($('#noRoomsPage').val()); 3065 showGuestsPage(value); 3066 3067 for(var i = 1; i <= 5; i++) { 3068 $('#noAdultsPage' + i).val($('#noAdultsPage' + i).data('old')) 3069 $('#noAdultsPage' + i).trigger('change'); 3070 3071 $('#noChildrenPage' + i).val($('#noChildrenPage' + i).data('old')) 3072 $('#noChildrenPage' + i).trigger('change'); 3073 3074 $('#noInfantsPage' + i).val($('#noInfantsPage' + i).data('old')) 3075 $('#noInfantsPage' + i).trigger('change'); 3076 } 3077 3078 $('#noAdultsPage').select2({ 3079 placeholder: '0', 3080 minimumResultsForSearch: Infinity, 3081 language: { 3082 "noResults": function(){ 3083 return "Please select accomodation type"; 3084 } 3085 }, 3086 escapeMarkup: function(markup){ 3087 return markup; 3088 } 3089 }); 3090 $('#noChildrenPage').select2({ 3091 placeholder: '0', 3092 minimumResultsForSearch: Infinity, 3093 language: { 3094 "noResults": function(){ 3095 return "Please select accomodation type"; 3096 } 3097 }, 3098 escapeMarkup: function(markup){ 3099 return markup; 3100 } 3101 }); 3102 $('#noInfantsPage').select2({ 3103 placeholder: '0', 3104 minimumResultsForSearch: Infinity, 3105 language: { 3106 "noResults": function(){ 3107 return "Please select accomodation type"; 3108 } 3109 }, 3110 escapeMarkup: function(markup){ 3111 return markup; 3112 } 3113 }); 3114 3115 // change events 3116 $('#accomodationTypePage').change(function(){ 3117 var value = $(this).val(); 3118 if(value == 'PMLTDSERV'){ 3119 $('#noNightsPage').empty().trigger("change"); 3120 $('#noNightsPage').select2({ 3121 minimumResultsForSearch: Infinity, 3122 data: dataNightsHotel 3123 }); 3124 $('#noNightsPage').parent().parent().removeClass('col-xs-12'); 3125 $('#noNightsPage').parent().parent().addClass('col-xs-6'); 3126 3127 $('#noRoomsPage').empty().trigger("change"); 3128 $('#noRoomsPage').select2({ 3129 minimumResultsForSearch: Infinity, 3130 data: dataRoomsHotel 3131 }); 3132
3133 $('.noRoomsTexts').show(); 3134 $('.noCottagesTexts').hide(); 3135 $('.noCampersTexts').hide(); 3136 3137 $('#noAdultsPage1').empty().trigger("change"); 3138 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 3139 $('#noChildrenPage1').empty().trigger("change"); 3140 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 3141 $('#noInfantsPage1').empty().trigger("change"); 3142 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 3143 $('#noAdultsPage2').empty().trigger("change"); 3144 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 3145 $('#noChildrenPage2').empty().trigger("change"); 3146 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 3147 $('#noInfantsPage2').empty().trigger("change"); 3148 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 3149 $('#noAdultsPage3').empty().trigger("change"); 3150 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 3151 $('#noChildrenPage3').empty().trigger("change"); 3152 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 3153 $('#noInfantsPage3').empty().trigger("change"); 3154 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 3155 $('#noAdultsPage4').empty().trigger("change"); 3156 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 3157 $('#noChildrenPage4').empty().trigger("change"); 3158 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 3159 $('#noInfantsPage4').empty().trigger("change"); 3160 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 3161 $('#noAdultsPage5').empty().trigger("change"); 3162 $('#noAdultsPage5').select2({minimumResultsForSearch: Infinity,data: dataAdultsHotel}); 3163 $('#noChildrenPage5').empty().trigger("change"); 3164 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenHotel}); 3165 $('#noInfantsPage5').empty().trigger("change"); 3166 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsHotel}); 3167 3168 var value = parseInt($('#noRoomsPage').val()); 3169 showGuestsPage(value); 3170 $('#book_error_page').hide(); 3171 } 3172 else if(value == 'PMLTDSELF'){ 3173 $('#noNightsPage').empty().trigger("change"); 3174 $('#noNightsPage').select2({ 3175 minimumResultsForSearch: Infinity, 3176 data: dataNightsCottage 3177 }); 3178 $('#noNightsPage').parent().parent().removeClass('col-xs-6'); 3179 $('#noNightsPage').parent().parent().addClass('col-xs-12'); 3180 3181 $('#noRoomsPage').empty().trigger("change"); 3182 $('#noRoomsPage').select2({ 3183 minimumResultsForSearch: Infinity, 3184 data: dataRoomsCottage 3185 }); 3186 3187 $('.noRoomsTexts').hide(); 3188 $('.noCottagesTexts').show(); 3189 $('.noCampersTexts').hide(); 3190 3191 $('#noAdultsPage1').empty().trigger("change"); 3192 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 3193 $('#noChildrenPage1').empty().trigger("change"); 3194 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 3195 $('#noInfantsPage1').empty().trigger("change"); 3196 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 3197 $('#noAdultsPage2').empty().trigger("change"); 3198 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 3199 $('#noChildrenPage2').empty().trigger("change"); 3200 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 3201 $('#noInfantsPage2').empty().trigger("change"); 3202 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 3203 $('#noAdultsPage3').empty().trigger("change"); 3204 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 3205 $('#noChildrenPage3').empty().trigger("change"); 3206 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 3207 $('#noInfantsPage3').empty().trigger("change"); 3208 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 3209 $('#noAdultsPage4').empty().trigger("change"); 3210 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 3211 $('#noChildrenPage4').empty().trigger("change"); 3212 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 3213 $('#noInfantsPage4').empty().trigger("change"); 3214 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 3215 $('#noAdultsPage5').empty().trigger("change"); 3216 $('#noAdults5Page').select2({minimumResultsForSearch: Infinity,data: dataAdultsCottage}); 3217 $('#noChildrenPage5').empty().trigger("change"); 3218 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCottage}); 3219 $('#noInfantsPage5').empty().trigger("change"); 3220 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCottage}); 3221 3222 var value = parseInt($('#noRoomsPage').val()); 3223 showGuestsPage(value); 3224 (value); 3225 $('#book_error_page').hide(); 3226 } 3227 else if(value == 'PMLTDCAMP'){ 3228 $('#noNightsPage').empty().trigger("change"); 3229 $('#noNightsPage').select2({ 3230 minimumResultsForSearch: Infinity, 3231 data: dataNightsCampers 3232 }); 3233 $('#noNightsPage').parent().parent().removeClass('col-xs-6'); 3234 $('#noNightsPage').parent().parent().addClass('col-xs-12'); 3235 3236 $('#noRoomsPage').empty().trigger("change"); 3237 $('#noRoomsPage').select2({ 3238 minimumResultsForSearch: Infinity, 3239 data: dataRoomsCampers 3240 }); 3241
3242 $('.noRoomsTexts').hide(); 3243 $('.noCottagesTexts').hide(); 3244 $('.noCampersTexts').show(); 3245 3246 3247 $('#noAdultsPage1').empty().trigger("change"); 3248 $('#noAdultsPage1').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3249 $('#noChildrenPage1').empty().trigger("change"); 3250 $('#noChildrenPage1').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3251 $('#noInfantsPage1').empty().trigger("change"); 3252 $('#noInfantsPage1').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3253 $('#noAdultsPage2').empty().trigger("change"); 3254 $('#noAdultsPage2').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3255 $('#noChildrenPage2').empty().trigger("change"); 3256 $('#noChildrenPage2').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3257 $('#noInfantsPage2').empty().trigger("change"); 3258 $('#noInfantsPage2').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3259 $('#noAdultsPage3').empty().trigger("change"); 3260 $('#noAdultsPage3').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3261 $('#noChildrenPage3').empty().trigger("change"); 3262 $('#noChildrenPage3').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3263 $('#noInfantsPage3').empty().trigger("change"); 3264 $('#noInfantsPage3').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3265 $('#noAdultsPage4').empty().trigger("change"); 3266 $('#noAdultsPage4').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3267 $('#noChildrenPage4').empty().trigger("change"); 3268 $('#noChildrenPage4').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3269 $('#noInfantsPage4').empty().trigger("change"); 3270 $('#noInfantsPage4').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3271 $('#noAdultsPage5').empty().trigger("change"); 3272 $('#noAdults5Page').select2({minimumResultsForSearch: Infinity,data: dataAdultsCampers}); 3273 $('#noChildrenPage5').empty().trigger("change"); 3274 $('#noChildrenPage5').select2({minimumResultsForSearch: Infinity,data: dataChildrenCampers}); 3275 $('#noInfantsPage5').empty().trigger("change"); 3276 $('#noInfantsPage5').select2({minimumResultsForSearch: Infinity,data: dataInfantsCampers}); 3277 3278 var value = parseInt($('#noRoomsPage').val()); 3279 showGuestsPage(value); 3280 (value); 3281 $('#book_error_page').hide(); 3282 } 3283 }); 3284 3285 $('#noRoomsPage').change(function(){ 3286 var value = parseInt($('#noRoomsPage').val()); 3287 showGuestsPage(value); 3288 (value); 3289 }); 3290 3291 // submit 3292 $('#form_book_now_page').submit(function(e){ 3293 var accomodationType = $('#accomodationTypePage').val(); 3294 3295 if(accomodationType == "PMLTDSERV"){ 3296 $(this).attr('action', '/reservations/hotels'); 3297 SearchOverlay.start(); 3298 } 3299 else if(accomodationType == "PMLTDSELF"){ 3300 $(this).attr('action', '/reservations/results'); 3301 SearchOverlay.start(); 3302 } 3303 else if(accomodationType == "PMLTDCAMP"){ 3304 $(this).attr('action', '/reservations/results'); 3305 SearchOverlay.start(); 3306 } 3307 else{ 3308 $('#book_error_page').show(0); 3309 e.preventDefault(); 3310 } 3311 3312 }); 3313 3314 if($('#bn_form').length) { 3315 $('#bn_form label').matchHeight(); 3316 } 3317 3318 3319 3320 // 3321 // BOOK NOW PAGE END 3322 // 3323 3324 // Tour Guide 3325 $('#tour_guide').select2({ 3326 placeholder: 'Please select', 3327 minimumResultsForSearch: Infinity 3328 }); 3329 3330 // Section boxes 3331 $.when( 3332 $('.section-boxes .section-slick').slick({ 3333 lazyLoad: 'progressive', 3334 }) 3335 ).done( function(x){ 3336 $('.section-boxes .match-height').matchHeight(); 3337 $('.section-boxes .slider-inner').addClass('positioned'); 3338 $('.section-boxes .content-inner').addClass('positioned'); 3339 }); 3340 3341 // Page Section boxes 3342 $.when( 3343 $('.page-section-boxes .section-slick').slick({ 3344 lazyLoad: 'progressive', 3345 }) 3346 ).done( function(x){ 3347 $('.page-section-boxes .match-height').matchHeight(); 3348 $('.page-section-boxes .slider-inner').addClass('positioned'); 3349 $('.page-section-boxes .content-inner').addClass('positioned'); 3350 }); 3351 3352 // Slider boxes 3353 $.when( 3354 $('.slider-boxes .slider-boxes-slick').slick({ 3355 lazyLoad: 'progressive', 3356 slidesToShow: 3, 3357 responsive: [ 3358 { 3359 breakpoint: 1023, 3360 settings: { 3361 slidesToShow: 2, 3362 } 3363 }, 3364 { 3365 breakpoint: 767, 3366 settings: { 3367 slidesToShow: 1, 3368 } 3369 } 3370 ] 3371 }) 3372 ).done( function(x){ 3373 $('.slider-boxes .match-height').matchHeight({byRow:false}); 3374 }); 3375 3376 // Content Box Slider Box 3377 $('.slick-slider-content-block').slick(); 3378 3379 // Card Slider Image 3380 $.when( 3381 $('.slick-slider-card-images').slick({ 3382 lazyLoad: 'progressive', 3383 slidesToShow: 1,
3384 arrows: false, 3385 autoplay: true, 3386 autoplaySpeed: 2000 3387 }) 3388 ).done( function(x){ 3389 $('.multi_row_grid_container .match-height').matchHeight({byRow:false}); 3390 }); 3391 3392 // SIDE MENU 3393 $('.region-title').click(function(event){ 3394 $this = $(this); 3395 $content = $this.siblings('.region-content'); 3396 3397 if($this.hasClass('open')){ 3398 $content.removeClass('open'); 3399 $this.removeClass('open'); 3400 } 3401 else{ 3402 $content.addClass('open'); 3403 $this.addClass('open'); 3404 } 3405 }); 3406 3407 // BLOG SEARCH 3408 $('#blog_search_button').click(function(e){ 3409 $('#blog_search_form').submit(); 3410 }); 3411 3412 resizeTasks(); 3413}); 3414 3415$(window).resize(function() { 3416 resizeTasks(); 3417}); 3418 3419$(window).scroll(function() { 3420 // Header width 3421 pos = $(window).scrollTop(); 3422 if (pos > 300) { 3423 $(".header-logo").addClass("small-logo"); 3424 $(".header-bar").addClass("small-bar"); 3425 $(".header-weather").fadeOut('fast'); 3426 $(".header-details").fadeOut('fast'); 3427 } 3428 else{ 3429 $(".header-logo").removeClass("small-logo"); 3430 $(".header-bar").removeClass("small-bar"); 3431 $(".header-weather").fadeIn('slow'); 3432 $(".header-details").fadeIn('slow'); 3433 } 3434}); 3435 3436$(window).on('load', function() { 3437 resizeTasks(); 3438}); 3439 3440active = false; 3441 3442const lazyLoad = function() { 3443 if (active === false) { 3444 active = true; 3445 lazyImages = [].slice.call(document.querySelectorAll("img.lazy")); 3446 3447 setTimeout(function() { 3448 lazyImages.forEach(function(lazyImage) { 3449 if ((lazyImage.getBoundingClientRect().top <= window.innerHeight && lazyImage.getBoundingClientRect().bottom >= 0) && getComputedStyle(lazyImage).display !== "none") { 3450 lazyImage.src = lazyImage.dataset.src; 3451 if (lazyImage.dataset.srcset) { lazyImage.srcset = lazyImage.dataset.srcset; } 3452 lazyImage.classList.remove("lazy"); 3453 3454 lazyImages = lazyImages.filter(function(image) { 3455 return image !== lazyImage; 3456 }); 3457 3458 } 3459 }); 3460 active = false; 3461 }, 200); 3462 } 3463}; 3464 3465document.addEventListener("scroll", lazyLoad); 3466window.addEventListener("resize", lazyLoad); 3467window.addEventListener("orientationchange", lazyLoad); 3468document.addEventListener("DOMContentLoaded", lazyLoad); 3469 3470 3471/* -------------------------------- 3472* Add another 'Education and Qualifications' 3473* uses underscore.js 3474---------------------------------*/ 3475if($("#eduQual").length){ 3476 3477 var EDUQUAL_TEMPLATE = _.template( 3478 '<div class="controls addAnotherControls" style="width:100%;">' + 3479 3480 // Content (To be the same as baseApplicationForm.php) 3481 // '<textarea name="<%=fieldname_establishment%>"></textarea>'+ 3482 3483 '<div class="col col-sm-4">'+ 3484 ' <input type="text" name="<%=fieldname_establishment%>" class="form_input" placeholder="Establishment" value="">'+ 3485 '</div>'+ 3486 '<div class="col col-sm-4">'+ 3487 ' <input type="text" name="<%=fieldname_qualification%>" class="form_input" placeholder="Qualification" value="">'+ 3488 '</div>'+ 3489 '<div class="col col-sm-4">'+ 3490 '<input type="text" name="<%=fieldname_subject%>" class="form_input" placeholder="Subject" value="">'+ 3491 '</div>'+ 3492 3493 // Delete 3494 '<span class="span2"><a href="#" class="deleteEduQual" title="Delete this block"><i class="fa fa-times-circle text-error" aria-hidden="true"></i></a></span>'+ 3495 3496 '<div class="clearfix"></div><br />' + 3497 '</div>' 3498 ); 3499 3500 const EDUQUAL_OBJECT = { 3501 fieldname_establishment: "" 3502 ,fieldname_qualification: "" 3503 ,fieldname_subject: "" 3504 }; 3505 3506 $(".addNewEduQual").click(function(){ 3507 var SETTINGS = $(this).data("switcher-settings"); // data element on the 'add another' buton 3508 console.log(SETTINGS); 3509 3510 if(SETTINGS){ 3511 3512 let next_i = SETTINGS.next_i; 3513 let baseName = SETTINGS.baseName; 3514 3515 EDUQUAL_OBJECT.fieldname_establishment = baseName + "[" + next_i + "][establishment]"; 3516 EDUQUAL_OBJECT.fieldname_qualification = baseName + "[" + next_i + "][qualification]"; 3517 EDUQUAL_OBJECT.fieldname_subject = baseName + "[" + next_i + "][subject]"; 3518 3519 var outputHtml = EDUQUAL_TEMPLATE(EDUQUAL_OBJECT); 3520 3521 // Attach the new block before the trigger 3522 $(this).closest(".controls").before(outputHtml); 3523 3524 SETTINGS.next_i = next_i + 1; 3525 $(this).data("switcher-settings", SETTINGS); 3526 } 3527 }); 3528} 3529// Delete
3530$(document).on("click", ".deleteEduQual", function(e){ 3531 e.preventDefault(); 3532 var $block = $(this).closest(".controls"); 3533 $block.remove(); 3534}); 3535/* -------------------------------- 3536* END Item Text Type 3537---------------------------------*/ 3538 3539 3540/* -------------------------------- 3541* Add another 'Previous employment' 3542* uses underscore.js 3543---------------------------------*/ 3544if($("#prevEmployment").length){ 3545 3546 var PREVEMPLOYMENT_TEMPLATE = _.template( 3547 '<div class="controls addAnotherControls" style="width:100%;">' + 3548 3549 // Content (To be the same as baseApplicationForm.php) 3550 3551 '<div class="col col-sm-3">'+ 3552 ' <input type="text" name="<%=fieldname_name%>" class="form_input" placeholder="Name and Address of Employer" value=""> '+ 3553 '</div>'+ 3554 '<div class="col col-sm-3">'+ 3555 ' <input type="text" name="<%=fieldname_position%>" class="form_input" placeholder="Position held and outline of duties" value="">'+ 3556 '</div>'+ 3557 '<div class="col col-sm-3">'+ 3558 ' <input type="text" name="<%=fieldname_dates%>" class="form_input" placeholder="Dates From/To" value="">'+ 3559 '</div>'+ 3560 '<div class="col col-sm-3">'+ 3561 ' <input type="text" name="<%=fieldname_reason%>" class="form_input" placeholder="Reason for leaving" value="">'+ 3562 '</div>'+ 3563 3564 // Delete 3565 '<span class="span2"><a href="#" class="deletePrevEmployment" title="Delete this block"><i class="fa fa-times-circle text-error" aria-hidden="true"></i></a></span>'+ 3566 3567 '<div class="clearfix"></div><br />' + 3568 '</div>' 3569 ); 3570 3571 const PREVEMPLOYMENT_OBJECT = { 3572 fieldname_name: "" 3573 ,fieldname_position: "" 3574 ,fieldname_dates: "" 3575 ,fieldname_reason: "" 3576 }; 3577 3578 $(".addNewPrevEmployment").click(function(){ 3579 var SETTINGS = $(this).data("switcher-settings"); // data element on the 'add another' buton 3580 console.log(SETTINGS); 3581 3582 if(SETTINGS){ 3583 3584 let next_i = SETTINGS.next_i; 3585 let baseName = SETTINGS.baseName; 3586 3587 PREVEMPLOYMENT_OBJECT.fieldname_name = baseName + "[" + next_i + "][name]"; 3588 PREVEMPLOYMENT_OBJECT.fieldname_position = baseName + "[" + next_i + "][position]"; 3589 PREVEMPLOYMENT_OBJECT.fieldname_dates = baseName + "[" + next_i + "][dates]"; 3590 PREVEMPLOYMENT_OBJECT.fieldname_reason = baseName + "[" + next_i + "][reason]"; 3591 3592 var outputHtml = PREVEMPLOYMENT_TEMPLATE(PREVEMPLOYMENT_OBJECT); 3593 3594 // Attach the new block before the trigger 3595 $(this).closest(".controls").before(outputHtml); 3596 3597 SETTINGS.next_i = next_i + 1; 3598 $(this).data("switcher-settings", SETTINGS); 3599 } 3600 }); 3601} 3602// Delete 3603$(document).on("click", ".deletePrevEmployment", function(e){ 3604 e.preventDefault(); 3605 var $block = $(this).closest(".controls"); 3606 $block.remove(); 3607}); 3608/* -------------------------------- 3609* END Item Text Type 3610---------------------------------*/ 3611 3612// On page load (in-case returned by failed submission) 3613checkCriminalInputOption(); 3614// And when the input is switched from Yes/No 3615$("input[name='criminal']").change(function(){ 3616 checkCriminalInputOption(); 3617}); 3618 3619function checkCriminalInputOption(){ 3620 let checked = $("input[name='criminal']:checked").val(); 3621 showHideCriminalInputs(checked); 3622} 3623// Show/Hide inputs and also make required if needed 3624function showHideCriminalInputs(checked){ 3625 console.log(checked); 3626 if(checked == 1){ 3627 $('#criminalInputs').show(); 3628 $('#criminal_crime').prop('required', true); 3629 $('#criminal_sentence').prop('required', true); 3630 $('#criminal_date').prop('required', true); 3631 $('#criminal_details').prop('required', true); 3632 }else{ 3633 $('#criminalInputs').hide(); 3634 $('#criminal_crime').removeAttr('required'); 3635 $('#criminal_sentence').removeAttr('required'); 3636 $('#criminal_date').removeAttr('required'); 3637 $('#criminal_details').removeAttr('required'); 3638 } 3639 3640 3641 3642}
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.