if (typeof jQuery != "undefined") {
$ = jQuery;
}
function format_time(hour, minute) {
var h = hour > 9 ? "" + hour: "0" + hour;
var m = minute > 9 ? "" + minute: "0" + minute;
return h+":"+m;
}
var bookingWidgetController = function () {
return {
config: {
language: $("html").attr("lang") ? $("html").attr("lang").replace(/[-_].*/, '') : $("html").attr("xml:lang").replace(/[-_].*/, ''),
base_url: "//checkin-hotels-dot-checkin-hoteles.appspot.com",
widget_url: "//checkin-hotels-dot-checkin-hoteles.appspot.com/checkinwidget/",
only_adults: "",
dependcencies_added: typeof(bookingWidgetController) == "undefined" ? false : bookingWidgetController.config.dependcencies_added,
datepicker_added: false,
css_list : [
"//checkin-hotels-dot-checkin-hoteles.appspot.com/static_1/plugins/dates-selector/css/datepicker_ext_inf.css?v=1.16",
"//checkin-hotels-dot-checkin-hoteles.appspot.com/static_1/css/checkin_injection/booking_widget_checkin_injection.css?v=1.16",
"//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css",
"//checkin-hotels-dot-checkin-hoteles.appspot.com/static_1/plugins/pricescalendar/styles.css?v=1.16",
"//checkin-hotels-dot-checkin-hoteles.appspot.com/static_1/css/datepicker.redmond/jquery-ui-1.8.16.custom.min.css?v=1.16"
],
/*Special configs*/
avoid_guest_autoclose_click: false
},
init: function () {
this.prepare_dependencies();
},
prepare_dependencies: function () {
var base_url = bookingWidgetController.config.base_url,
lang = bookingWidgetController.config.language;
if (!bookingWidgetController.config.dependcencies_added) {
$.getScript(base_url + "/static_1/lib/jquery-ui-1.10.1.custom.min.modified.js?v=1.16").done(function () {
$.getScript(base_url + "/static_1/js/mainWebSkeletonAux_injection.js?v=1.16");
$.getScript(base_url + "/static_1/lib/selectric/jquery.selectric.1.8.js?v=1.16").done(function () {
$.getScript(base_url + "/static_1/lib/jquery-i18n-1.1.1/jquery.i18n.js?v=1.16").done(function () {
$.getScript(base_url + "/static_1/i18n/messages_" + lang + ".js?v=1.16").done(function () {
$.i18n.load(messages);
bookingWidgetController.get_booking_widget_html();
bookingWidgetController.config.dependcencies_added = true;
});
});
});
});
}
},
get_booking_widget_html: function () {
bookingWidgetController.load_css();
var language_widget = bookingWidgetController.config.language;
$("html").attr("lang", language_widget);
$.get(bookingWidgetController.config.widget_url + bookingWidgetController.config.language, function (e) {
bookingWidgetController.config.widget_html = $("
").html(e);
}).done(function () {
bookingWidgetController.add_widget_html();
bookingWidgetController.add_button_mobile_version_html();
bookingWidgetController.adding_tags_to_config();
bookingWidgetController.load_datepicker();
bookingWidgetController.open_widget();
bookingWidgetController.close_widget();
bookingWidgetController.click_listeners();
if ($("#add_analytics_campaings_tracking") && $("#add_analytics_campaings_tracking").length > 0) {
injectionCampaignsController.init()
}
});
},
load_css: function () {
var list_css = bookingWidgetController.config.css_list;
for (var i = 0; i < list_css.length; i++) {
$('head').append($('').attr('href', list_css[i]));
}
},
add_widget_html: function() {
},
add_button_mobile_version_html: function() {
let target_container = $("#widget_paraty").length ? $("#widget_paraty") : $("#widget-paraty");
target_container.append($("").html($.i18n._("reserva_ahora")));
target_container.find("#full_wrapper_booking").append($(""));
},
load_datepicker: function () {
var lang = bookingWidgetController.config.language,
base_url = bookingWidgetController.config.base_url;
// Refactor in a external function
if (!bookingWidgetController.config.datepicker_added) {
$.getScript(base_url + "/static_1/plugins/pricescalendar/calendar.plugin.js?v=1.16");
$.getScript(base_url + "/static_1/js/datepicker/jquery.ui.datepicker-" + lang + ".js?v=1.16").done(function () {
$.getScript(base_url + "/static_1/plugins/dates-selector/datepicker_v1.js").done(function () {
_set_datepicker_regional($);
bookingWidgetController.datepicker_configuration();
$.getScript(base_url + "/static_1/scripts/booking_7.js?v=1.16").done(function () {
bookingWidgetController.after_load_booking_script();
bookingWidgetController.custom_functions();
bookingWidgetController.config.datepicker_added = true
});
});
});
}
},
after_load_booking_script: function() {
_set_datepicker_regional($);
$(".room_selector").selectric({disableOnMobile: false});
$(".rooms_number").selectric({disableOnMobile: false});
DP_extend_info.init();
bookingWidgetController.prepare_guest_selector();
bookingWidgetController.adding_room_tag_selector();
bookingWidgetController.set_occupancy_number();
bookingWidgetController.update_date_by_timezone();
},
update_date_by_timezone: function() {
if ($("#timeLimit").length>0) {
var _limit = $("#timeLimit").val();
var _now = new Date();
var _hour = format_time(_now.getHours(), _now.getMinutes());
if (_hour > _limit) {
_now.setUTCDate(_now.getUTCDate() + 1);
}
var datepicker_sd = $('.' + DP_extend_info.config.class_datepicker_sd);
datepicker_sd.datepicker('option', 'minDate', new Date(_now.getFullYear(),_now.getMonth(),_now.getDate()));
var datestart = _now.getDate()+"/"+(_now.getMonth()+1)+"/"+_now.getFullYear();
updateDates(datestart);
$("input[name='startDate']").val(datestart);
_set_start_date(datestart);
_now.setUTCDate(_now.getUTCDate() + 1);
datepicker_departure_date = $.datepicker.formatDate("dd-mm-yy", _now);
datepicker_departure_date = datepicker_departure_date.replace(new RegExp("-", "g"), '/');
$("input[name='endDate']").val(datepicker_departure_date);
_set_end_date(datepicker_departure_date);
$('.departure_datepicker').datepicker('option', 'minDate', _now);
}
},
datepicker_configuration: function() {
DP_extend_info.config.booking_version = '5';
DP_extend_info.config.hotel_path_endpoint = bookingWidgetController.config.base_url;
bookingWidgetController.separate_entry_departure_datepicker();
DP_extend_info.config.custom_format_day_month = bookingWidgetController.custom_format_date;
},
separate_entry_departure_datepicker: function() {
DP_extend_info.config.start_date_selector = ".entry_date_wrapper";
DP_extend_info.config.end_date_selector = ".departure_date_wrapper";
DP_extend_info.config.start_datepicker_span = ".entry_date_wrapper .date_day";
DP_extend_info.config.end_datepicker_span = ".departure_date_wrapper .date_day";
},
custom_format_date: function(dateComponents) {
dateComponents = dateComponents.split("/");
var month_names = $.datepicker._defaults.monthNames,
html_date = "%d
%m
%y
",
month = (parseInt(dateComponents[1]) - 1);
return html_date.replace("%d", dateComponents[0]).replace("%m", month_names[month]).replace("%y", dateComponents[2]);
},
prepare_guest_selector: function () {
$("select.room_selector").unbind("change");
$("select.room_selector, select.rooms_number").change(function () {
bookingWidgetController.set_occupancy_number();
});
},
adding_room_tag_selector: function () {
$("select.rooms_number option").each(function (index, element) {
var room_tag = parseInt($(element).val()) === 1 ?
bookingWidgetController.config.room_tag : bookingWidgetController.config.rooms_tag;
$(element).text($(element).text() + " " + room_tag);
});
$("select.rooms_number").selectric("refresh");
},
set_occupancy_number: function () {
var number_of_rooms = $("select[name='numRooms']").val(),
adults_number = 0,
kids_number = 0,
babies_number = 0;
if (number_of_rooms) {
for (var room_loop = 1; room_loop <= number_of_rooms; room_loop++) {
var actual_select_adults = $("select[name='adultsRoom" + room_loop + "']").val(),
actual_select_kids = $("select[name='childrenRoom" + room_loop + "']").val(),
actual_select_baby = $("select[name='babiesRoom" + room_loop + "']").val();
adults_number += parseInt(actual_select_adults);
kids_number += parseInt(actual_select_kids);
babies_number += parseInt(actual_select_baby);
}
}
var target_placeholder = $(".guest_selector .placeholder_text"),
placeholder_string = bookingWidgetController.occupancy_format_html();
var room_tag = number_of_rooms === 1 ?
bookingWidgetController.config.room_tag : bookingWidgetController.config.rooms_tag;
var adult_tag = adults_number === 1 ?
bookingWidgetController.config.adult_text : bookingWidgetController.config.adults_text;
var kid_tag = kids_number === 1 ?
bookingWidgetController.config.kid_text : bookingWidgetController.config.kids_text;
var baby_tag = babies_number === 1 ?
bookingWidgetController.config.baby_text : bookingWidgetController.config.babies_text;
placeholder_string = placeholder_string.replace("@@N_R@@", number_of_rooms).replace("@@T_R@@", room_tag)
.replace("@@N_A@@", adults_number).replace("@@T_A@@", adult_tag)
.replace("@@N_C@@", kids_number).replace("@@T_C@@", kid_tag)
.replace("@@N_B@@", babies_number).replace("@@T_B@@", baby_tag);
target_placeholder.html(placeholder_string);
},
occupancy_format_html: function() {
var occupancy_string = '';
if (this.config.only_adults) {
occupancy_string = "@@N_A@@ @@T_A@@";
} else {
occupancy_string = "@@N_A@@ @@T_A@@ / @@N_C@@ @@T_C@@";
}
return occupancy_string;
},
open_widget: function () {
$("#floating_button").click(function () {
$("#full_wrapper_booking").fadeIn();
});
},
close_widget: function () {
$("i.fa-times.close_widget").click(function () {
$("#full_wrapper_booking").fadeOut();
});
},
click_listeners: function () {
if (!this.config.avoid_guest_autoclose_click) {
$("html").click(function (event) {
var event_target = $(event.target);
if (!event_target.closest(".room_list_wrapper").length && !event_target.closest(".guest_selector").length) {
$(".room_list_wrapper").slideUp();
}
});
}
},
adding_tags_to_config: function () {
bookingWidgetController.config.adults_text = $("#adults_tag").val();
bookingWidgetController.config.adult_text = $("#adult_tag").val();
bookingWidgetController.config.kids_text = $("#kids_tag").val();
bookingWidgetController.config.kid_text = $("#kid_tag").val();
bookingWidgetController.config.babies_text = $("#babies_tag").val();
bookingWidgetController.config.baby_text = $("#baby_tag").val();
bookingWidgetController.config.room_tag = $("#room_tag").val();
bookingWidgetController.config.rooms_tag = $("#rooms_tag").val();
},
custom_functions: function(){
}
};
}();
const injectionCampaignsController = (function () {
return {
init() {
this.processCampaignInfo();
},
getUrlParameter(sParam) {
const sPageURL = decodeURIComponent(window.location.search.substring(1));
const sURLVariables = sPageURL.split('&');
for (const sVariable of sURLVariables) {
const [key, value] = sVariable.split('=');
if (key === sParam) {
return value === undefined ? true : value;
}
}
return undefined;
},
createCookie(key, value, durationInDays = 365) {
const targetExpiryDate = new Date();
targetExpiryDate.setDate(targetExpiryDate.getDate() + durationInDays);
document.cookie = `${key}=${value};path=/;expires=${targetExpiryDate.toUTCString()};`;
},
searchCookie(key) {
const cookies = document.cookie.split(';');
for (const cookie of cookies) {
const [cookieKey, cookieValue] = cookie.trim().split('=');
if (cookieKey === key) {
return cookieValue;
}
}
return undefined;
},
saveCampaignInfo() {
const availableCampaignParams = [
'utm_source', 'utm_medium', 'utm_campaign', 'utm_term',
'utm_content', 'utm_id', 'partner'
];
const cookieToSet = {};
availableCampaignParams.forEach(param => {
const retrievedParam = this.getUrlParameter(param);
if (retrievedParam) {
cookieToSet[param] = retrievedParam;
}
});
if (!$.isEmptyObject(cookieToSet)) {
const cookieToSetJson = JSON.stringify(cookieToSet);
this.createCookie("analytics_campaign", cookieToSetJson);
}
},
addCampaignToWidget() {
const retrievedCookie = this.searchCookie('analytics_campaign');
if (!retrievedCookie) return;
const loadedCookie = JSON.parse(retrievedCookie);
$(".paraty-booking-form").each(function () {
for (const [keyCampaign, value] of Object.entries(loadedCookie)) {
const inputToAppend = $("").attr({
name: keyCampaign,
value: value
});
$(this).append(inputToAppend);
}
});
},
processCampaignInfo() {
this.saveCampaignInfo();
this.addCampaignToWidget();
}
};
})();
bookingWidgetController.config.avoid_guest_autoclose_click = true;
bookingWidgetController.add_widget_html = function () {
var paraty_widget = bookingWidgetController.config.widget_html;
if (!$("#widget_paraty").length) {
$("body").append($(""));
$("#widget_paraty").addClass('auto-position');
}
$("#widget_paraty").html(paraty_widget);
let namespaceClass = $("#widget_paraty input#extra_widget_class").length ? $("#widget_paraty input#extra_widget_class").val() : ""
if (namespaceClass) {
$("#widget_paraty").addClass(namespaceClass);
$("body").addClass(namespaceClass)
}
if ($("#widget_paraty .destination_wrapper").length) {
$("#widget_paraty").addClass('has-hotel-selector');
}
$("#widget_paraty .booking_steps").detach().appendTo($('body'));
$("#widget_paraty").before($(""))
};
bookingWidgetController.add_button_mobile_version_html = function () {
if (!$("#floating_button_paraty").length) {
$("body").append($("").html($.i18n._("reserva_ahora")));
$("#floating_button_paraty").addClass('auto-position');
if ($("#widget_paraty input#extra_widget_class").length)
$("#floating_button_paraty").addClass($("#widget_paraty input#extra_widget_class").val());
}
$("#widget_paraty #full_wrapper_booking").append($(""));
}
bookingWidgetController.custom_format_date = function (dateComponents) {
dateComponents = dateComponents.split("/");
var html_date = "%d %m";
let date = new Date();
date.setMonth(dateComponents[1] - 1);
let month = date.toLocaleString([], {
month: 'short',
});
month = month.charAt(0).toUpperCase() + month.slice(1);
return html_date.replace("%d", dateComponents[0]).replace("%m", month);
};
bookingWidgetController.adding_room_tag_selector = function () {
$("select.rooms_number option").each(function (index, element) {
$(element).text($(element).text());
});
$("select.rooms_number").selectric("refresh");
};
bookingWidgetController.open_widget = function () {
$("#floating_button_paraty").click(function (e) {
e.preventDefault();
$("#widget_paraty").fadeToggle();
});
};
bookingWidgetController.close_widget = function () {
$("i.fa-times.close_widget").click(function () {
$("#widget_paraty").fadeOut();
$(".booking_steps").hide();
$("body").removeClass("widget_paraty_open");
});
};
bookingWidgetController.custom_functions = function () {
bookingWidgetController.config.languages = {
"es": "SPANISH",
"en": "ENGLISH"
};
//Get fontawesome 6
var script_fa_tag = document.createElement('script');
script_fa_tag.src = 'https://kit.fontawesome.com/d8b9925505.js';
script_fa_tag.setAttribute("defer", "");
document.head.appendChild(script_fa_tag);
booking_engine_controller();
prepare_guests_selector();
set_occupancy_number();
room_selector_dates();
init_calendar();
hotel_selector_tabs();
hotel_filter_by_input();
changeAgeKidsText();
hotel_preselected();
$("#full_wrapper_booking .children_selector select.room_selector").change(function () {
check_kids_ages($(this));
});
if ($("#booking").length) {
$("#full_wrapper_booking .kidAgesSelect").selectric();
}
let hotel_preselection = $("#widget_paraty").attr("data-hotel-namespace");
let destiny_preselection = $("#widget_paraty").attr("data-destino");
if (hotel_preselection) {
selectHotel(hotel_preselection);
} else if (destiny_preselection) {
let destiny = $(".booking_0_destiny").filter(function () {
return (
$(this).attr("hotel_name").toLowerCase() == destiny_preselection.toLowerCase()
);
});
destiny.click();
$("#full-booking-engine-html-7 .calendar_root_wrapper").css(
"display",
"none"
);
}
let destination_placeholder = $.i18n._('T_establecimiento') + ' - ' + $.i18n._('T_destino');
$('#widget_paraty .destination_wrapper .destination_fieldo .destination').attr('placeholder', destination_placeholder);
$('#widget_paraty .widget_contact_selected').on('click', function () {
$(this).toggleClass('active');
$(this).siblings('.widget_contact_desc').slideToggle('fast');
})
let ol_map_library_url = 'https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.2.1/build/ol.js'
$.getScript(ol_map_library_url, function () {
ol_map();
});
//control for booking-steps class
$("#widget_paraty .hotel_selector .hotel_selector_filter .destiny_filter.load_map").click(function () {
$('.hotel_selector').addClass('no_gradient');
})
$("#widget_paraty .hotel_selector .hotel_selector_filter .destiny_filter.hotels").click(function () {
$('.hotel_selector').removeClass('no_gradient');
})
};
function hotel_selector_tabs() {
//show hotels list or map
let hotel_selector_tabs = $('#widget_paraty .hotel_selector_filter .destiny_filter');
let hotel_selector_tab_element = $('#widget_paraty .hotel_selector .tab_element');
hotel_selector_tabs.each(function () {
let tab_filter = $(this);
let tab_filter_data = tab_filter.data('filter')
tab_filter.on('click', function () {
$(this).addClass('active');
$(this).siblings('.destiny_filter').removeClass('active');
hotel_selector_tab_element.each(function () {
let tab_element_data = $(this).data('item');
if (tab_filter_data === tab_element_data) {
$(this).show().css('z-index', '2');
$(this).siblings('.tab_element').fadeOut();
} else {
$(this).hide().css('z-index', '1');
$(this).siblings('.tab_element').fadeIn();
}
})
})
})
}
function init_calendar() {
window.calendar_data.change_date_callback = function (date, isStartDateSelection) {
function format(inputDate) {
let date, month, year;
date = inputDate.getDate();
month = inputDate.getMonth() + 1;
year = inputDate.getFullYear();
date = date.toString().padStart(2, '0');
month = month.toString().padStart(2, '0');
return `${date}/${month}/${year}`;
}
let widget_form_wrapper = $('#full_wrapper_booking .paraty-booking-form');
let date_formated = format(date);
let day_month_format = $.datepicker.formatDate('dd M', date);
let year_format = $.datepicker.formatDate('yy', date);
if (isStartDateSelection) {
widget_form_wrapper.find('input[name=startDate]').val(date_formated);
widget_form_wrapper.find('.entry_date .date_day').html(day_month_format);
widget_form_wrapper.find('.entry_date .date_year').html(year_format);
} else {
widget_form_wrapper.find('input[name=endDate]').val(date_formated);
widget_form_wrapper.find('.departure_date .date_day').html(day_month_format);
widget_form_wrapper.find('.departure_date .date_year').html(year_format);
$(".booking_steps .step_3").trigger('click');
$('.booking_steps .step_2').addClass('done');
}
load_new_room_dates();
};
}
function prepare_guests_selector() {
$("select.room_selector").unbind("change");
$(".room_selector").selectric('destroy');
$(".room_selector").selectric({disableOnMobile: false});
$("select.room_selector, select.rooms_number").change(function () {
set_occupancy_number();
});
$(".remove_room_element").click(function () {
var actual_room_numbers = $("select.rooms_number").val();
if (actual_room_numbers > 1) {
var target_room_number = parseInt(actual_room_numbers) - 1;
$("select.rooms_number option").removeAttr('selected');
$("select.rooms_number option[value='" + target_room_number + "']").attr('selected', 'selected');
$(".room" + actual_room_numbers).hide();
$("select.rooms_number").val(target_room_number);
$("select.rooms_number").selectric("refresh");
}
set_occupancy_number()
});
var add_room_html = "" + $.i18n._('T_add_another_room') + "
",
remove_room_html = "" + $.i18n._('T_eliminar') + ' ' + $.i18n._('T_habitacion') + "
",
close_btn = "",
close_calendar_btn = "",
booking_btn = "";
$(".room_list_wrapper").append(close_btn);
$(".calendar_root_wrapper").append(close_calendar_btn);
$(".room_list_wrapper .room_list .room").each(function () {
$(this).append(add_room_html);
});
$(".room_list_wrapper .room_list .room2").append(remove_room_html);
$(".room_list_wrapper .room_list .room3").append(remove_room_html);
$(".add_room").click(add_room);
$(".remove_room").click(remove_room);
$(".room_list_wrapper .room_list").append(booking_btn);
const motorPromocodeInput = $(".wrapper_booking_button .promocode_wrapper input.promocode_input");
const popupPromocodeInput = $(".wrapper_booking_button_guest #popup_promocode");
popupPromocodeInput.change(function () {
motorPromocodeInput.val($(this).val());
});
motorPromocodeInput.change(function () {
popupPromocodeInput.val($(this).val());
});
$(".wrapper_booking_button_guest .submit_button").click(function () {
$(".wrapper_booking_button .submit_button").click();
});
$(document).on("click", ".close_guest_selector, .close_calendar_app", function () {
$(".booking_steps .step_1, .booking_steps .step_2, .booking_steps .step_3").removeClass("current_step");
$(".hotel_selector").slideUp();
$(".calendar_root_wrapper").slideUp();
$(".room_list_wrapper").slideUp();
$("#full_wrapper_booking").removeClass("fixed");
$("#widget_paraty").removeClass("open");
$('.booking_steps').hide();
$("body").removeClass("widget_paraty_open");
});
$(".adults_selector .selectric-room_selector .label").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 8, 0, 1);
});
$(".adults_selector .selectric-room_selector .button").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 9, 1, -1);
});
$(".children_selector .selectric-room_selector .label").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 4, -1, 1);
check_kids_ages($(this).closest(".selectric-room_selector").find("select.room_selector"));
});
$(".children_selector .selectric-room_selector .button").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 5, 0, -1);
check_kids_ages($(this).closest(".selectric-room_selector").find("select.room_selector"));
});
$(".babies_selector .selectric-room_selector .label").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 2, -1, 1);
});
$(".babies_selector .selectric-room_selector .button").click(function () {
change_selectric_rooms($(this), ".selectric-room_selector", "select.room_selector", 3, 0, -1);
});
}
function change_selectric_rooms(element, parent_class, select, max, min, operator) {
var selectric_element = element.closest(parent_class).find(select),
label_for = element.closest(".range_label_enabled");
if (parseInt(selectric_element.val()) > min &&
parseInt(selectric_element.val()) < max) {
var new_select_val = parseInt(selectric_element.val()) + operator;
selectric_element.val(new_select_val);
selectric_element.selectric('refresh');
set_occupancy_number();
}
}
function add_room() {
var number_rooms = parseInt($("select.rooms_number").val());
if (number_rooms < 3) {
$($(".selectric-rooms_number .selectricItems li").get(number_rooms)).trigger("click");
set_occupancy_number();
}
if (number_rooms == 1) {
$(".room1 .add_room").hide();
$(".room1 .add_room").addClass('hidden');
}
if (number_rooms == 2) {
$(".add_room").hide();
$(".add_room").addClass('hidden');
$(".room2 .remove_room").hide();
$(".room2 .remove_room").addClass('hidden');
}
}
function remove_room(event) {
const target_element = $(event.target);
const ages_selector = target_element.parent().next();
if (ages_selector.length && ages_selector.hasClass('showed')) {
ages_selector.slideUp(function () {
$(this).css("overflow", "inherit");
$(this).removeClass('showed');
});
}
var number_rooms = parseInt($("select.rooms_number").val());
if (number_rooms > 1) {
$($(".selectric-rooms_number .selectricItems li").get(number_rooms - 2)).trigger("click");
set_occupancy_number();
}
if (number_rooms == 2) {
$(".room1 .remove_room").show();
$(".room1 .remove_room").removeClass('hidden');
$(".room1 .add_room").show();
$(".room1 .add_room").removeClass('hidden');
}
if (number_rooms == 3) {
$(".room2 .remove_room").show();
$(".room2 .add_room").show();
$(".room2 .remove_room").removeClass('hidden');
$(".room2 .add_room").removeClass('hidden');
}
$("select.rooms_number").change(function (event) {
var number = $(this).val(),
_room1 = $(".room1"),
_room2 = $(".room2"),
_room3 = $(".room3"),
_room_age1 = $(".room_ages_1"),
_room_age2 = $(".room_ages_2"),
_room_age3 = $(".room_ages_3");
if (number == 1) {
_room2.hide().promise().done(function () {
_room2.css("overflow", "initial");
});
_room_age2.removeClass("show")
_room_age3.removeClass("show")
_room3.hide().promise().done(function () {
_room3.css("overflow", "initial");
});
$(".horizontal_engine").css("height", "379px");
} else if (number == 2) {
_room2.show("fast").promise().done(function () {
_room2.css("overflow", "initial");
});
_room_age3.removeClass("show")
_room3.hide().promise().done(function () {
_room3.css("overflow", "initial");
});
$(".horizontal_engine").css("height", "449px");
} else {
_room2.show("fast").promise().done(function () {
_room2.css("overflow", "initial");
});
_room3.show().promise().done(function () {
_room3.css("overflow", "initial");
});
$(".horizontal_engine").css("height", "518px");
}
});
}
function toggle_guest_selector() {
var target_room_wrapper = $(".room_list_wrapper");
if (!target_room_wrapper.hasClass('active')) {
target_room_wrapper.addClass('active');
target_room_wrapper.show();
} else {
target_room_wrapper.removeClass('active');
target_room_wrapper.hide();
}
set_occupancy_number();
}
function set_occupancy_number() {
var number_of_rooms = parseInt($("select[name='numRooms']").val()),
adults_number = 0,
kids_number = 0,
babies_number = 0;
let hotel_selected = $(".hotel_selector_option.selected");
let adults_only = hotel_selected.attr('data-adults-only'),
include_babies = hotel_selected.attr('data-show-babies');
if (number_of_rooms){
for (let room_loop = 1;room_loop <= number_of_rooms;room_loop++){
let actual_select_adults = $("select[name='adultsRoom" + room_loop + "']").val(),
actual_select_kids = 0,
actual_select_babies = 0;
/* Update kids value */
if(adults_only){
$("select[name='childrenRoom" + room_loop + "']").val(0);
} else{
actual_select_kids = $("select[name='childrenRoom" + room_loop + "']").val();
}
/* Update babies value */
if(include_babies){
actual_select_babies = $("select[name='babiesRoom" + room_loop + "']").val();
} else{
$("select[name='babiesRoom" + room_loop + "']").val(0);
}
if(actual_select_adults || actual_select_kids || actual_select_babies){
adults_number += parseInt(actual_select_adults);
kids_number += parseInt(actual_select_kids);
babies_number += parseInt(actual_select_babies);
}
}
}
var target_placeholder = $(".guest_selector .placeholder_text");
adults_number = parseInt(adults_number);
kids_number = parseInt(kids_number);
babies_number = parseInt(babies_number);
let placeholder_string = "" + adults_number + " " + $.i18n._('T_adultos') + "";
if(!adults_only){
placeholder_string += " + " + kids_number + " " + $.i18n._('T_ninos') + "";
}
if(include_babies) {
placeholder_string += " + " + babies_number + " " + $.i18n._('T_bebes') + "";
}
target_placeholder.html(placeholder_string);
}
bookingWidgetController.after_load_booking_script = function () {
_set_datepicker_regional($);
$(".room_selector").selectric({disableOnMobile: false});
$(".rooms_number").selectric({disableOnMobile: false});
bookingWidgetController.prepare_guest_selector();
bookingWidgetController.adding_room_tag_selector();
bookingWidgetController.set_occupancy_number();
bookingWidgetController.update_date_by_timezone();
};
bookingWidgetController.datepicker_configuration = function () {
let is_mobile = ($(window).width() <= 1140);
DP_extend_info.config.booking_version = '5';
DP_extend_info.config.hotel_path_endpoint = bookingWidgetController.config.base_url;
DP_extend_info.config.months_show = (is_mobile) ? 1 : 2;
DP_extend_info.config.months_show_highlight = true;
DP_extend_info.config.force_hightlight = true;
DP_extend_info.config.custom_format_day_month = function (dateComponents) {
dateComponents = dateComponents.split("/");
var month_short = $.datepicker._defaults['monthNamesShort'][parseInt(dateComponents[1], 10) - 1];
return "" + dateComponents[0] + "" + month_short + "";
};
DP_extend_info.init();
};
function room_selector_dates() {
var room_list_wrapper = $('.room_list_wrapper .room_list'),
dates_wrapper = $('');
if (room_list_wrapper.length) {
room_list_wrapper.prepend(dates_wrapper);
}
$('.dates_wrapper, .stay_selection').on('click', function () {
$(".booking_steps .step_2").trigger('click');
});
}
function check_kids_ages(select_element) {
var parent_list = select_element.closest("li"),
selected_value = select_element.val(),
target_age_selector = parent_list.next(".full_ages_wrapper"),
childs_elements = target_age_selector.find(".kid_age_element_wrapper"),
target_childs_elements = childs_elements.slice(0, parseInt(selected_value));
if (parseInt(selected_value)) {
childs_elements.css('display', 'none');
target_childs_elements.css('display', 'block');
target_age_selector.slideDown(function () {
$(this).css("overflow", "inherit");
$(this).addClass('showed');
});
} else {
childs_elements.css('display', 'none');
target_age_selector.slideUp(function () {
$(this).css("overflow", "inherit");
$(this).removeClass('showed');
});
}
}
function load_new_room_dates() {
if ($('.dates_wrapper').length) {
var start_date = $.datepicker.parseDate("dd/mm/yy", $("input[name=startDate]").val()),
start_date_format = $.datepicker.formatDate("dd MM", start_date),
end_date = $.datepicker.parseDate("dd/mm/yy", $("input[name=endDate]").val()),
end_date_format = $.datepicker.formatDate("dd MM", end_date);
$(".room_info_wrapper .dates_wrapper").html(decodeEntities($.i18n._("T_habitaciones_y_ocuapcion")));
}
}
function hotel_preselected() {
const uri = window.location.pathname;
let hotel_equivalencies = $(".hotel_selector .hotel_selector_option");
hotel_equivalencies.each(function() {
let preselectedHotel = $(this).attr("data-hotel-preselected");
if (preselectedHotel && uri.includes(preselectedHotel)) {
selectHotel($(this).attr("id"));
}
});
}
function selectHotel(namespace) {
let widget = $("#widget_paraty"),
booking_form = widget.find('.booking_form');
let hotel_selected_element = $(".hotel_selector .hotel_selector_option#" + namespace);
let hotel_title_selector_html = hotel_selected_element.find(".title_selector").html() ?? ""
let new_placeholder_html = hotel_title_selector_html.replace("
", " ").replace("&", "&").replace(/<.*?>/g, "")
let url_booking = widget.find("#url_booking_" + namespace).val(),
hotel_value = ""
if (url_booking) {
hotel_value = url_booking.indexOf('http') > -1 ? url_booking : `https://${namespace}${url_booking}`
}
widget.find(".destination").val(new_placeholder_html);
booking_form.attr("action", hotel_value).find("#namespace").val(namespace);
if(hotel_selected_element.attr('data-adults-only')){
$('.room_list_wrapper').addClass('adults_only').removeClass('show_babies');
} else{
$('.room_list_wrapper').removeClass('adults_only');
}
if(hotel_selected_element.attr('data-show-babies')){
$('.room_list_wrapper').addClass('show_babies');
} else{
$('.room_list_wrapper').removeClass('show_babies');
}
setTimeout(() => {
window.calendar_data.update_namespace_calendar(namespace);
set_occupancy_number();
}, 100);
}
function booking_engine_controller() {
let widget = $("#widget_paraty"),
booking_form = widget.find('.booking_form');
$(".destination_wrapper").click(function () {
$(".booking_steps .step_1, .booking_steps .step_2, .booking_steps .step_3").removeClass("current_step");
//$(".close_button_datepicker").click();
$(".close_calendar_app").click();
$(".close_room_selector").click();
$(".hotel_selector").slideDown();
$(".booking_steps .step_1").addClass("current_step");
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$("#full_wrapper_booking").addClass("fixed");
load_new_room_dates();
if ($("#filter_selector").length) {
_filter_selector($(this));
}
});
widget.find(".hotel_selector_option").click(function () {
widget.find(".hotel_selector").hide("fast");
widget.find(".hotel_selector_option").removeClass("selected");
$(this).addClass("selected");
selectHotel($(this).attr("id"))
$('.price_calendar_wrapper .toggle_chart').css('opacity', '1').css('pointer-events', 'auto');
});
$(document).on("click", ".booking_steps .step_1", function () {
$(".booking_steps .step_2, .booking_steps .step_3").removeClass("current_step");
$(".close_button_datepicker").click();
$(".close_room_selector").click();
$(".close_calendar_app").click();
$(".hotel_selector").slideDown();
$(".booking_steps .step_1").addClass("current_step");
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$("#full_wrapper_booking").addClass("fixed");
load_new_room_dates();
});
$(document).on("click", ".booking_steps .step_2:not(.current_step)", function () {
$(".booking_steps .step_1, .booking_steps .step_3").removeClass("current_step");
$(".hotel_selector .close").click();
$(".close_room_selector").click();
$(".calendar_root_wrapper").slideDown();
$(".booking_steps .step_2").addClass("current_step");
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$("#full_wrapper_booking").addClass("fixed");
load_new_room_dates();
});
$(document).on("click", ".booking_steps .step_3:not(.current_step)", function () {
$(".guest_selector").click();
load_new_room_dates();
});
$(".guest_selector").click(function () {
$(".booking_steps .step_1, .booking_steps .step_2, .booking_steps .step_3").removeClass("current_step");
$(".hotel_selector").slideUp();
$(".calendar_root_wrapper").slideUp();
$(".room_list_wrapper").slideDown();
$(".booking_steps .step_3").addClass("current_step");
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$("#full_wrapper_booking").addClass("fixed");
load_new_room_dates();
});
$(".hotel_selector_inner li").click(function (e) {
$(".booking_steps .step_1").removeClass("current_step");
$('.booking_steps .step_1').addClass('done');
if (!$("#widget_paraty").hasClass("dates_selected")) {
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$(".booking_steps .step_2").addClass("current_step");
$(".calendar_root_wrapper").slideDown();
load_new_room_dates();
} else {
if ($("#full_wrapper_booking").hasClass("fixed")) {
$(".hotel_selector").hide();
$(".booking_steps .step_2").removeClass("current_step");
$("body").addClass("widget_paraty_open");
if (!$('.calendar_app').is(':visible')) {
$("#widget_paraty").addClass("open");
$('.booking_steps').show();
$("body").addClass("widget_paraty_open");
$(".booking_steps .step_3").addClass("current_step");
$(".room_list_wrapper").slideDown();
load_new_room_dates();
}
}
}
});
$(".close_button_datepicker").unbind("click");
$(".close_button_datepicker").click(function () {
$("#widget_paraty").removeClass("open");
$('.booking_steps').hide();
$("body").removeClass("widget_paraty_open");
$("#full_wrapper_booking").removeClass("fixed");
$(".booking_steps .step_2").removeClass("current_step");
});
$(".hotels_group .hotels_grouped_list .booking_0_destiny").click(function () {
setTimeout(() => {
window.calendar_data.update_namespace_calendar("")
}, 100)
let booking_0_domain = '';
if ($('#booking_0_domain').length) {
booking_0_domain = $('#booking_0_domain').val();
}
let all_namespaces = $(this).attr('namespaces'),
hotel_name = $(this).attr('hotel_name');
$(".hotel_selector").slideUp();
$("#full-booking-engine-html-7 .calendar_root_wrapper").css("display", "block");
booking_form.attr("action", booking_0_domain + "/booking0");
booking_form.find(".destination").val(hotel_name);
if (!booking_form.find("input[name='applicationIds']").length) {
$("").appendTo(booking_form);
}
booking_form.find("input[name='applicationIds']").val(all_namespaces);
});
$(".hotel_selector .close").click(function (e) {
e.preventDefault();
$(this).toggleClass("active");
$(".hotel_selector").slideUp();
$("booking_steps .step_1").removeClass("current_step");
$("#widget_paraty").removeClass("open");
$('.booking_steps').hide();
$("body").removeClass("widget_paraty_open");
$("#full_wrapper_booking").removeClass("fixed");
});
$(".wrapper_booking_button .submit_button").click(function () {
if ($(".destination_fieldo input[name=destination]").val() !== "") {
$(".booking_steps .step_1, .booking_steps .step_2, .booking_steps .step_3").removeClass("current_step");
$(".close_button_datepicker").click();
$(".close_room_selector").click();
} else {
$(".booking_steps .step_1").click();
}
});
//select hotels from map cards
$('.hotel_card .bottom .button-promotion').click(function () {
let hotel_card_namespace = $(this).data('namespace');
let hotel_option = $('.hotel_selector_option');
hotel_option.each(function () {
let hotel_option_namespace = $(this).attr('id');
if (hotel_card_namespace === hotel_option_namespace) {
$(this).trigger('click');
}
})
})
}
function select_hotel_selector(option) {
let widget = $("#widget_paraty");
widget.find(".hotel_selector").hide("fast");
widget.find(".hotel_selector_option").removeClass("selected");
option.addClass("selected");
let titleSelectorHtml = option.find(".title_selector").html() ?? "";
let new_placeholder_html = titleSelectorHtml.replace("
", " ").replace("&", "&").replace(/<.*?>/g, "");
let id_hotel_4_url = option.attr("id"),
new_namespace = widget.find("#namespace_" + id_hotel_4_url).val() ?? "",
url_booking = widget.find("#url_booking_" + id_hotel_4_url).val() ?? "",
hotel_value = ""
if (url_booking) {
hotel_value = url_booking.indexOf('http') > -1 ? url_booking : `https://${id_hotel_4_url}${url_booking}`
}
//Change calendar namespace
window.calendar_data.update_namespace_calendar(new_namespace);
$('.price_calendar_wrapper .toggle_chart').css('opacity', '1').css('pointer-events', 'auto');
//change the value
widget.find(".destination").val(new_placeholder_html);
widget.find("form").attr("action", hotel_value).find("#namespace").val(new_namespace);
}
const decodeEntities = (() => {
const element = document.createElement('div');
function decodeHTMLEntities(str) {
if (str && typeof str === 'string') {
str = str.replace(/