/**
* RR - Language Redirection
*/
var RR = (function (parent, $) {
'use strict';
function LanguageManuallySelected() {
var selected = false;
var name = "LanguageManuallySelected=";
var decodedCookie = decodeURIComponent(document.cookie);
var cookies = decodedCookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
//Remove whitespace before cookie name
while (cookie.charAt(0) == ' ') {
cookie = cookie.substring(1);
}
//If language cookie then return its value
if (cookie.indexOf(name) == 0) {
selected = "true" == cookie.substring(name.length, cookie.length);
}
}
return selected;
}
var SetLanguageSelectedCookie = function () {
//Add a cookie that lasts 5 days to tell the langauge selector not to redirect to the chinese site
var exdate = new Date();
exdate.setDate(exdate.getDate() + 5);
document.cookie = "LanguageManuallySelected=true; expires=" + exdate.toUTCString() + "; path=/";
}
$('.language-link').on("click", function () {
if (LanguageManuallySelected() == false) {
SetLanguageSelectedCookie();
}
});
/**
* Export module method
*/
parent.languageRedirection = {
SetLanguageSelectedCookie: SetLanguageSelectedCookie,
};
return parent;
}(RR || {}, jQuery));/**
* RR - Accordion
*/
var RR = (function (parent, $) {
'use strict';
var $accExpander= $('.custom-accordion dt');
var desktopEvents = function () {
};
var tabletEvents = function () {
};
var mobileEvents = function () {
};
var setup = function () {
$accExpander.each(function(){
var $this=$(this),
$thisTarget=$this.next(),
$parentItem=$this.parents('.custom-accordion');
$this.click(function(){
if(!$this.hasClass('expanded')){
$('dd.expanded',$parentItem).slideUp(function(){
$('.expanded').removeClass('expanded');
$('.faq-item').removeClass('is-expanded');
});
$thisTarget.slideDown(function(){
$this.addClass('expanded');
$thisTarget.addClass('expanded');
$this.parents('.faq-item').addClass('is-expanded');
});
}else{
$this.removeClass('expanded');
$this.parents('.faq-item').removeClass('is-expanded');
$thisTarget.slideUp(function(){
$(this).removeClass('expanded');
$this.parents('.faq-item').removeClass('is-expanded');
});
}
});
});
};
/**
* Export module method
*/
parent.accordionPanel = {
setup: setup,
desktopEvents: desktopEvents,
tabletEvents: tabletEvents,
mobileEvents: mobileEvents
};
return parent;
}(RR || {}, jQuery));var RR = (function (parent, $) {
'use strict';
var setup = function () {
var $header = $('header'),
$headerBooking= $('.header-booking'),
$noticeBanner = $('.notice-banner'),
$detail = $noticeBanner.children('.detail'),
$inside = $detail.children('.inside'),
$readMoreLink = $noticeBanner.children('.js-readmore');
if ($($noticeBanner).length) {
$('body').addClass('with-notice');
if ($inside.height() > $detail.height()) {
$readMoreLink.css('visibility','visible');
}
// Close page announcement
$('.notice-banner .js-close').on('click', function(event){
event.preventDefault();
var $banner = $(this).parents('.notice-banner');
$('body').removeClass('with-notice');
$banner.remove();
if ($headerBooking.hasClass('is-fixed')) {
$headerBooking.css('top', $header.height());
}
});
if($( $readMoreLink).length) {
$( $readMoreLink).on('click', function(event){
$(this).toggleClass('active');
$('.notice-banner .detail').toggleClass('active');
});
}
}
};
/**
* Export module method
*/
parent.announcementBanner = {
setup: setup,
};
return parent;
}(RR || {}, jQuery));/**
* RR - Booking form
*/
var RR = (function (parent, $) {
'use strict';
var $bookingSection = $('.page-header .header-booking'),
bookingUrl = '',
bookingRoomUrl = '';
var setup = function () {
if ($('#homepageBookingDestination, #headerBookingDestination').length) {
loadMapAllData();
}
};
function compareStrings(a, b) {
a = a.toLowerCase();
b = b.toLowerCase();
return (a < b) ? -1 : (a > b) ? 1 : 0;
}
var setDataAttr = function (el, suggestion) {
// get booking url from mapData.json from brandCode
el.data('booking-url', suggestion.bookingUrl);
el.data('flexible-url', suggestion.flexibleUrl);
el.data('date-format', suggestion.dateFormat);
if (suggestion.startDate) {
el.data('booking-start-date', suggestion.startDate);
} else {
el.data('booking-start-date', '');
}
if (suggestion.endDate) {
el.data('booking-end-date', suggestion.endDate);
} else {
el.data('booking-end-date', '');
}
}
var loadMapAllData = function () {
if (typeof (bookingData) == "undefined" || (bookingData.markers != null && bookingData.markers.length == 0)) {
var url = window.location.origin + '/' + $('html').attr('lang');
var dataUrl = $('body').data('booking-data-url') ? $('body').data('booking-data-url') : (url + '/json/bookingdata');
$.ajax({
url: dataUrl,
type: "GET",
cache: true,
timeout: 10000,
dataType: 'json',
success: function (data) {
if (typeof data === "string") {
data = JSON.parse(data);
}
if (data.markers) {
processMapAllData(data.markers);
} else {
processMapAllData(data);
}
},
error: function (error) {
console.warn(error)
}
});
} else {
processMapAllData(bookingData.markers);
}
};
var processMapAllData = function (data) {
if ($('#headerBookingDestination').length) {
initSelect2(this, data);
}
};
var initSelect2 = function (_self, data) {
var dateInputs = {
checkinId: 'headerBookingCheckin',
checkoutId: 'headerBookingCheckout'
}
var containers = {
checkinContainer: 'checkin-subgroup',
checkoutContainer: 'checkout-subgroup'
}
var randID = function () {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}
var data = $.map(data, function (obj) {
obj = obj.content;
if (typeof (obj.title) !== "undefined") {
obj.id = (obj.Id == null && (obj.hotelCode == null || obj.hotelCode === "") ? randID().replace(/\-/g, '') : (obj.Id || obj.hotelCode));
obj.text = obj.text || obj.title;
obj.location = obj.location || obj.title;
if ((typeof (obj.hotelCode) === "undefined") || (obj.hotelCode.indexOf("_VOID") > 0 || obj.hotelCode.indexOf("_GHA") > 0)) {
if (obj.bookingUrl === "" || obj.bookingUrl == null) {
obj.disabled = true;
}
obj.hotelCode = "";
}
return obj;
}
});
var formatResult = function (data) {
var destStyle = "";
var disabledOption = "";
if (data.loading) {
return $('#headerBookingDestination').data('placeholder');
}
else {
if (typeof data != "undefined") {
if (typeof data.hotelCode == "undefined" || data.hotelCode.indexOf("_VOID") > 0) {
destStyle += " blocked ";
disabledOption = "disabled='disabled'";
}
if (data.country) {
destStyle += ' t-c-m t-upper tt-country';
}
else if (data.state) {
destStyle += ' t-c-s tt-state';
}
else if (data.city) {
destStyle += ' t-c-s tt-city';
}
else {
if (typeof data.brandCode === "undefined" || data.brandCode === "") {
destStyle += ' t-c-s ti';
}
else {
destStyle += data.brandCode;
destStyle += ' t-c-s';
}
}
var $result = $('
' + data.title + '
');
return $result;
}
}
};
var templateSelected = function (data) {
if (typeof data == "undefined" || typeof data == "undefined")
return $('#headerBookingDestination').data('placeholder');
var selection = data;
$('.booking-destination .js-clear-destination').fadeIn();
var $bookingMaskForm = $('.header-booking-form').find('.js-booking-search'),
$bookingHc = $('#booking-hc'),
$bookingDateFormat = selection.dateFormat,
bookableStartDate = '',
bookableEndDate = '';
$bookingMaskForm.data('selection', selection);
$bookingMaskForm.data('pms-platform', selection.pmsPlatform ? selection.pmsPlatform : "");
$bookingMaskForm.data('country', selection.country ? selection.country : "");
$bookingMaskForm.data('hotel-code', selection.hotelCode ? selection.hotelCode : "");
$bookingMaskForm.data('brand-code', selection.brandCode ? selection.brandCode : "");
$bookingMaskForm.data('booking-url', selection.bookingUrl ? selection.bookingUrl : "");
$bookingMaskForm.data('flexible-url', selection.flexibleUrl ? selection.flexibleUrl : "");
$bookingMaskForm.data('date-format', selection.dateFormat ? selection.dateFormat : "");
// Set bookable start date
if (selection.startDate) {
bookableStartDate = selection.startDate;
}
$bookingMaskForm.data('booking-start-date', bookableStartDate);
var checkInPicker = $('#headerBookingCheckin').data('picker'),
checkoutPicker = $('#headerBookingCheckout').data('picker');
if (checkInPicker && checkoutPicker) {
var minDateTimeStamp = '',
minDate = selection.startDate,
selectedStartDate = checkInPicker.getMoment(),
selectedEndDate = checkoutPicker.getMoment(),
tempMaxDate = moment().add(1, 'years'),
oneYearTimeStamp = moment(tempMaxDate.format('x'))._i;
if (minDate !== undefined && minDate !== '') {
minDateTimeStamp = moment(moment(minDate, 'DD/MM/YYYY').format('x'))._i;
}
var selectedStartDateTimeStamp = moment(selectedStartDate.format('x'))._i;
//if there is min date and the selected date is less than the min date
if (minDate !== undefined && minDate !== '') {
minDate = moment(minDate, 'DD/MM/YYYY');
if (minDate < moment(moment(), 'DD/MM/YYYY')) {
minDate = moment(moment(), 'DD/MM/YYYY');
}
checkInPicker.setMinDate(minDate.toDate());
checkInPicker.setMaxDate(tempMaxDate);
if (selectedStartDateTimeStamp < minDateTimeStamp) {
selectedStartDate = minDate;
checkInPicker.setDate(minDate.toDate());
}
} else {
checkInPicker.setMinDate(moment().toDate());
checkInPicker.setDate(selectedStartDate);
};
checkInPicker.setMaxDate(tempMaxDate.toDate());
checkoutPicker.setMaxDate(tempMaxDate.toDate());
// if (selection.mlos) {
// $('.header-booking .booking-form').data('default-stay', selection.mlos);
// } else {
// $('.header-booking .booking-form').data('default-stay', '2');
// }
// var checkOut = moment(selectedStartDate).add($('.booking-section .booking-form').data('default-stay'), 'days');
// $('#headerBookingCheckout').val(checkOut.format(AD.bookingForm.getDisplayDateFormat()));
}
if (typeof selection.title == "undefined") {
return $('#headerBookingDestination').data('placeholder');
}
return selection.title;
}
var matchCustom = function (params, data) {
// If there are no search terms, return all of the data
if ($.trim(params.term) === '') {
return data;
}
// Do not display the item if there is no 'text' property
if (typeof data.location === 'undefined') {
return null;
}
var pattern = new RegExp((params.term).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&').replace(/\s/g, ".*"), "i");
// `params.term` should be the term that is used for searching
// `data.text` is the text that is displayed for the data object
if (data.location && data.location.search(pattern) > -1) {
var modifiedData = $.extend({}, data, true);
// You can return modified objects from here
// This includes matching the `children` how you want in nested data sets
return modifiedData;
} else if (data.text && data.text.search(pattern) > -1) {
var modifiedData = $.extend({}, data, true);
// You can return modified objects from here
// This includes matching the `children` how you want in nested data sets
return modifiedData;
}
// Return `null` if the term should not be displayed
return null;
}
var select2_option = {
data: data,
closeOnSelect: true,
selectOnClose: true,
width: "100%",
placeholder: $('#headerBookingDestination').data('placeholder'),
templateResult: formatResult,
templateSelection: templateSelected,
theme: 'oaks',
matcher: matchCustom
};
$('#headerBookingDestination').addClass('destination-input-select').select2(select2_option);
$('#headerBookingDestination').on('select2:select', function(e){
$('.icon.icon-location-2').removeClass('is-error');
})
var select2element = $('#headerBookingDestination').closest('.header-booking-form').find('.js-booking-search');
if (select2element.data('prefill')) {
var option = $('#headerBookingDestination').children('option[title*="' + select2element.data('prefill') + '"]');
$('#headerBookingDestination').val($(option).val()).trigger('change');
}
}
/**
* Export module method
*/
parent.autoComplete = {
setup: setup,
setDataAttr: setDataAttr
};
return parent;
}(RR || {}, jQuery));var RR = (function (parent, $) {
'use strict';
var setup = function () {
function setOption(option) {
var destStyle = "";
if ($(option.element).data("country")) {
destStyle += ' t-c-m t-upper tt-country';
}
else if ($(option.element).data("state")) {
destStyle += ' t-c-s tt-state';
}
else if ($(option.element).data("city")) {
destStyle += ' t-c-s tt-city';
} else {
destStyle += ' t-c-s';
}
return $('
' + option.text + '
');
};
var select2_option = {
closeOnSelect: false,
selectOnClose: false,
width: "100%",
templateResult: setOption,
templateSelection: setOption,
placeholder: $('#blog-filter').data('placeholder'),
theme: 'oaks'
};
var urlSearchParams = new URLSearchParams(window.location.search);
var params = Object.fromEntries(urlSearchParams.entries());
$('#blog-filter').addClass('destination-input-select').select2(select2_option);
if (params["Destination"]) {
$('#blog-filter').val(params["Destination"]).trigger('change');
}
$('#blog-filter').on('select2:select', function () {
var url = $(this).find(':selected').data('destinationUrl');
if( $(this).val() == "all") { window.location = window.location.origin + url }
else if (url) {
Object.keys(params).forEach(key => {
if (key != "Destination" && key != "page") {
url += "&" + key + "=" + params[key];
}
});
window.location.href = url;
}
});
};
parent.blog = {
setup: setup
};
return parent;
}(RR || {}, jQuery));/**
* RR - Layout Events
* Adjust, move elements based on breakpoints
*/
var RR = (function (parent, $) {
'use strict';
var datePickerObjs = [],
$document = $(document),
$headerBooking = $('.header-booking'),
$headerBookingForm = $('.header-booking-form'),
windowTarget = $headerBookingForm.attr('target'),
$headerBookingForm = $('.header-booking-form', $headerBooking),
$headerBookingInput = $('.dates-booking-group .input-text, .guests-booking-group .input-text', $headerBookingForm),
$promoToggle = $('.js-booking-promo-btn', $headerBooking),
$promoToggleClose = $('.promo-booking-group .close', $headerBooking),
dateFormat = $('#headerBookingCheckin').data('dateformat'),
bookingDateGHAFormat = 'YYYY-MM-DD',
defaultBookingUrl = $headerBookingForm.data('mhg-default-booking-url'),
defaultFlexibleUrl = $headerBookingForm.data('mhg-default-flexible-url'),
ghaCountryURL = $headerBookingForm.data('gha-country-url'),
bookingDateGHAFormat = 'YYYY-MM-DD',
isAndroid = false,
roomCode = undefined,
$ghaAPI = $('#gha-api').val(),
ghaLocation = '',
ghaBrands = '',
ghaBrandHTML = '',
ghaDatePickerInit = false,
$formPost = $("#header-booking-form-post"),
ghaMaintenance = $("body").data('gha-maintenance');
if (dateFormat == '' || dateFormat == undefined) {
dateFormat = 'DD/MM/YYYY'
}
if ($('html').attr('lang') == 'zh' || $('html').attr('lang') == 'cn' || $('html').attr('lang') == 'ja') {
if (dateFormat == 'D MMM YYYY' || dateFormat == 'DD MMM YYYY' || dateFormat == 'D MMMM YYYY' || dateFormat == 'DD MMMM YYYY') {
dateFormat = 'D日M月YYYY年';
} else if (dateFormat == 'MMM D YYYY' || dateFormat == 'MMM DD YYYY' || dateFormat == 'MMMM D YYYY' || dateFormat == 'MMMM DD YYYY') {
dateFormat = 'M月D日YYYY年';
} else if (dateFormat == 'YYYY MMM D' || dateFormat == 'YYYY MMM DD' || dateFormat == 'YYYY MMMM D' || dateFormat == 'YYYY MMMM DD') {
dateFormat = 'YYYY年M月D日';
}
}
var styleDateRange = function (checkoutDateSelector, momentCheckinDate, duration) {
$('.pika-table').find(checkoutDateSelector).addClass('is-checkin-date');
if (duration > 1) {
var tempMoment = moment(momentCheckinDate.toDate());
for (var i = 0; i < duration - 1; i++) {
tempMoment.add(1, 'days');
var selectedDate = tempMoment.date(),
selectedMonth = tempMoment.month(),
selectedYear = tempMoment.year(),
dateSelector = '';
dateSelector = '.pika-day[data-pika-day="' + selectedDate + '"]';
dateSelector += '[data-pika-month="' + selectedMonth + '"]';
dateSelector += '[data-pika-year="' + selectedYear + '"]';
$('.pika-table').find(dateSelector).addClass('is-in-range');
};
}
};
var initializeDatepicker = function (months, dateInputs, dateTriggers, containers, hasOverlay, pickerTheme) {
if ($('.no-booking-mask').length) {
return;
}
var headerCheckin = $('#headerBookingCheckin').val();
var headerCheckout = $('#headerBookingCheckout').val();
var checkin = moment();
var checkout = moment().add(2, 'd');
if (headerCheckin) {
checkin = moment(headerCheckin, "DD-MM-YYYY");
}
if (headerCheckout) {
checkout = moment(headerCheckout, "DD-MM-YYYY");
}
// console.log('initialize', dateTriggers);
var checkoutDateSelector = '',
momentCheckinDate = moment(),
duration = 0,
checkinPicker,
checkinPickerOpts,
checkoutPicker,
checkoutPickerOpts,
containerId = '',
$overlay = $('.datepicker-overlay');
var today = moment();
var nextDate = moment().add(1, 'days');
// ---------------------------------------------------------------------------------------------------//
// Check in date picker
// ---------------------------------------------------------------------------------------------------//
checkinPickerOpts = {
field: document.getElementById(dateInputs.checkinId),
theme: pickerTheme,
minDate: today.toDate(),
defaultDate: checkin.toDate(),
setDefaultDate: true,
format: dateFormat,
maxDate: moment().add(1, 'years').toDate(),
numberOfMonths: months,
firstDay: 1,
onSelect: function (date) {
momentCheckinDate = moment(date);
var selectedDate = momentCheckinDate.date(),
selectedMonth = momentCheckinDate.month(),
selectedYear = momentCheckinDate.year(),
momentCheckinDatePlus1 = moment(momentCheckinDate.toDate()).add(1, 'days'),
momentCheckinDatePlus2 = moment(momentCheckinDate.toDate()).add(2, 'days'),
momentCheckinDatePlus90 = moment(momentCheckinDate.toDate()).add(90, 'days'),
momentCheckoutDate = checkoutPicker.getMoment();
checkoutDateSelector = '';
checkoutDateSelector = '.pika-day[data-pika-day="' + selectedDate + '"]';
checkoutDateSelector += '[data-pika-month="' + selectedMonth + '"]';
checkoutDateSelector += '[data-pika-year="' + selectedYear + '"]';
checkoutPicker.setMinDate(momentCheckinDatePlus1.toDate());
checkoutPicker.gotoDate(momentCheckinDate.toDate());
setDateButtonsText(momentCheckinDate, momentCheckinDatePlus1);
// If checkout date has been selected
/*if (checkoutPicker.getDate()) {
// If newly selected checkin date bigger than previously selected checkout date
if (momentCheckinDatePlus1.diff(momentCheckoutDate, 'days') > 0) {
checkoutPicker.setDate(momentCheckinDatePlus.toDate());
} else if (momentCheckoutDate.diff(momentCheckinDatePlus1, 'days') > 90) {
checkoutPicker.setDate(momentCheckinDatePlus90.toDate());
}
setDateButtonsText(momentCheckinDate, checkoutPicker.getMoment());
}*/
checkoutPicker.setDate(momentCheckinDatePlus2.toDate());
setDateButtonsText(momentCheckinDate, checkoutPicker.getMoment());
duration = checkoutPicker.getMoment().diff(momentCheckinDate, 'days');
$('#nights-subgroup .booking-info-value').text(duration);
if (duration > 1) {
$('#nights-subgroup .booking-info-text').text($("#nights-subgroup .booking-info-text").data("nights-text-plural"));
} else {
$('#nights-subgroup .booking-info-text').text($("#nights-subgroup .booking-info-text").data("nights-text"));
}
// Redraw checkout datepicker to disable the next button once max date is reached
checkoutPicker.draw();
},
onOpen: function () {
if (hasOverlay) {
$overlay.addClass('is-active');
$('.pika-single.is-bound').addClass('is-fixed');
}
},
onClose: function () {
if (hasOverlay) {
$overlay.removeClass('is-active');
$('.pika-single.is-bound').removeClass('is-fixed');
}
}
}
if (containers) {
checkinPickerOpts.container = document.getElementById(containers.checkinContainer);
}
if (dateTriggers) {
checkinPickerOpts.trigger = document.getElementById(dateTriggers.checkinTriggerId);
}
// initialize datepicker
checkinPicker = new Pikaday(checkinPickerOpts);
// ---------------------------------------------------------------------------------------------------//
// Check out date picker
// ---------------------------------------------------------------------------------------------------//
checkoutPickerOpts = {
field: document.getElementById(dateInputs.checkoutId),
theme: pickerTheme,
minDate: nextDate.toDate(),
defaultDate: checkout.toDate(),
setDefaultDate: true,
format: dateFormat,
maxDate: moment().add(1, 'years').toDate(),
numberOfMonths: months,
firstDay: 1,
onSelect: function (date) {
var momentCheckinDate = checkinPicker.getMoment(),
momentCheckoutDate = moment(date);
var tempMoment = moment(momentCheckinDate.toDate());
duration = momentCheckoutDate.diff(momentCheckinDate, 'days');
$('#nights-subgroup .booking-info-value').text(duration);
if (duration > 1) {
$('#nights-subgroup .booking-info-text').text($("#nights-subgroup .booking-info-text").data("nights-text-plural"));
} else {
$('#nights-subgroup .booking-info-text').text($("#nights-subgroup .booking-info-text").data("nights-text"));
}
setDateButtonsText(null, momentCheckoutDate);
},
onOpen: function () {
styleDateRange(checkoutDateSelector, momentCheckinDate, duration);
if (hasOverlay) {
$overlay.addClass('is-active');
$('.pika-single.is-bound').addClass('is-fixed');
}
},
onDraw: function () {
styleDateRange(checkoutDateSelector, momentCheckinDate, duration);
},
onClose: function () {
if (hasOverlay) {
$overlay.removeClass('is-active');
$('.pika-single.is-bound').removeClass('is-fixed');
}
}
}
if (containers) {
checkoutPickerOpts.container = document.getElementById(containers.checkoutContainer);
}
if (dateTriggers) {
checkoutPickerOpts.trigger = document.getElementById(dateTriggers.checkoutTriggerId);
}
//$('.booking-form-group .js-booking-search').attr('type', 'text');
// initialize datepicker
checkoutPicker = new Pikaday(checkoutPickerOpts);
datePickerObjs.push(checkinPicker);
datePickerObjs.push(checkoutPicker);
return [checkinPicker, checkoutPicker];
};
var setDateButtonsText = function (checkinMoment, checkoutMoment) {
var $headerCheckinBtn = $('#headerCheckinBtn'),
$headerCheckoutBtn = $('#headerCheckoutBtn');
if (checkinMoment) {
var checkinDate = checkinMoment;
$headerCheckinBtn.find('.date').text(checkinDate.date());
$headerCheckinBtn.find('.month-year').text(checkinDate.format('MMMM YYYY'));
$headerCheckinBtn.find('.day').text(checkinDate.format('ddd'));
}
if (checkoutMoment) {
var checkoutDate = checkoutMoment;
$headerCheckoutBtn.find('.date').text(checkoutDate.date());
$headerCheckoutBtn.find('.month-year').text(checkoutDate.format('MMMM YYYY'));
$headerCheckoutBtn.find('.day').text(checkoutDate.format('ddd'));
}
};
var destroyDatePickers = function () {
var i;
for (i = 0; i < datePickerObjs.length; i++) {
datePickerObjs[i].destroy();
}
};
var hideDatePickers = function () {
var i;
for (i = 0; i < datePickerObjs.length; i++) {
datePickerObjs[i].hide();
}
};
var showPromoGroup = function ($this) {
var $promoGroup = $this.parent().parent().find('.promo-booking-group');
if (!$promoGroup.hasClass('is-active')) {
$promoGroup.slideDown(200, function (e) {
$promoGroup.addClass('is-active');
//auto scroll down for limited height device
$promoGroup.parent().animate({
scrollTop: $promoGroup.parent().prop("scrollHeight") - $promoGroup.parent().height()
}, 200)
});
//$this.hide();
}
};
var hidePromoGroup = function ($this) {
var $promoGroup = $this.parent().parent();
if ($promoGroup.hasClass('is-active')) {
$promoGroup.slideUp(200, function (e) {
$promoGroup.removeClass('is-active');
});
//$this.parent().parent().parent().find('.js-booking-promo-btn').show(200);
}
}
var desktopEvents = function () {
$(function () {
// reset style
$headerBookingInput.removeClass('visuallyhidden');
$headerBooking.removeClass('is-active');
$headerBookingForm.removeAttr('style');
var dateInputs = {
checkinId: 'headerBookingCheckin',
checkoutId: 'headerBookingCheckout'
}
var homepageDateInputs = {
checkinId: 'homepageBookingCheckin',
checkoutId: 'homepageBookingCheckout'
}
var containers = {
checkinContainer: 'checkin-subgroup',
checkoutContainer: 'checkout-subgroup'
}
var $headerBookingToggle = $('.js-header-booking-toggle', $headerBooking),
$bookingToggleText = $('.text', $headerBookingToggle);
$bookingToggleText.text($bookingToggleText.data('text-open'));
$headerBookingToggle.css('top', '');
destroyDatePickers();
var headerBookingMask = initializeDatepicker(2, dateInputs, null, containers, false);
//select2
$('#headerBookingDestination').on('select2:select', function (ev) {
var suggestion = ev.params.data;
RR.autoComplete.setDataAttr($(this), suggestion);
headerBookingMask[0].setMaxDate(moment().add(1, 'years').toDate());
headerBookingMask[1].setMaxDate(moment().add(90, 'days').toDate());
var minDateTimeStamp = '',
maxDateTimeStamp = '',
minDate = $(this).data('booking-start-date'),
maxDate = $(this).data('booking-end-date'),
selectedStartDate = moment($('#headerBookingCheckin').val(), dateFormat),
selectedEndDate = moment($('#headerBookingCheckout').val(), dateFormat),
tempMaxDate = moment().add(1, 'years'),
oneYearTimeStamp = moment(tempMaxDate.format('x'))._i;
if (minDate !== undefined && minDate !== '') {
minDateTimeStamp = moment(moment(minDate, 'DD/MM/YYYY').format('x'))._i;
}
var selectedStartDateTimeStamp = moment(selectedStartDate.format('x'))._i;
//if there is min date and the selected date is less than the min date
if (minDate !== undefined && minDate !== '' && selectedStartDateTimeStamp <= minDateTimeStamp) {
minDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY');
headerBookingMask[0].setMinDate(minDate.toDate());
headerBookingMask[0].setDate(minDate.format('YYYY-MM-DD'));
headerBookingMask[0].setMaxDate(tempMaxDate);
} else {
headerBookingMask[0].setMinDate(moment().toDate());
headerBookingMask[0].setDate(selectedStartDate);
};
if (maxDate !== undefined && maxDate !== '') {
maxDateTimeStamp = moment(moment(maxDate, 'DD/MM/YYYY').format('x'))._i,
tempMaxDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY').add(1, 'years').toDate();
}
var selectedEndDateTimeStamp = moment(selectedEndDate.format('x'))._i;
//if there is max date
if (maxDate !== undefined && maxDate !== '') {
//if maxdate is later than the 1 year from today, use 1 year from today date
if (maxDateTimeStamp < oneYearTimeStamp) {
tempMaxDate = moment(maxDate, 'DD/MM/YYYY');
}
//if selected date is later than maxdate, use maxdate
if (selectedEndDateTimeStamp > maxDateTimeStamp) {
if (selectedStartDateTimeStamp >= maxDateTimeStamp) {
headerBookingMask[0].setDate(moment(moment(maxDate, 'DD/MM/YYYY').subtract(1, 'days')).toDate());
}
headerBookingMask[1].setDate(moment(maxDate, 'DD/MM/YYYY').toDate());
}
}
headerBookingMask[0].setMaxDate(tempMaxDate);
headerBookingMask[1].setMaxDate(tempMaxDate);
});
$("#homepageBookingPromoCode, #headerBookingPromoCode").keyup(function () {
$(this).addClass('has-close');
if ($(this).val() == '') {
$(this).removeClass('has-close');
}
});
if ($('#homepage-booking').length) {
containers = {
checkinContainer: 'homepage-checkin-subgroup',
checkoutContainer: 'homepage-checkout-subgroup'
}
var homepageBookingMask = initializeDatepicker(2, homepageDateInputs, null, containers, false);
$('#homepage-booking .js-booking-promo-btn').on('click', function (e) {
e.preventDefault();
showPromoGroup($(this));
});
$('#homepageBookingDestination').on('select2:select', function (ev) {
var suggestion = ev.params.data;
RR.autoComplete.setDataAttr($(this), suggestion);
var minDateTimeStamp = '',
maxDateTimeStamp = '',
minDate = $(this).data('booking-start-date'),
maxDate = $(this).data('booking-end-date'),
selectedStartDate = moment($('#homepageBookingCheckin').val(), dateFormat),
selectedEndDate = moment($('#homepageBookingCheckout').val(), dateFormat),
tempMaxDate = moment().add(1, 'years'),
oneYearTimeStamp = moment(tempMaxDate.format('x'))._i;
if (minDate !== undefined && minDate !== '') {
minDateTimeStamp = moment(moment(minDate, 'DD/MM/YYYY').format('x'))._i;
}
var selectedStartDateTimeStamp = moment(selectedStartDate.format('x'))._i;
//if there is min date and the selected date is less than the min date
if (minDate !== undefined && minDate !== '' && selectedStartDateTimeStamp <= minDateTimeStamp) {
minDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY');
homepageBookingMask[0].setMinDate(minDate.toDate());
homepageBookingMask[0].setDate(minDate.format('YYYY-MM-DD'));
homepageBookingMask[0].setMaxDate(tempMaxDate);
} else {
homepageBookingMask[0].setMinDate(moment().toDate());
homepageBookingMask[0].setDate(selectedStartDate);
};
if (maxDate !== undefined && maxDate !== '') {
maxDateTimeStamp = moment(moment(maxDate, 'DD/MM/YYYY').format('x'))._i,
tempMaxDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY').add(1, 'years').toDate();
}
var selectedEndDateTimeStamp = moment(selectedEndDate.format('x'))._i;
//if there is max date
if (maxDate !== undefined && maxDate !== '') {
//if maxdate is later than the 1 year from today, use 1 year from today date
if (maxDateTimeStamp < oneYearTimeStamp) {
tempMaxDate = moment(maxDate, 'DD/MM/YYYY');
}
//if selected date is later than maxdate, use maxdate
if (selectedEndDateTimeStamp > maxDateTimeStamp) {
if (selectedStartDateTimeStamp >= maxDateTimeStamp) {
homepageBookingMask[0].setDate(moment(moment(maxDate, 'DD/MM/YYYY').subtract(1, 'days')).toDate());
}
homepageBookingMask[1].setDate(moment(maxDate, 'DD/MM/YYYY').toDate());
}
}
homepageBookingMask[0].setMaxDate(tempMaxDate);
homepageBookingMask[1].setMaxDate(tempMaxDate);
});
}
});
};
var mobileOnlyEvents = function (monthsNumber) {
$(function (e) {
if (isAndroid) {//need to revisit this
$('#headerBookingPromoCode').focus(function () {
$headerBookingForm.addClass('pushUp');
});
$('#headerBookingPromoCode').blur(function () {
$headerBookingForm.removeClass('pushUp');
});
}
//select2
$('#headerBookingDestination').on('select2:select', function (ev) {
$('.js-submit-booking').focus();
}).keypress(function (e) {
var code = (e.keyCode ? e.keyCode : e.which);
if ((code == 13) || (code == 10)) {
$('.js-submit-booking').focus();
return false;
}
});
}); // end document ready
}; // end mobile only events
var mobileEvents = function (monthsNumber) {
var $headerBookingToggle = $('.js-header-booking-toggle', $headerBooking),
$guestStepperButton = $('.guests-booking-group .js-stepper'),
$nightsStepperButton = $('.dates-booking-group .js-stepper'),
$datepickerBtn = $('.js-datepicker-btn', $headerBooking);
$(function (e) {
var dateInputs = {
checkinId: 'headerBookingCheckin',
checkoutId: 'headerBookingCheckout'
}
var dateTriggerInputs = {
checkinTriggerId: 'headerCheckinBtn',
checkoutTriggerId: 'headerCheckoutBtn'
}
$headerBookingInput.addClass('visuallyhidden');
var headerCheckin = $('#headerBookingCheckin').val();
var headerCheckout = $('#headerBookingCheckout').val();
var checkin = moment();
var checkout = moment().add(2, 'd');
if (headerCheckin) {
checkin = moment(headerCheckin, "DD-MM-YYYY");
}
if (headerCheckout) {
checkout = moment(headerCheckout, "DD-MM-YYYY");
}
setDateButtonsText(checkin, checkout);
destroyDatePickers();
var headerBookingMask = initializeDatepicker(monthsNumber, dateInputs, dateTriggerInputs, false, true);
//select2
$('#headerBookingDestination').on('select2:select', function (ev) {
var suggestion = ev.params.data;
RR.autoComplete.setDataAttr($(this), suggestion);
headerBookingMask[0].setMaxDate(moment().add(1, 'years').toDate());
headerBookingMask[1].setMaxDate(moment().add(90, 'days').toDate());
var minDateTimeStamp = '',
maxDateTimeStamp = '',
minDate = $(this).data('booking-start-date'),
maxDate = $(this).data('booking-end-date'),
selectedStartDate = moment($('#headerBookingCheckin').val(), dateFormat),
selectedEndDate = moment($('#headerBookingCheckout').val(), dateFormat),
tempMaxDate = moment().add(1, 'years'),
oneYearTimeStamp = moment(tempMaxDate.format('x'))._i;
if (minDate !== undefined && minDate !== '') {
minDateTimeStamp = moment(moment(minDate, 'DD/MM/YYYY').format('x'))._i;
}
var selectedStartDateTimeStamp = moment(selectedStartDate.format('x'))._i;
//if there is min date and the selected date is less than the min date
if (minDate !== undefined && minDate !== '' && selectedStartDateTimeStamp <= minDateTimeStamp) {
minDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY');
headerBookingMask[0].setMinDate(minDate.toDate());
headerBookingMask[0].setDate(minDate.format('YYYY-MM-DD'));
headerBookingMask[0].setMaxDate(tempMaxDate);
} else {
headerBookingMask[0].setMinDate(moment().toDate());
headerBookingMask[0].setDate(selectedStartDate);
};
if (maxDate !== undefined && maxDate !== '') {
maxDateTimeStamp = moment(moment(maxDate, 'DD/MM/YYYY').format('x'))._i,
tempMaxDate = moment($(this).data('booking-start-date'), 'DD/MM/YYYY').add(1, 'years').toDate();
}
var selectedEndDateTimeStamp = moment(selectedEndDate.format('x'))._i;
//if there is max date
if (maxDate !== undefined && maxDate !== '') {
//if maxdate is later than the 1 year from today, use 1 year from today date
if (maxDateTimeStamp < oneYearTimeStamp) {
tempMaxDate = moment(maxDate, 'DD/MM/YYYY');
}
//if selected date is later than maxdate, use maxdate
if (selectedEndDateTimeStamp > maxDateTimeStamp) {
if (selectedStartDateTimeStamp >= maxDateTimeStamp) {
headerBookingMask[0].setDate(moment(moment(maxDate, 'DD/MM/YYYY').subtract(1, 'days')).toDate());
}
headerBookingMask[1].setDate(moment(maxDate, 'DD/MM/YYYY').toDate());
}
}
headerBookingMask[0].setMaxDate(tempMaxDate);
headerBookingMask[1].setMaxDate(tempMaxDate);
})
$headerBookingToggle.off().on('click', function (e) {
e.preventDefault();
var $bookingToggleText = $('.text', $headerBookingToggle);
if ($headerBooking.hasClass('is-active')) {
$headerBookingForm.slideUp(300, function (e) {
$headerBooking.removeClass('is-active');
$bookingToggleText.text($bookingToggleText.data('text-open'));
$headerBookingToggle.css('top', '');
});
} else {
$headerBookingForm.slideDown(300, function (e) {
var winHeight = parseInt($window.outerHeight()),
formHeight = parseInt($headerBookingForm.outerHeight()),
toggleHeight = parseInt($headerBookingToggle.outerHeight());
$headerBookingForm.css('height', winHeight - toggleHeight);
if ((formHeight + toggleHeight) < winHeight) {
var doubleHeight = toggleHeight * 2,
offset = 10;
if ((formHeight + doubleHeight) < winHeight) {
$headerBookingToggle.css('top', '-' + (toggleHeight + offset) + 'px');
}
}
});
$headerBooking.addClass('is-active');
$bookingToggleText.text($bookingToggleText.data('text-close'));
}
});
$guestStepperButton.off().on('touchend click', function (e) {
e.preventDefault();
var $this = $(this),
$parent = $this.parent(),
op = $this.data('operation'),
$guestNumber = $parent.find('.booking-info-value'),
$guestText = $parent.find('.booking-info-text'),
$inputGuestNumber = $parent.find('.input-text'),
$minGuests = parseInt($inputGuestNumber.attr('min')),
$maxGuest = parseInt($inputGuestNumber.attr('max')),
result = 0;
$guestStepperButton.removeClass('disabled');
if (op === 'plus') {
result = parseInt($guestNumber.text(), 10) + 1;
if (result <= $maxGuest) {
$guestNumber.text(result);
$inputGuestNumber.val(result);
$guestText.text($guestText.data("people-text-plural"));
}
if (result >= $maxGuest) {
$this.addClass('disabled');
}
} else if (op === 'minus') {
result = parseInt($guestNumber.text(), 10);
if ((result - 1) <= 1) $this.addClass('disabled');
if ((result - 1) === 1) {
result -= 1;
$guestText.text($guestText.data("people-text"));
$this.addClass('disabled');
} else if ((result - 1) > 1) {
result -= 1;
$guestText.text($guestText.data("people-text-plural"));
$this.removeClass('disabled');
}
$guestNumber.text(result);
$inputGuestNumber.val(result);
}
});
$nightsStepperButton.off().on('touchend click', function (e) {
e.preventDefault();
var $this = $(this),
$parent = $this.parent(),
op = $this.data('operation'),
$guestNumber = $parent.find('.booking-info-value'),
$guestText = $parent.find('.booking-info-text'),
$inputGuestNumber = $parent.find('.input-text'),
result = 0,
checkoutPicker = datePickerObjs[1],
tempMoment = moment(checkoutPicker.getMoment().toDate());
if (op === 'plus') {
result = parseInt($guestNumber.text(), 10) + 1;
$guestNumber.text(result);
$inputGuestNumber.val(result);
$guestText.text($guestText.data("nights-text-plural"));
checkoutPicker.setMoment(tempMoment.add(1, 'days'));
} else if (op === 'minus') {
result = parseInt($guestNumber.text(), 10);
if ((result - 1) === 1) {
result -= 1;
$guestText.text($guestText.data("nights-text"));
checkoutPicker.setMoment(tempMoment.subtract(1, 'days'));
} else if ((result - 1) > 1) {
result -= 1;
$guestText.text($guestText.data("nights-text-plural"));
checkoutPicker.setMoment(tempMoment.subtract(1, 'days'));
}
$guestNumber.text(result);
$inputGuestNumber.val(result);
}
});
$('.datepicker-overlay').on('touchend click', function (e) {
e.preventDefault();
hideDatePickers();
});
}); // end document ready
}; // end mobile events
var setup = function () {
if ($('.no-booking-mask').length) {
return;
}
if ($('js-toggle-gha').length) {
$.ajax({
type: "GET",
url: $ghaAPI,
datatype: 'xml',
crossDomain: true,
success: function (xml) {
appendOptions(xml);
},
error: function (a, b, c) {
console.log(arguments);
}
});
}
$(function (e) {
var ua = navigator.userAgent.toLowerCase();
isAndroid = ua.indexOf("android") > -1 && ua.indexOf("mobile");
$promoToggle.on('touchend click', function (e) {
e.preventDefault();
showPromoGroup($(this));
});
$(document).find('.close').on('touchend click', function () {
$('#homepageBookingPromoCode, #headerBookingPromoCode').val('').removeClass('has-close');
hidePromoGroup($(this));
});
////////////////////////////////////////////////
$('.select2-selection.select2-selection--single').on('click', function (e) {
var $destination = $('#select2-headerBookingDestination-container');
if ($destination.attr('title') != "" || $destination.attr('title') != undefined) {
$('.booking-form-group .select2-container--oaks').removeClass('is-error');
}
});
$('.js-submit-booking').on('click', function (e) {
e.preventDefault();
var userSession = "",
is_country = false,
formValidation = true;
var $this = $(this),
$searchInput = $this.closest('.header-booking-form').find('.js-booking-search'),
$destination = $('#select2-headerBookingDestination-container');
if (typeof window.guest_profile !== 'undefined' && window.guest_profile !== null) {
// Check guest_profile object. It will auto generate after login.
userSession = window.guest_profile.access_token;
}
var bookingURL = '',
bookingDateFormat = '',
numChildren = $('#headerBookingChildrenNo').val() == undefined ? 0 : $('#headerBookingChildrenNo').val();
var $this = $(this),
$searchInput = $this.closest('.header-booking-form').find('.js-booking-search'),
hotelCode = '';
bookingURL = $searchInput.data('booking-url') || defaultBookingUrl;
is_country = false;
if ($searchInput.data().selection && $searchInput.data().selection.is_country) {
is_country = $searchInput.data().selection.is_country == "true";
}
if (is_country) {
if ($searchInput.data('brand-code') && $searchInput.data('brand-code') == "gha") {
bookingURL = $searchInput.data('booking-url') ? $searchInput.data('booking-url') : ghaCountryURL;
bookingURL = bookingURL.replace('[CountryCode]', encodeURIComponent($searchInput.data('hotel-code')));
}
else {
bookingURL = $searchInput.data('booking-url');
}
}
if ($(this).parent().parent().hasClass('homepage-booking-form')) {
var checkIn = $('#homepageBookingCheckin').val(),
checkOut = $('#homepageBookingCheckout').val(),
numAdults = $('#homepageBookingAdultNo').val(),
promoGroup = $('#homepageBookingPromotion').val(),
promoCode = $('#homepageBookingPromoCode').val();
if (promoCode == '') {
promoCode = $('#homepageBookingPromoCode').data('fallback');
}
} else {
var checkIn = $('#headerBookingCheckin').val(),
checkOut = $('#headerBookingCheckout').val(),
adultsGroup = $('.guests-booking-group');
numAdults = $('#headerBookingAdultNo').val(),
promoGroup = $('#headerBookingPromotion').val(),
promoCode = $('#headerBookingPromoCode').val();
if (promoCode == '') {
promoCode = $('#headerBookingPromoCode').data('fallback');
}
}
if (bookingURL == '' || bookingURL == undefined) {
$searchInput.addClass('is-error');
$('.booking-form-group .select2-container--oaks').addClass('is-error');
if ($(this).parents('.homepage-booking-form').length) {
$(this).parents('.homepage-booking-form').find('.icon-location-2').addClass('is-error');
} else {
$(this).parents('.header-booking-form').find('.icon-location-2').addClass('is-error');
}
formValidation = false;
} else if ($destination.length && ($destination.attr('title') == '' || $destination.attr('title') == undefined)) {
$searchInput.addClass('is-error');
$('.booking-form-group .select2-container--oaks').addClass('is-error');
if ($(this).parents('.homepage-booking-form').length) {
$(this).parents('.homepage-booking-form').find('.icon-location-2').addClass('is-error');
} else {
$(this).parents('.header-booking-form').find('.icon-location-2').addClass('is-error');
}
formValidation = false;
}
else{
if( $('.booking-form-group .select2-container--oaks').hasClass('is-error')){
$('.booking-form-group .select2-container--oaks').removeClass('is-error');
}
}
var pmsPlatform = $searchInput.data('pms-platform');
bookingDateFormat = $searchInput.data('date-format') || dateFormat;
if (checkIn) {
if (bookingDateFormat != '') {
checkIn = moment(checkIn, 'DD/MM/YYYY');
var momentCheckin = moment(checkIn).format(bookingDateFormat);
bookingURL = bookingURL.replace('[checkinDate]', momentCheckin);
} else {
bookingURL = bookingURL.replace('[checkinDate]', checkIn);
}
} else {
formValidation = false;
}
if (bookingURL.indexOf('[checkoutDate]') > 0) {
if (bookingDateFormat != '') {
checkOut = moment(checkOut, 'DD/MM/YYYY');
var momentcheckOut = moment(checkOut).format(bookingDateFormat);
bookingURL = bookingURL.replace('[checkoutDate]', momentcheckOut);
} else {
bookingURL = bookingURL.replace('[checkoutDate]', checkOut);
}
} else {
var nights = $('#numOfNights').val();
if (nights == undefined) {
checkOut = moment(checkOut, 'DD/MM/YYYY');
checkIn = moment(checkIn, 'DD/MM/YYYY');
nights = moment.duration(checkOut.diff(checkIn)).asDays();
}
bookingURL = bookingURL.replace('[nights]', nights);
}
var rooms = 1;
var NHHotelURL = isTMS(pmsPlatform);
if (NHHotelURL) {
if (bookingURL.indexOf('[hotelID]') > 0) {
bookingURL = bookingURL.replace('[hotelID]', $searchInput.data("hotelCode"));
}
if (numAdults > 0) {
numAdults = Math.round(numAdults);
var adultPerRoom = Math.round(numAdults / rooms);
var cntadultGuests = numAdults;
var nadults = "";
for (var i = 1; i <= rooms; i++) {
if (i != 1) { nadults += "&"; }
if (i != rooms) {
cntadultGuests -= adultPerRoom;
nadults = nadults + "nadults" + i + "=" + adultPerRoom;
}
else {
nadults = nadults + "nadults" + i + "=" + cntadultGuests;
}
}
bookingURL = bookingURL.replace('[nadults]', nadults);
} else {
bookingURL = bookingURL.replace('[nadults]', "nadults1=1");
}
bookingURL = bookingURL.replace('&[nchilds]', "");
bookingURL = bookingURL.replace('&[nbabies]', "");
bookingURL = bookingURL.replace('[destinationid]', $searchInput.data("hotelCode"));
if (promoCode) {
bookingURL = bookingURL.replace('[voucherCode]', encodeURIComponent(promoCode));
}
else {
bookingURL = bookingURL.replace('[voucherCode]', '');
}
}
else if ($searchInput.data('brand-code') && $searchInput.data('brand-code') == "gha") {
var formatCheckin = moment(checkIn, 'DD/MM/YYYY').format(bookingDateGHAFormat);
var formatCheckout = moment(checkOut, 'DD/MM/YYYY').format(bookingDateGHAFormat);
bookingURL = bookingURL.replace('[startDate]', formatCheckin);
bookingURL = bookingURL.replace('[endDate]', formatCheckout);
if (bookingURL.indexOf('[startDate]') < 0) {
bookingURL = bookingUrlBuildUp(bookingURL, "startDate", formatCheckin);
}
if (bookingURL.indexOf('[endDate]') < 0) {
bookingURL = bookingUrlBuildUp(bookingURL, "endDate", formatCheckout);
}
var roomsParams = '&';
var roomCapacity = {};
if (numAdults > 0) {
numAdults = Math.round(numAdults);
var adultPerRoom = Math.round(numAdults / rooms);
var cntadultGuests = numAdults;
var nadults = "";
for (var i = 1; i <= rooms; i++) {
if (i != 1) { nadults += "&"; }
if (i != rooms) {
cntadultGuests -= adultPerRoom;
nadults = nadults + "room" + i + "Adults=" + adultPerRoom;
roomCapacity["room" + i] = adultPerRoom;
}
else {
nadults = nadults + "room" + i + "Adults=" + cntadultGuests;
roomCapacity["room" + i] = cntadultGuests;
}
}
roomsParams += nadults;
} else {
roomsParams += "room1Adults=2";
}
roomsParams += "&room1Children=0";
bookingURL = bookingURL.replace('[rooms]', roomsParams);
if (bookingURL.indexOf('[rooms]') < 0) {
bookingURL = bookingUrlBuildUp(bookingURL, "", roomsParams);
}
}
else {
if (bookingURL.indexOf('[brandCode]') > 0) {
bookingURL = bookingURL.replace('[brandCode]', $searchInput.data("brandCode"));
}
if (bookingURL.indexOf('[hotelID]') > 0) {
bookingURL = bookingURL.replace('[hotelID]', $searchInput.data("hotelCode"));
}
if (numAdults) {
adultsGroup.find('#headerBookingAdultNo').removeClass("is-error");
adultsGroup.find('.icon-people').removeClass("is-error");
bookingURL = bookingURL.replace('[adults]', numAdults);
} else {
adultsGroup.find('#headerBookingAdultNo').addClass("is-error");
adultsGroup.find('.icon-people').addClass("is-error");
formValidation = false;
}
if (promoCode) {
if (promoGroup) {
bookingURL = bookingURL.replace('[promogroup]', promoGroup);
} else {
promoGroup = 'promo';
bookingURL = bookingURL.replace('[promogroup]', promoGroup);
}
bookingURL = bookingURL.replace('[promocode]', promoCode);
} else {
bookingURL = bookingURL.replace('&promo=[promocode]', '');
bookingURL = bookingURL.replace('&promocode=[promocode]', '');
}
if (bookingURL.indexOf('[roomcode]')) {
var roomcode = $('#roomcode').val();
if (roomcode) {
bookingURL = bookingURL.replace('[roomcode]', roomcode);
} else {
bookingURL = bookingURL.replace('&roomcode=[roomcode]', '');
}
}
}
if (typeof window.guest_profile !== 'undefined' && window.guest_profile !== null) {
bookingURL = bookingURL.replace('configcode=OAKS', 'configcode=OAKSGHA');
}
var currency = checkCookie('rr_currency');
if (currency) {
bookingURL = bookingUrlBuildUp(bookingURL,'currency',currency);
}
//added consent
var consent = getConsent();
if (consent) {
bookingURL = bookingUrlBuildUp(bookingURL, "", consent);
}
var tealiumVisitorId = getTealiumVisitorId();
if (tealiumVisitorId) {
bookingURL = bookingUrlBuildUp(bookingURL, "", tealiumVisitorId);
}
if (typeof ga !== 'undefined' && ga) {
ga(function (tracker) {
if (!tracker && ga.getAll()) {
tracker = (ga.getAll())[0];
}
if (tracker && window.gaplugins && window.gaplugins.Linker) {
var linker = new window.gaplugins.Linker(tracker);
bookingURL = linker.decorate(bookingURL);
}
});
}
bookingURL = bookingURL.replace('&Child=[children]', '');
var isInternalSite = sameOrigin(window.location, bookingURL);
var isSSOEnabled = (isMBE(pmsPlatform) || isSBE(pmsPlatform)) && $('#booking-sso-form').length && !ghaMaintenance && !isInternalSite;
if(!formValidation){
return false;
}
else if ($('body').hasClass('is-members') && NHHotelURL && !ghaMaintenance && !isInternalSite) {
var wnd = (windowTarget == "_blank") ? window.open("/assets/minor/oaks/loading.htm") : window;
$('.js-booking-submit').addClass('is-spinning');
$.ajax({
url: "/api/nhsso",
data: {
"ghaid": window.guest_profile.gha_profile_id,
"lastname": window.guest_profile.lastname
},
type: "get",
timeout: $this.closest('.booking-sso-form').data("nh-sso-timeout") || 5000,
success: function (data) {
$('.js-booking-submit').removeClass('is-spinning');
if (data.token) {
bookingURL = bookingUrlBuildUp(bookingUrl, "TOKENSSO", data.token);
}
wnd.location.href = bookingURL;
},
error: function (jqXHR, textStatus, errorThrown) {
$('.js-booking-submit').removeClass('is-spinning');
wnd.location.href = bookingURL;
}
});
} else if ($('body').hasClass('is-members') && window.guest_profile && isSSOEnabled) {
constructFormPostAndSend(bookingURL, windowTarget, true, pmsPlatform);
return false;
}
else {
if (windowTarget == "_blank") {
var wnd = window.open(bookingURL);
} else {
window.location.href = bookingURL;
}
}
});
$('.js-book-now').on('click', function (e) {
e.preventDefault();
var $this = $(this),
roomCode = $this.data('roomcode'),
roomName = $('.property-header .title').text();
$('.tt-suggestion').trigger('click');
});
$(document).on("click", ".synxis-redirect-link", function(e){
e.preventDefault();
var url = $(this).data("synxis-url");
var pmsPlatform = $(this).data("pmsPlatform");
var isSynxisBE = isSBE(pmsPlatform);
var isSSOEnabled = (isMBE(pmsPlatform) || isSBE(pmsPlatform)) && $('#booking-sso-form').length && !ghaMaintenance;
if (typeof window.guest_profile !== 'undefined' && window.guest_profile !== null) {
if (isSynxisBE && url.indexOf("OAKSGHA") < 0) {
url = url.replace('configcode=OAKS', 'configcode=OAKSGHA');
}
}
if ($('body').hasClass('is-members') && window.guest_profile && isSSOEnabled) {
constructFormPostAndSend(url, $(this).attr('target'), true, pmsPlatform);
} else {
if ($(this).attr('target') == '_blank') {
window.open(url);
} else {
window.location = url;
}
}
});
$('.js-toggle-gha').each(function () {
var $this = $(this);
$this.fancybox({
wrapCSS: 'gha-fancybox',
autoCenter: false,
autoSize: false,
padding: 60,
scrollOutside: false,
height: 420,
beforeShow: function () {
if (!ghaDatePickerInit) {
var dateInputs = {
checkinId: 'ghaCheckIn',
checkoutId: 'ghaCheckOut'
}
var dateTriggerInputs = {
checkinTriggerId: 'headerCheckinBtn',
checkoutTriggerId: 'headerCheckoutBtn'
}
initializeDatepicker(2, dateInputs, null, null, false, 'gha-theme');
// RR.bookingForm.initializeDatepicker(2, 'ghaCheckIn', 'ghaCheckOut', 'gha-theme');
ghaDatePickerInit = true;
}
var $jsToggleBooking = $('.js-toggle-booking');
if ($jsToggleBooking.hasClass('is-active')) {
$('.js-toggle-booking').trigger('click');
}
}
});
});
$('.js-gha-close').on('click', function (e) {
e.preventDefault();
if ($(window).width() >= 1024) {
$.fancybox.close();
}
if ($('.header-booking').css('opacity') == '1') {
$('.js-toggle-booking').trigger('click');
}
});
$('#bookingDestination').val('');
$('.gha-brown-btn').on('click', function (e) {
e.preventDefault();
var $ghaURL = $('#gha-url').val(),
$ghaCheckIn = $('.ghaCheckIn').val(),
$ghaCheckOut = $('.ghaCheckOut').val();
$ghaURL = $ghaURL.replace('[CountryCode]', encodeURIComponent(ghaLocation));
$ghaURL = $ghaURL.replace('[BrandCode]', encodeURIComponent(ghaBrands));
$ghaCheckIn = moment($ghaCheckIn, 'DD/MM/YYYY').format('YYYY-MM-DD');
$ghaCheckOut = moment($ghaCheckOut, 'DD/MM/YYYY').format('YYYY-MM-DD');
$ghaURL = $ghaURL.replace('[StartDate]', encodeURIComponent($ghaCheckIn));
$ghaURL = $ghaURL.replace('[EndDate]', encodeURIComponent($ghaCheckOut));
window.open($ghaURL);
})
});
};
var appendOptions = function (xml) {
var $xml = $(xml),
ghaLocHTML = '';
ghaBrandHTML = '';
$xml.find('select[name="country"] option').eq(0).text($('.gha-location label').text());
$xml.find('select[name="country"] option').each(function () {
var $this = $(this);
ghaLocHTML += $this[0].outerHTML;
});
$xml.find('select[name="brand"] option').eq(0).text($('.gha-brands label').text());
$xml.find('select[name="brand"] option').each(function () {
var $this = $(this);
ghaBrandHTML += $this[0].outerHTML;
});
$('#ghaLocation').append(ghaLocHTML).on('change.fs update', function () {
var $this = $(this),
id = $this.find('option:selected').attr('id'),
$ghaBrands = $('#gha-brands').val();
ghaLocation = id;
$ghaBrands = $ghaBrands.replace('[CountryCode]', encodeURIComponent(id));
getBrands($ghaBrands);
}).trigger('update');
$('#ghaBrand').append(ghaBrandHTML).on('change.fs update', function () {
var $this = $(this),
id = $this.find('option:selected').attr('id');
ghaBrands = id;
}).trigger('update');
};
var bookingUrlBuildUp = function (bookingUrl, parameter, value) {
if (!sameOrigin(window.location, bookingUrl)) {
if (bookingUrl.indexOf('?') > 0) {
if (parameter !== null && parameter !== "") {
return bookingUrl + '&' + parameter + '=' + encodeURIComponent(value);
}
return bookingUrl + '&' + value;
} else {
if (parameter !== null && parameter !== "") {
return bookingUrl + '?' + parameter + '=' + encodeURIComponent(value);
}
return bookingUrl + '?' + value;
}
}
else {
return bookingUrl;
}
}
var sameOrigin = function (uri1, uri2 = false) {
if (!uri2) uri2 = window.location.href;
uri1 = new URL(uri1);
if (uri2.indexOf("/") == 0) return true;
uri2 = new URL(uri2);
if (uri1.host !== uri2.host) return false;
if (uri1.port !== uri2.port) return false;
if (uri1.protocol !== uri2.protocol) return false;
return true;
}
var getBrands = function (url) {
$.ajax({
type: "GET",
url: url,
datatype: 'xml',
crossDomain: true,
success: function (xml) {
updateBrands(xml);
},
error: function (a, b, c) {
console.log(arguments);
}
});
};
var updateBrands = function (xml) {
var $xml = $(xml);
ghaBrandHTML = '';
$xml.find('select[name="brand"] option').eq(0).text($('.gha-brands label').text());
$xml.find('select[name="brand"] option').each(function () {
var $this = $(this);
ghaBrandHTML += $this[0].outerHTML;
});
$('#ghaBrand').empty().append(ghaBrandHTML).trigger('update');
};
/**
* Export module method
*/
parent.bookingForm = {
setup: setup,
desktopEvents: desktopEvents,
mobileEvents: mobileEvents,
mobileOnlyEvents: mobileOnlyEvents,
destroyDatePickers: destroyDatePickers,
initializeDatepicker: initializeDatepicker
};
return parent;
}(RR || {}, jQuery));
var RR = (function (parent, $) {
'use strict';
var setup = function () {
// $.ajax({
// url: '/api/token',
// type: "GET",
// cache: false,
// timeout: 10000
// }).done(function (data) {
// $("#contact-us form").append('');
// }).error(function(jqXHR, textStatus, errorThrown) {
// console.log(textStatus);
// });
$('a.captcha').click(function() {
$('#imgCaptcha').attr('src', $('#imgCaptcha').attr('src') + '&v=' + (Math.random() * 1000));
return false;
});
};
/**
* Export module method
*/
parent.captcha = {
setup: setup
};
return parent;
}(RR || {}, jQuery));
/**
* RR - Carousel events
*/
var RR = (function (parent, $) {
"use strict";
var $carousel = $(".carousel .js-carousel");
var $propertyGallery = $(".property-gallery .js-carousel");
var $propertyGalleryNav = $(".property-gallery nav ul");
var $featuredLocations = $(".featured-locations .js-carousel");
var $featuredPromotions = $(".featured-promotions .js-carousel");
var $featuredPromotionsList = $(".featured-promotions .featured-promotion");
var $roomTypeGallery = $(".room-gallery .js-carousel");
var $featuredPromotionsUnorderedList = $(".featured-locations .list");
var $bannerCarousel = $(".js-banner-carousel");
var $oaksDifferenceCarousel = $(".slick-difference-carousel");
var $campaignCarousel = $(".campaign-carousel .js-carousel");
var $oaksBenefits = $(".oaks-benefits-carousel .js-carousel");
var $oaksBenefitsList = $(".oaks-benefits-carousel .carousel-slide");
var $heroCarousel = $(".hero-carousel .js-carousel");
var $heroTextCarousel = $(".hero-text-carousel .js-carousel");
var $galleryContentCarousel = $(".gallery-content-carousel .js-carousel");
var $dealsCarousel = $(".deals-carousel .js-carousel");
var $portfolioCarousel = $(".portfolio-carousel .js-carousel");
var $galleryCarousel = $(".gallery-carousel .js-carousel");
var isRTL = false;
if ($("html").attr("dir") === "rtl") {
isRTL = true;
}
if (isRTL) {
var prevArrow =
'';
var nextArrow =
'';
} else {
var prevArrow =
'';
var nextArrow =
'';
}
var carouselOptions = {
mobileFirst: true,
infinite: true,
centerMode: false,
slidesToShow: 1,
centerPadding: 0,
variableWidth: false,
rtl: isRTL,
prevArrow: prevArrow,
nextArrow: nextArrow,
};
var desktopEvents = function () {
function centerNavGallery() {
// Need to centerlise the nav carousel
if ($("li", $propertyGalleryNav).length < 6) {
$propertyGalleryNav
.parent()
.css({ width: 115 * $("li", $propertyGalleryNav).length + "px" });
$propertyGalleryNav.slick("slickSetOption", { infinite: false }, true);
} else {
$propertyGalleryNav.parent().css({ width: "" });
$propertyGalleryNav.slick("slickSetOption", { infinite: true }, true);
}
}
$(document).ready(function () {
if (
$propertyGallery.length &&
$propertyGallery.hasClass("slick-initialized")
) {
$propertyGallery.slick("unslick");
}
if (
$featuredPromotionsUnorderedList.length &&
$featuredPromotionsUnorderedList.hasClass("slick-initialized")
) {
$featuredPromotionsUnorderedList.slick("unslick");
}
$carousel.each(function (idx) {
var $this = $(this);
if ($this.hasClass("slick-initialized")) {
$this.slick("unslick");
}
$this.slick({
mobileFirst: true,
dots: false,
infinite: true,
centerMode: true,
centerPadding: "60px",
variableWidth: true,
rtl: isRTL,
prevArrow: prevArrow,
nextArrow: nextArrow,
});
});
if ($propertyGallery.length) {
var $propertyGalleryFilter = $(".property-gallery-filter");
var numSlidesToShowNav = $("li", $propertyGalleryNav).length;
if (
$propertyGalleryNav.length &&
$propertyGalleryNav.hasClass("slick-initialized")
) {
$propertyGalleryNav.slick("unslick");
}
if (numSlidesToShowNav > 6) {
numSlidesToShowNav = 6;
}
$propertyGalleryNav.slick({
mobileFirst: true,
dots: false,
slidesToShow: numSlidesToShowNav,
infinite: false,
centerPadding: "0",
variableWidth: true,
arrows: false,
rtl: isRTL,
asNavFor: ".property-gallery .js-carousel",
});
$propertyGallery.slick(
"slickSetOption",
{ asNavFor: ".property-gallery nav ul" },
true
);
centerNavGallery();
var selectedCats = "li";
var selectedBoxes = 0;
$propertyGalleryFilter.on(
"click",
'input[type="checkbox"]',
function () {
var $this = $(this);
if ($this.val() === "all") {
if (!$this.is(":checked") && selectedBoxes >= 1) {
selectedBoxes = 0;
$propertyGalleryFilter
.find('li input[type="checkbox"]')
.prop("checked", false);
} else {
selectedCats = "li";
selectedBoxes = $propertyGalleryFilter.find("li").length;
$propertyGalleryFilter
.find('li input[type="checkbox"]')
.prop("checked", false);
$propertyGalleryFilter
.find('li:first-child input[type="checkbox"]')
.prop("checked", true);
}
} else {
selectedCats = "";
selectedBoxes = 0;
$propertyGalleryFilter
.find('li:first-child input[type="checkbox"]')
.prop("checked", false);
$propertyGalleryFilter.find("li").each(function () {
var $this = $(this),
$inputTag = $this.find('input[type="checkbox"]');
if ($inputTag.is(":checked")) {
selectedCats += "." + $inputTag.val() + ", ";
selectedBoxes += 1;
}
});
selectedCats = selectedCats.substring(0, selectedCats.length - 2);
}
if (selectedBoxes === 0) {
selectedCats = "li";
$propertyGalleryFilter
.find('li:first-child input[type="checkbox"]')
.prop("checked", true);
}
$propertyGallery.slick("slickUnfilter");
$propertyGalleryNav.slick("slickUnfilter");
$propertyGallery.slick("slickFilter", selectedCats);
$propertyGalleryNav.slick("slickFilter", selectedCats);
$propertyGallery.slick("slickGoTo", 0);
centerNavGallery();
}
);
// Delegated events to assign click behaviour to cloned slide too
$(".gallery-nav").on("click", ".js-property-item", function (evt) {
evt.preventDefault();
var $this = $(this);
var $parent = $this.parent();
$(".js-property-item", ".gallery-nav").removeClass("active");
$this.addClass("active");
if ($("li", $propertyGalleryNav).length < 6) {
$propertyGallery.slick("slickGoTo", $parent.index());
} else {
$propertyGallery.slick("slickGoTo", $parent.index() - 6); // minus slidesToShow value
}
});
}
if ($featuredPromotions.length) {
if ($featuredPromotions.hasClass("slick-initialized")) {
$featuredPromotions.slick("unslick");
}
if ($featuredPromotionsList.length > 4) {
$featuredPromotions.slick({
mobileFirst: true,
dots: false,
infinite: true,
centerMode: true,
slidesToShow: 4,
centerPadding: 0,
variableWidth: false,
adaptiveHeight: true,
rtl: isRTL,
prevArrow: prevArrow,
nextArrow: nextArrow,
});
}
}
if ($oaksBenefits.length) {
if ($oaksBenefits.hasClass("slick-initialized")) {
$oaksBenefits.slick("unslick");
}
if ($oaksBenefitsList.length > 3) {
$oaksBenefits.slick({
...carouselOptions,
dots: false,
infinite: false,
slidesToScroll: 1,
slidesToShow: 3,
adaptiveHeight: true,
});
}
}
if ($heroCarousel.length && $heroTextCarousel.length) {
if (
$heroCarousel.hasClass("slick-initialized") &&
$heroTextCarousel.hasClass("slick-initialized")
) {
$heroCarousel.slick("unslick");
$heroTextCarousel.slick("unslick");
}
$heroCarousel.slick({
...carouselOptions,
dots: true,
asNavFor: ".hero-text-carousel .js-carousel",
});
$heroTextCarousel.slick({
...carouselOptions,
arrows: false,
asNavFor: ".hero-carousel .js-carousel",
});
}
if ($galleryContentCarousel.length) {
if ($galleryContentCarousel.hasClass("slick-initialized")) {
$galleryContentCarousel.slick("unslick");
}
$galleryContentCarousel.slick({
...carouselOptions,
arrows: false,
dots: true,
autoplay: true,
customPaging: function (slider, i) {
var title = $(slider.$slides[i]).data("title");
return (
'