(function ($) { "use strict"; let Header = { $body: $("body"), isValidated: {}, init: function () { let base = this; base._mobile_menu(base.$body); base._login_signup(base.$body); base._toglesidebar(); base._moreSidebar(); base._mobileLocation(); base._toolTip(); base._toggleSection(base.$body); base._reviewListSingle(base.$body); base._matchHeight(base.$body); base._likeReview(); base._languageCurrency(); }, _languageCurrency: function () { $(".select2-languages").on("change", function () { var target = $("option:selected", this).data("target"); if (target) { window.location.href = target; } }); $(".select2-currencies").on("change", function () { var target = $("option:selected", this).data("target"); if (target) { window.location.href = target; } }); }, _likeReview: function () { $(".st-like-review").on("click", function (e) { e.preventDefault(); var me = $(this); var comment_id = me.data("id"); $.ajax({ url: st_params.ajax_url, type: "post", dataType: "json", data: { action: "like_review", comment_ID: comment_id }, success: function (res) { if (res.status) { $("i", me).toggleClass("fa-thumbs-up fa-thumbs-down"); if ($(".booking-item-review-rate").length) { $(me).toggleClass("fa-thumbs-up fa-thumbs-down"); } if (typeof res.data.like_count != undefined) { res.data.like_count = parseInt(res.data.like_count); me.parent().find("span").html(res.data.like_count); } } }, }); }); }, _reviewListSingle: function (body) { $(".review-list", body).on("click", ".show-more", function (ev) { ev.preventDefault(); var parent = $(this).closest(".comment"); $(this).css("display", "none"); $(".review", parent).slideDown(200); $(".show-less", parent).css("display", "block"); }); $(".review-list", body).on("click", ".show-less", function (ev) { ev.preventDefault(); var parent = $(this).closest(".comment"); $(this).css("display", "none"); $(".review", parent).slideUp(200); $(".show-more", parent).css("display", "block"); }); }, _toggleSection: function (body) { body.on("click", ".toggle-section", function (ev) { ev.preventDefault(); var t = $(this); var target = t.data("target"); if ($(".fas", t).length) { $(".fas", t).toggleClass("fa-angle-up fa-angle-down"); } else { $("i", t).toggleClass("stt-icon-arrow-up stt-icon-arrow-down"); } $('[data-toggle-section="' + target + '"]').slideToggle(200); $(".has-matchHeight", body).matchHeight(); }); }, _matchHeight: function (body) { if ($(".has-matchHeight", body).length) { $(".has-matchHeight", body).matchHeight(); } }, _mobileLocation: function () { $(".search-form-mobile .dropdown-menu li").on("click", function () { var t = $(this); var parent = t.closest(".search-form-mobile"); $('input[name="location_id"]', parent).val(t.data("value")); $('input[name="location_name"]', parent).val(t.find("span").text()); }); }, _toolTip: function () { var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')); var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl); }); }, _moreSidebar: function () { if ($(".btn-more-item").length) { $(".btn-more-item").each(function () { var t = $(this); var parent = t.closest(".item-content"); if (parent.find("ul li").length > 3) { t.show(); } t.on("click", function () { var countLi = parent.find("ul li.hidden").length; var max = 3; if (countLi < 3) { max = countLi; } for (var i = 0; i < max; i++) { parent.find("ul li.hidden").eq(0).removeClass("hidden"); } var countLi = parent.find("ul li.hidden").length; if (countLi <= 0) { t.hide(); } }); }); } }, _toglesidebar: function (body) { if ($(".sidebar-item").length) { $(".sidebar-item").each(function () { var t = $(this); if (t.hasClass("open")) { t.find(".item-content").slideUp(); } }); } $(".sidebar-item .item-title").on("click", function () { var t = $(this); if(!t.hasClass('toggle-none')){ t.parent().toggleClass("open"); t.parent().find(".item-content").slideToggle(); } }); }, _login_signup: function (body) { $("#st-login-form form, #st-login-form-page form", body).on("submit", function (ev) { ev.preventDefault(); var form = $(this), loader = form.closest(".modal-content").find(".loader-wrapper"), message = $(".message-wrapper", form); var data = form.serializeArray(); data.push({ name: "security", value: st_params._s }); message.html(""); loader.show(); $.post( st_params.ajax_url, data, function (respon) { if (typeof respon == "object") { message.html(respon.message); setTimeout(function () { message.html(""); }, 4000); if (respon.status == 1) { setTimeout(function () { $(".st-sign-up").removeClass("active"); $(".st-sign-in").addClass("active"); $(".register-component").removeClass("active"); $(".login-component").addClass("active"); if (typeof respon.redirect !== "undefined") { window.location.href = respon.redirect; } }, 4000); } } loader.hide(); }, "json" ); }); $("#st-register-form form", body).on("submit", function (ev) { ev.preventDefault(); var form = $(this), loader = form.closest(".modal-content").find(".loader-wrapper"), message = $(".message-wrapper", form); var data = form.serializeArray(); data.push({ name: "security", value: st_params._s }); message.html(""); loader.show(); $.post( st_params.ajax_url, data, function (respon) { loader.hide(); if (typeof respon == "object") { message.html(respon.message); if (respon.status == 1) { swal({ type: "success", title: respon.message, text: respon.sub_message, showConfirmButton: true, confirmButtonText: "close", onClose: function () { $("#st-login-form", body).modal("show"); $("#st-register-form", body).modal("hide"); }, allowOutsideClick: false, }); } else { message.html(respon.message); setTimeout(function () { message.html(""); }, 4000); } } }, "json" ); }); $("#st-forgot-form form, #st-forgot-form-page form", body).on("submit", function (ev) { ev.preventDefault(); var form = $(this), loader = form.closest(".modal-content").find(".loader-wrapper"), message = $(".message-wrapper", form); var data = form.serializeArray(); data.push({ name: "security", value: st_params._s }); message.html(""); loader.show(); $.post( st_params.ajax_url, data, function (respon) { if (typeof respon == "object") { message.html(respon.message); setTimeout(function () { message.html(""); }, 2000); } loader.hide(); }, "json" ); }); }, _mobile_menu: function (body) { var body = $("body"); $(".toggle-menu").on("click", function (ev) { ev.preventDefault(); toggleBody($("#st-main-menu")); $("#st-main-menu").toggleClass("open"); }); $(".back-menu").on("click", function (ev) { ev.preventDefault(); toggleBody($("#st-main-menu")); $("#st-main-menu").toggleClass("open"); }); function toggleBody(el) { if (el.hasClass("open")) { body.css({ overflow: "" }); } else { body.css({ overflow: "hidden" }); } } $("#st-main-menu .main-menu .menu-item-has-children .fa").on("click", function () { if (window.matchMedia("(max-width: 768px)").matches) { $(this).toggleClass("fa-angle-down fa-angle-up"); var parent = $(this).closest(".menu-item-has-children"); $(">.menu-dropdown", parent).toggle(); } }); body.on("click", function (ev) { if ($(ev.target).is("#st-main-menu")) { toggleBody($(ev.target)); $("#st-main-menu").toggleClass("open"); } }); }, }; Header.init(); let ST_Elementor = { $body: $("body"), isValidated: {}, init: function () { let base = this; base._selectTabServiceList(); base._addWishlist(); }, _addWishlist: function () { $(document).on("click", ".service-add-wishlist.login", function (event) { event.preventDefault(); var t = $(this); t.addClass("loading"); $.ajax({ url: st_params.ajax_url, type: "POST", data: { action: "st_add_wishlist", data_id: t.data("id"), data_type: t.data("type") }, dataType: "json" }).done(function (html) { if (html.status == "true") { if (html.added == "true") { t.addClass("added"); } else { t.removeClass("added"); } t.attr("title", html.title); } t.removeClass("loading"); }); }); }, _selectTabServiceList: function () { $(".st-list-service").each(function () { var t = $(this); var dataTabShowVal = $(".st-list-dropdown .header", t).data("value"); $(".multi-service-wrapper .tab-content." + dataTabShowVal, t).show(); }); $(".st-list-dropdown").each(function () { var t = $(this); var parent = t.closest(".st-list-service"); var currentTabList = t.find(".header").data("value"); $(".list", t) .find('li[data-value="' + currentTabList + '"]') .hide(); $(".header", t).on("click", function () { $(".list", t).toggle(); }); $(".list li", t).on("click", function () { var me = $(this); $(".list li", t).removeClass("active"); me.addClass("active"); var dataS = me.data("value"); var dataArg = me.data("arg"); var datastyleitem = me.data("styleitem"); var dataSName = me.text(); $(".header span", t).text(dataSName); $(".header", t).attr("data-value", dataS); me.parent().hide(); $.ajax({ url: st_params.ajax_url, type: "GET", data: { action: "st_list_of_service_" + dataS, dataArg: dataArg, datastyleitem: datastyleitem }, dataType: "json", beforeSend: function () { parent.find(".map-content-loading").css("z-index", 99); parent.find(".map-content-loading").show(); }, error: function (jqXHR, textStatus, errorThrown) {}, success: function (res) { parent.find(".map-content-loading").hide(); }, complete: function (xhr, status) { if (xhr.responseJSON) { parent.find(".multi-service-wrapper").html(xhr.responseJSON.html).hide().fadeIn(1500); $(".multi-service-wrapper .tab-content", parent).hide(); $(".multi-service-wrapper .tab-content." + dataS, parent).show(); setTimeout(function () { $(".multi-service-wrapper .tab-content .has-matchHeight", parent).matchHeight({ remove: true }); $(".multi-service-wrapper .tab-content .has-matchHeight", parent).matchHeight(); }, 1000); $(".list li", t).show(); $(".list", t) .find('li[data-value="' + dataS + '"]') .hide(); } $(".st-service-slider").each(function () { $(this).owlCarousel({ loop: false, items: 4, margin: 20, responsiveClass: true, dots: false, responsive: { 0: { items: 1, nav: false, margin: 15, dots: true }, 576: { items: 2, nav: false, margin: 15, dots: true }, 992: { items: 3, nav: true }, 1200: { items: 4, nav: true } }, }); }); }, }); }); $(document).on("mouseup", function (e) { var container = t; if (!container.is(e.target) && container.has(e.target).length === 0) { container.find(".list").hide(); } }); }); }, _resize: function (body) { var timeout_fixed_item; $(window) .on("resize", function () { clearTimeout(timeout_fixed_item); timeout_fixed_item = setTimeout(function () { $(".st-hotel-content", "body").each(function () { var t = $(this); $(window).on("scroll", function () { if ($(window).scrollTop() >= 50 && window.matchMedia("(max-width: 991px)").matches) { t.css("display", "flex"); } else { t.css("display", "none"); } }); }); }, 1000); }) .trigger("resize"); if (window.matchMedia("(min-width: 992px)").matches) { $(".st-gallery", body).each(function () { var parent = $(this); var $fotoramaDiv = $(".fotorama", parent).fotorama({ width: parent.data("width"), nav: parent.data("nav"), thumbwidth: "135", thumbheight: "135", allowfullscreen: parent.data("allowfullscreen") }); parent.data("fotorama", $fotoramaDiv.data("fotorama")); }); } else { $(".st-gallery", body).each(function () { var parent = $(this); if (typeof parent.data("fotorama") !== "undefined") { parent.data("fotorama").destroy(); } var $fotoramaDiv = $(".fotorama", parent).fotorama({ width: parent.data("width"), nav: parent.data("nav"), thumbwidth: "80", thumbheight: "80", allowfullscreen: parent.data("allowfullscreen") }); parent.data("fotorama", $fotoramaDiv.data("fotorama")); }); } if (window.matchMedia("(min-width: 992px)").matches) { $(".full-map").show(); } else { $(".full-map").hide(); } if (window.matchMedia("(max-width: 991px)").matches) { $(".as").slideDown(); } }, }; ST_Elementor.init(); if ($(".payment-form .payment-item").length) { $(".payment-form .payment-item").eq(0).find('.st-icheck-item input[type="radio"]').prop("checked", true); $(".payment-form .payment-item").eq(0).find(".dropdown-menu").slideDown(); } $(".payment-form .payment-item").each(function (l, i) { var parent = $(this); $('.st-icheck-item input[type="radio"]', parent).on("change", function () { $(".payment-form .payment-item .dropdown-menu").slideUp(); if ($(this).is(":checked")) { if ($(".dropdown-menu", parent).length) { $(".dropdown-menu", parent).slideDown(); } } }); }); })(jQuery); function stKeyupsmartSearch(event) { var input, filter, ul, li, a, i, txtValue; input = event.value.toUpperCase(); filter = event.value.toUpperCase(); parent = event.closest(".destination-search"); ul = parent.getElementsByTagName("ul")[0]; li = ul.getElementsByTagName("li"); for (i = 0; i < li.length; i++) { txtValue = li[i].textContent || li[i].innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { li[i].style.display = ""; } else { li[i].style.display = "none"; } } } jQuery(function ($) { var startApp = function () { var key = st_social_params.google_client_id; gapi.load("auth2", function () { auth2 = gapi.auth2.init({ client_id: key, cookiepolicy: "single_host_origin" }); attachSignin(document.getElementById("st-google-signin2")); attachSignin(document.getElementById("st-google-signin3")); }); }; if (typeof window.gapi != "undefined") { startApp(); } function attachSignin(element) { auth2.attachClickHandler( element, {}, function (googleUser) { var profile = googleUser.getBasicProfile(); startLoginWithGoogle(profile); }, function (error) { console.log(JSON.stringify(error, undefined, 2)); } ); } function startLoginWithGoogle(profile) { if (typeof window.gapi.auth2 == "undefined") return; sendLoginData({ channel: "google", userid: profile.getId(), username: profile.getName(), useremail: profile.getEmail() }); } function startLoginWithFacebook(btn) { btn.addClass("loading"); FB.getLoginStatus(function (response) { if (response.status === "connected") { sendLoginData({ channel: "facebook", access_token: response.authResponse.accessToken }); } else { FB.login( function (response) { if (response.authResponse) { sendLoginData({ channel: "facebook", access_token: response.authResponse.accessToken }); } else { alert("User cancelled login or did not fully authorize."); } }, { scope: "email", return_scopes: true } ); } }); } function sendLoginData(data) { data._s = st_params._s; data.action = "traveler.socialLogin"; var parent_login = $(".login-regiter-popup"); $.ajax({ data: data, type: "post", dataType: "json", url: st_params.ajax_url, beforeSend: function () { parent_login.find(".map-loading").html('
'); parent_login.find(".map-loading").css("z-index", 99); parent_login.find(".map-loading").show(); }, success: function (rs) { handleSocialLoginResult(rs); }, error: function (e) { alert("Can not login. Please try again later"); }, }); } function handleSocialLoginResult(rs) { if (rs.reload && typeof rs.reload !== "undefined") window.location.reload(); if (rs.message) alert(rs.message); } $(".st_login_social_link").on("click", function () { var channel = $(this).data("channel"); switch (channel) { case "facebook": startLoginWithFacebook($(this)); break; } }); function popupwindow(url, title, w, h) { var left = screen.width / 2 - w / 2; var top = screen.height / 2 - h / 2; return window.open(url, title, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=" + w + ", height=" + h + ", top=" + top + ", left=" + left); } $(".st_login_social_link").on("click", function () { var href = $(this).attr("href"); if ($(this).hasClass("btn_login_tw_link")) popupwindow(href, "", 600, 450); return false; }); $(".toolbar-action-mobile .btn-from-to").on("click", function (e) { e.preventDefault(); window.scrollTo({ top: "46" }); $(".sidebar-filter").fadeIn(); $(".top-filter").fadeIn(); $(".sidebar-filter .sidebar-search-form").show(); $(".sidebar-filter .sidebar-item-wrapper").hide(); $(".sidebar-filter .form-date-search").hide(); $("html, body").css({ overflow: "hidden" }); }); $(".toolbar-action-mobile .btn-filter").on("click", function (e) { e.preventDefault(); window.scrollTo({ top: "46" }); $(".sidebar-filter").fadeIn(); $(".top-filter").fadeIn(); $(".sidebar-filter .sidebar-item-wrapper").fadeIn(); $(".sidebar-filter .sidebar-search-form").hide(); $("html, body").css({ overflow: "hidden" }); }); $(".toolbar .btn-sort").on("click", function (e) { e.preventDefault(); $(".sort-menu-mobile").fadeIn(); }); $(".toolbar .btn-map").on("click", function (e) { e.preventDefault(); window.scrollTo({ top: "46" }); $(".page-half-map .col-right").show(); $(".full-map .full-map-item").show(); $("html, body").css({ overflow: "hidden" }); }); $(".sidebar-filter .close-filter").on("click", function () { $(this) .closest(".sidebar-filter") .fadeOut(function () { $("html, body").css({ overflow: "auto" }); }); }); $(".top-filter .close-filter").on("click", function () { $(this) .closest(".top-filter") .fadeOut(function () { $("html, body").css({ overflow: "auto" }); }); }); $(".sort-menu-mobile .close-filter").on("click", function () { $(this).closest(".sort-menu-mobile").fadeOut(); }); $(".page-half-map .close-half-map").on("click", function () { $(this).closest(".col-right").hide(); $("html, body").css({ overflow: "auto" }); if ($("#btn-show-map-mobile").length) { $("#btn-show-map-mobile").prop("checked", false); } }); $(".full-map .close-map").on("click", function () { $(this).closest(".full-map").hide(); $("html, body").css({ overflow: "auto" }); }); $(window).on("resize", function () { if (window.matchMedia("(min-width: 768px)").matches) { if ($(".full-map-item").length) { if (!$(".full-map-item").is(":visible")) { $(".full-map-item").attr("style", ""); } } if ($(".st-hotel-result .sidebar-filter").length) { if (!$(".st-hotel-result .sidebar-filter").is(":visible")) { $(".st-hotel-result .sidebar-filter").attr("style", ""); } } if ($(".st-hotel-result .top-filter").length) { if (!$(".st-hotel-result .top-filter").is(":visible")) { $(".st-hotel-result .top-filter").attr("style", ""); } } } if (window.matchMedia("(min-width: 992px)").matches) { if ($(".page-half-map .col-right").length) { if (!$(".page-half-map .col-right").is(":visible") && $("#btn-show-map").is(":checked")) { $(".page-half-map .col-right").attr("style", ""); } } } if (window.matchMedia("(max-width: 991px)").matches) { if ($(".page-half-map .col-right").length) { if ($(".page-half-map .col-right").is(":visible")) { $(".page-half-map .col-right").attr("style", ""); } } if ($(".page-half-map .col-left").length) { if ($(".page-half-map .col-left").is(":visible")) { $.fn.getNiceScroll && $(".page-half-map .col-left").getNiceScroll().remove(); } } } }); }); var markerGolbal; var mapGobal; function getMapDistance(map) { var bounds = map.getBounds(); var center = bounds.getCenter(); var ne = bounds.getNorthEast(); var r = 3963.0; var lat1 = center.lat() / 57.2958; var lon1 = center.lng() / 57.2958; var lat2 = ne.lat() / 57.2958; var lon2 = ne.lng() / 57.2958; var dis = r * Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)); return dis; } function initHalfMap(mapEl, mapData, mapLat, mapLng, mapZoom, mapIcon, mapVersion, isMapMove) { var popupPos = mapEl.data("popup-position"); if (mapData.length <= 0) mapData = mapEl.data("data_show"); if (mapLat.length <= 0) mapLat = mapEl.data("lat"); if (mapLng.length <= 0) mapLng = mapEl.data("lng"); if (mapZoom.length <= 0) mapZoom = typeof mapEl.data("zoom") !== "undefined" ? mapEl.data("zoom") : 13; if (mapIcon.length <= 0) mapIcon = mapEl.data("icon"); if (typeof isMapMove === "undefined") isMapMove = false; if (!isMapMove) { mapGobal = new google.maps.Map(mapEl.get(0), { zoom: mapZoom, center: { lat: parseFloat(mapLat), lng: parseFloat(mapLng) }, disableDefaultUI: true }); } if (!isMapMove) { bounds = new google.maps.LatLngBounds(); } if (isMapMove) { if (markerGolbal.length) { for (var i = 0; i < markerGolbal.length; i++) { markerGolbal[i].setMap(null); } } } if (typeof mapData != "undefined" && Object.keys(mapData).length) { var marker = []; var ib = []; var c = {}; markerGolbal = jQuery.map(mapData, function (location, i) { if (mapVersion === "elementorv2") { marker[i] = new MarkerWithLabel({ icon: " ", position: new google.maps.LatLng(parseFloat(location.lat), parseFloat(location.lng)), draggable: false, raiseOnDrag: false, map: mapGobal, labelContent: '