var bookingWidgetController = function () { return { init: function () { this.prepare_dependencies(); }, is_mobile: function() { if(navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) { return true; } return false; }, prepare_dependencies: function () { $('head').append(''); var target_css = "https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/css/olee/booking_widget_olee.css?v=5.38"; $('head').append($('').attr('href', target_css)); var target_fawesome = "//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"; $('head').append($('').attr('href', target_fawesome)); $('head').append(''); $('head').append(''); $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_inj/lib/jquery-ui-1.10.1.custom.min.modified.js"); $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/js/mainWebSkeletonAux_injection.js").done(function(){ $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/lib/selectric/jquery.selectric.1.8.js").done(function () { bookingWidgetController.get_booking_widget_html(); }); }); }, get_booking_widget_html: function () { var language_widget = $("html").attr("lang").replace(/-.*/, ''); $.get("https://olee-calaceite-dot-amare-hotels.appspot.com/oleewidget/" + language_widget, function (e) { parent_wrapper_widget = $("
").html(e); }).done(function () { if ($("#booking_search_box_new_web").length) { $("#booking_search_box_new_web").html(parent_wrapper_widget); } else { if (!bookingWidgetController.is_mobile()) { if ($("body.home").length) { $("#booking_search_box").html(parent_wrapper_widget); } else { var booking_container_wrapper = $(''); booking_container_wrapper.html(parent_wrapper_widget); if ($(".hero-content").length) { $(".hero-content").append(booking_container_wrapper); $("#booking-mobile-desktop #b-booking").html("").append(parent_wrapper_widget); } else{ booking_container_wrapper.addClass('inner_without_slider'); booking_container_wrapper.insertAfter($("header#masthead")); } bookingWidgetController.prepare_stickie_engine(); } }else{ var booking_engine_mobile_wrapper = $("").attr('id', 'mobile_booking_engine_wrapper'); booking_engine_mobile_wrapper.html(parent_wrapper_widget); $("body").append(booking_engine_mobile_wrapper); $("#booking_search_box").html(""); } } $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/lib/jquery-i18n-1.1.1/jquery.i18n.js").done(function () { $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/i18n/messages_" + language_widget + ".js?v=1.2").done(function () { $.i18n.load(messages); if (bookingWidgetController.is_mobile()) { bookingWidgetController.prepare_mobile_version(); } if ($(".promocode_highlight").length) { $(".promocode_highlight").html($.i18n._("descuento_aplicado")); } $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/plugins/pricescalendar/calendar.plugin.js?v=1"); $(".start_end_date_wrapper").unbind( "click" ); $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/plugins/dates-selector/datepicker_v1.js?v=1.6").done(function () { $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/js/datepicker/jquery.ui.datepicker-" + language_widget + ".js?v=1").done(function () { _set_datepicker_regional($); DP_extend_info.config.booking_version = '7'; DP_extend_info.config.hotel_path_endpoint = 'https://olee-calaceite-dot-amare-hotels.appspot.com'; if (!bookingWidgetController.is_mobile()) { DP_extend_info.config.open_always_up = true; } var json_hotel_property = JSON.parse('[{"servingUrl": null, "title": "Periodo 1", "spanish_title": "Periodo 1", "description": "", "enabled": true, "priority": "", "linkUrl": "", "key": "ag5zfmFtYXJlLWhvdGVsc3IUCxIHUGljdHVyZRiAgIC2rNSPCQyiAQ5vbGVlLWNhbGFjZWl0ZQ", "altText": "Olee Holiday Rentals. Web Oficial", "allowInMobile": true, "onlyInMobile": false, "close": "2024-12-31", "pictureTitle": "Periodo 1", "open": "2025-01-01"}, {"servingUrl": null, "title": "Periodo Maximo", "spanish_title": "Periodo Maximo", "description": "", "enabled": true, "priority": "", "linkUrl": "", "key": "ag5zfmFtYXJlLWhvdGVsc3IUCxIHUGljdHVyZRiAgICO55OCCwyiAQ5vbGVlLWNhbGFjZWl0ZQ", "altText": "Olee Holiday Rentals. Web Oficial", "allowInMobile": true, "onlyInMobile": false, "pictureTitle": "Periodo Maximo", "last_close": "2026-01-26"}]'); DP_extend_info.config.period_closed = json_hotel_property; DP_extend_info.init(); olee_initialized_dp_extend_info = true; $.getScript("https://olee-calaceite-dot-amare-hotels.appspot.com/static_1/scripts/booking_7.js").done(function () { bookingWidgetController.prepare_booking_button(); $(".days_number_datepicker").html("1"); $(".room_selector").selectric({disableOnMobile: false}); $(".rooms_number").selectric({disableOnMobile: false}); }); }); }); }); }); if ($(".babies_selector").length) { $("#full_wrapper_booking").addClass("widget_with_babies"); } bookingWidgetController.adding_room_tag_selector(); bookingWidgetController.adding_adults_tag_selector(); bookingWidgetController.adding_kids_tag_selector(); bookingWidgetController.prepare_rooms_modifications(); bookingWidgetController.bind_click_buttons(); var has_promocode_at_url = getUrlParameter('promocode'); if (has_promocode_at_url) { $(".promocode_wrapper .promocode_input").val(has_promocode_at_url); $(".promocode_wrapper").append($("")); } }); }, prepare_mobile_version: function() { //Create button to open booking widget var mobile_booking_button = $("").attr('id', 'mobile_booking_button').html($.i18n._("reserva_ahora")), wrapper_booking_button = $("").attr('id', 'mobile_booking_wrapper'), close_booking_button = $("").attr('id', 'close_booking_widget').html("X"); wrapper_booking_button.append(mobile_booking_button); $("#mobile_booking_engine_wrapper").append(close_booking_button); $("body").append(wrapper_booking_button); $("#mobile_booking_wrapper").click(function(){ $("#mobile_booking_engine_wrapper").addClass('active'); $(this).addClass('hide'); }); $("#close_booking_widget").click(function(){ $("#mobile_booking_engine_wrapper").removeClass('active'); $("#mobile_booking_wrapper").removeClass('hide'); }); }, prepare_stickie_engine: function() { stickie_booking_container = $("#booking_search_box"); stickie_booking_offset = stickie_booking_container.offset(); last_scroll_top = 0; $(window).scroll(function(e){ var scroll_top = $(window).scrollTop(), scroll_direction = last_scroll_top < scroll_top ? 'down' : 'up'; if (stickie_booking_container && stickie_booking_offset) { var box_top = 'auto'; if (scroll_top > (stickie_booking_offset.top + 230)) { stickie_booking_container.addClass('fixed'); if ($('body').is('.admin-bar.logged-in')) { box_top = $('#wpadminbar').outerHeight(); } else { box_top = '0'; } if (scroll_direction == 'up'){ stickie_booking_container.addClass('header_deployed'); }else { stickie_booking_container.removeClass('header_deployed'); } } else { stickie_booking_container.removeClass('fixed'); } stickie_booking_container.css('top', box_top); } last_scroll_top = scroll_top; }); }, bind_click_buttons: function(){ $("a.btn-submit[href*='booking']").click(function(e){ e.preventDefault(); $(".start_end_date_wrapper").trigger('click'); }); jQuery(".hotel_selector_option").click(function(){ DP_extend_info.config.datepicker_sd_wrapper.datepicker('destroy'); DP_extend_info.config.datepicker_ed_wrapper.datepicker('destroy'); DP_extend_info.create_datepicker_containers(); var open_hotel_property = jQuery(this).attr('data-open-hotel'), external_open = jQuery(this).attr("data-open-external"), target_max_date = new Date("2050-12-31"); if(open_hotel_property) { var json_hotel_property = JSON.parse(open_hotel_property); DP_extend_info.config.period_closed = json_hotel_property; var target_min_date; for (var n=0;n