jQuery(document).ready(function ($) { /** * Contact Form Related Code */ $('.ts-c-form .nav .nav-item .nav-link').click(function () { var form = $(this).closest('.ts-c-form'); var totalSteps = form.find('.steps .tab-content .tab').length; }); //Button Next: Click to show the next tab $('.ts-c-form .btn-next').click(function () { var form = $(this).closest('.ts-c-form'); form.closest('.ts-c-form').find('.nav .nav-item .nav-link i').css('opacity', '1'); form.find('.steps .tab-content .tab').removeClass('active'); form.find('.steps .tab-content .tab').eq(1).addClass('active'); }); //Button Previous: Click to show the previous tab $('.ts-c-form .btn-prev').click(function () { var form = $(this).closest('.ts-c-form'); form.closest('.ts-c-form').find('.nav .nav-item .nav-link i').css('opacity', '0'); form.find('.steps .tab-content .tab').removeClass('active'); form.find('.steps .tab-content .tab').eq(0).addClass('active'); }); //Form Submit $('.ts-c-form').submit(function (e) { e.preventDefault(); var form = $(this); $.ajax({ data: form.serialize(), type: 'post', url: tsAjax.ajaxurl, success: function (data) { console.log(data); $('#form-message').text('Form has been submitted successfully!'); $('#form-message').addClass('text-secondary'); }, error: function (data) { $('#form-message').text('There is an error while submitting the form!'); $('#form-message').addClass('text-white'); } }); }); /** * Currency Switcher */ //Default Currency var userCurrency = 'gbp'; function get_currency_symbol(currency) { switch (currency) { case "GBP": case "gbp": return "£"; case "USD": case "usd": return "$"; case "EUR": case "eur": return "€"; default: return "$"; } } function get_exchange_rate(to, rates) { rate = 0; if (to == "gbp") { if (rates.gbp == "") { if (rates.usd != "") { rate = rates.usd * currency_rates.usd_to_gbp; } else if (rates.eur != "") { rate = rates.eur * currency_rates.eur_to_gbp; } } else { rate = rates.gbp; } } else if (to == "usd") { if (rates.usd == "") { console.log('? Yes USD IS EMPTY!'); if (rates.gbp != "") { rate = rates.gbp * currency_rates.gbp_to_usd; console.log('? GBP price is ', currency_rates.gbp_to_usd, '?? Converted Price is ', rate); $('.lang-subject-to-change').each(function() { $(this).text( $(this).attr('data-version-us') ); }); } else if (rates.eur != "") { rate = rates.eur * currency_rates.eur_to_usd; console.log('? Eur price is ', currency_rates.eur_to_usd, '?? Converted Price is ', rate); } } else { console.log('? No USD IS NOT EMPTY! ?? Converted Price is ', rate); rate = rates.usd; } } else if (to == "eur") { if (rates.eur == "") { if (rates.usd != "") { rate = rates.usd * currency_rates.usd_to_eur; } else if (rates.gbp != "") { rate = rates.gbp * currency_rates.gbp_to_eur; } } else { rate = rates.gbp; } } return Math.floor(rate); } function set_currenct_currency_widget_value(currency) { var currency_symbol = get_currency_symbol(currency); //Change the Price for each card based on the userCurrency $('.price').each(function () { var price = ""; var usdPrice = $(this).data('usd'); var gbpPrice = $(this).data('gbp'); var euroPrice = $(this).data('euro'); price = get_exchange_rate(currency, { usd: usdPrice, gbp: gbpPrice, eur: euroPrice }); if (price !== 0 && price % 10 != 0) { while (price % 10 != 0) { price++; } } price = currency_symbol + " " + price; $(this).html(price); }); //Change Phone Number $('.phone-number').each(function () { var phone = ""; switch (currency.toLowerCase()) { case 'gbp': $(this).html(phone_numbers.gbp); phone = phone_numbers.gbp; break; case 'usd': $(this).html(phone_numbers.usd); phone = phone_numbers.usd; break; default: $(this).html(phone_numbers.eur); phone = phone_numbers.eur; } if ($(this).is('a')) { $(this).attr('href', 'tel:' + phone); } }); //Change the text // $('a, button').each(function () { // var text = $(this).text(); // text = text.toLowerCase(); // if(text=="inquire" || text=="enquire"){ // switch (currency.toLowerCase()) { // case 'gbp': // text = "enquire"; // break; // default: // text = "inquire"; // } // } // $(this).text(text); // }); //Change the active currency from the currecny switcher widget $('.currency-switcher').each(function () { $(this).find('.currencies .currency').removeClass('active'); $(this).find('.currencies .currency').each(() => { let currentCurrency = $(this).data('currency'); console.log("?? CURRENT CURRENCY:", currency); if (currentCurrency == currency) { $(this).addClass('active'); } }) let active_currency = $(this).find('.current-currency').data('currency'); if (active_currency != currency) { $(this).find('.current-currency').data('currency', currency); $(this).find('.current-currency .currency').text(currency.toUpperCase() + " ") } }); } //If userCurrency is set, then change it... if (localStorage.getItem('ts_curreny')) { userCurrency = localStorage.getItem('ts_currency'); set_currenct_currency_widget_value(userCurrency); } else { localStorage.setItem('ts_currency', 'gbp'); $.get("https://api.ipdata.co/?api-key=f8f06fec59f41a1c97874cbadc8bc64b2241be4efcd6ec0d3bfc0ecd", function (response) { let country_code = response.country_code; if (country_code == "US") { userCurrency = "usd"; $('.lang-subject-to-change').each(function() { $(this).text( $(this).attr('data-version-us') ); }); } else if (country_code == "IE") { userCurrency = "eur"; $('.lang-subject-to-change').each(function() { $(this).text( $(this).attr('data-version-uk') ); }); } else { userCurrency = "gbp"; $('.lang-subject-to-change').each(function() { $(this).text( $(this).attr('data-version-uk') ); }); } set_currenct_currency_widget_value(userCurrency); }); } //When user changes currency via currency widget $('.currency-switcher .currencies .currency').click(function () { if (!$(this).hasClass('active')) { $('.currency-switcher').find('input').val(currency); var currency = $(this).data('currency'); //$(this).closest('.currencies').hide(); set_currenct_currency_widget_value(currency); } }); /** * Post Slider */ $(".ts-post-slider").owlCarousel({ margin: 15, nav: true, dots: true, rewind: true, responsive: { 0: { items: 1 }, 600: { items: 2 }, 1000: { items: 3 } }, navText: [ '', '' ] }); /** * Destination Slider */ $(".ts-gallery-slider").owlCarousel({ margin: 10, nav: true, dots: true, loop: true, rewind: false, autoplay: true, // Enables the autoplay feature autoplayTimeout: 5000, // Time each slide is displayed in milliseconds (5000ms = 5 seconds) touchDrag: true, // Ensure touch drag is enabled for touch devices mouseDrag: true, responsive: { 0: { items: 1.5 }, 600: { items: 2 }, 1000: { items: 1 } }, navText: [ '', '' ] }); /** * Image Slider */ $(".ts-owl-slider").owlCarousel({ margin: 10, rewind: true, responsive: { 0: { items: 2 }, 600: { items: 2 }, 1000: { items: 2 } }, navText: [ '', '' ] }); /** * TS Popup Filter */ $(".btn-ts-filter").click(function () { $(".ts_search_filter").show(); }); $(".ts_search_filter .btn-ts-times").click(function () { $(".ts_search_filter").hide(); }); /** * TS Trip Search Filter */ $(".btn-ts-trip-filter").click(function () { $(".ts_trip_search_filter").show(); }); $(".ts_trip_search_filter .btn-ts-times").click(function () { $(".ts_trip_search_filter").hide(); }); /** * Fixed Header */ $(window).scroll(function () { var sticky = $('.sticky'), scroll = $(window).scrollTop(); if (scroll >= 100) sticky.addClass('active'); else sticky.removeClass('active'); }); /** * TS Tabs Widget */ function scrollToActiveTab() { var activeTab = $('.tabs-list li.active'); if (activeTab.length) { var scrollContainer = activeTab.closest('.tabs-list'); var scrollLeft = scrollContainer.scrollLeft(); var tabLeft = activeTab.position().left; var tabRight = tabLeft + activeTab.outerWidth(); var containerLeft = scrollLeft; var containerRight = containerLeft + scrollContainer.width(); if (tabLeft < containerLeft || tabRight > containerRight) { // Adjust the scroll position slightly to show the full tab title scrollContainer.animate({ scrollLeft: tabLeft + scrollLeft - scrollContainer.outerWidth() / 2 + activeTab.outerWidth() / 2 + 10 // Adjust the "10" as needed }, 'fast'); } } } $(".ts-tab-widget .tabs .tabs-list li").click(function () { var tabContainer = $(this).closest('.ts-tab-widget'); tabContainer.find('.tabs .tabs-list li').removeClass('active'); $(this).addClass('active'); var tabID = $(this).data('tab'); tabContainer.find('.tabs-content .tab-content').removeClass('active'); tabContainer.find(`.tabs-content .tab-content[data-tab='${tabID}']`).addClass('active'); scrollToActiveTab(); // Scroll to the active tab }); $(".ts-tab-widget .tab-nav-controls .tab-prev").click(function () { var tabContainer = $(this).closest('.ts-tab-widget'); var activeTab = tabContainer.find('.tabs .tabs-list li.active'); var prevTab = activeTab.prev('li'); if (prevTab.length) { activeTab.removeClass('active'); prevTab.addClass('active'); var tabID = prevTab.data('tab'); tabContainer.find('.tabs-content .tab-content').removeClass('active'); tabContainer.find(`.tabs-content .tab-content[data-tab='${tabID}']`).addClass('active'); scrollToActiveTab(); // Scroll to the active tab } }); $(".ts-tab-widget .tab-nav-controls .tab-next").click(function () { var tabContainer = $(this).closest('.ts-tab-widget'); var activeTab = tabContainer.find('.tabs .tabs-list li.active'); var nextTab = activeTab.next('li'); if (nextTab.length) { activeTab.removeClass('active'); nextTab.addClass('active'); var tabID = nextTab.data('tab'); tabContainer.find('.tabs-content .tab-content').removeClass('active'); tabContainer.find(`.tabs-content .tab-content[data-tab='${tabID}']`).addClass('active'); scrollToActiveTab(); // Scroll to the active tab } }); /** * TS Popup Search Filter */ $(".ts-filter-list-items .item").click(function () { var icon = $(this).find('.icon').html(); var unCheckedIcon = ''; var checkedIcon = ''; var isChecked = $(this).data('checked'); var parentContainer = $(this).closest('.ts-filter-list-items'); if (isChecked === '0' || isChecked == 0) { parentContainer.find('.item').each(function(){ $(this).data('checked', '0'); $(this).removeClass('active'); $(this).find('.icon').html(unCheckedIcon); }); $(this).data('checked', '1'); $(this).addClass('active'); $(this).find('.icon').html(checkedIcon); } }); var allTrips = ""; //Filter Reset $('.btn-reset-filter').click(function () { var type = $(this).data('type'); var filterContainer = $(this).closest('aside'); filterContainer.find('.ts-filter-list-items .item').each(function () { var icon = $(this).find('.icon').html(); var unCheckedIcon = ''; var checkedIcon = ''; var isChecked = $(this).data('checked'); $(this).data('checked', '0'); $(this).removeClass('active'); $(this).find('.icon').html(unCheckedIcon); }); if(type != undefined && type == "trips"){ $('#trips .ts-posts-container .post').each(function(){ $(this).show(); }); } else{ if (allTrips == "") { //Do nothing } else { $('#search-result-container').html(allTrips); } } }); //Button to Apply Filter $('.btn-apply-filter').click(function () { var result = $('#search-result-container').html(); if (allTrips == "") { allTrips = result; } var filterContainer = $(this).closest('aside'); filterContainer.find('.ts-filter-list-items .item').each(function () { var isChecked = $(this).data('checked'); if (isChecked == "1") { var filterName = $(this).data('name'); switch (filterName) { case "trip_length_max": //Ascending Order result = $('#search-result-container .col-md-12').sort(function (a, b) { var contentA = parseInt($(a).data('days')); var contentB = parseInt($(b).data('days')); return (contentA > contentB) ? -1 : (contentA < contentB) ? 1 : 0; }); break; case "trip_length_min": //Descending Order result = $('#search-result-container .col-md-12').sort(function (a, b) { var contentA = parseInt($(a).data('days')); var contentB = parseInt($(b).data('days')); return (contentA < contentB) ? -1 : (contentA > contentB) ? 1 : 0; }); break; case "alphabetical": default: result = allTrips; } $('#search-result-container').html(result); return false; } }); }); /** * TS Veritical Tab Widget */ $(".ts-vertical-tabs .nav-items .nav-item .nav-link").click(function () { var mainContainer = $(this).closest(".ts-vertical-tabs"); mainContainer.find(".nav-items .nav-item .nav-link").removeClass("active"); $(this).addClass("active"); var tabID = $(this).data("tab"); mainContainer.find(".tab-content-container .tab-content").removeClass("active"); mainContainer.find(".tab-content-container .tab-content[data-container='" + tabID + "']").addClass("active"); }); /** * TS Image Slider with Title and Sub Title */ $(".ts-img-slider .nav-controls .btn-prev").click(function () { if (!$(this).hasClass("btn-disabled")) { var sliderContainer = $(this).closest(".ts-img-slider"); var slidesCount = sliderContainer.find(".slide").length; var activeSlide = sliderContainer.find(".slide.active").index(); console.log("ACTIVE TAB:", activeSlide, slidesCount); if (activeSlide <= 0) { $(this).addClass("btn-disabled"); } else { if (activeSlide === slidesCount - 1) { console.log("WELL DONE!"); sliderContainer.find(".nav-controls .btn-next").removeClass("btn-disabled"); } else if (activeSlide - 1 == 0) { $(this).addClass("btn-disabled"); } sliderContainer.find(".slide.active").removeClass("active"); sliderContainer.find(".slide").eq(activeSlide - 1).addClass('active'); } } }); $(".ts-img-slider .nav-controls .btn-next").click(function () { if (!$(this).hasClass('btn-disabled')) { var sliderContainer = $(this).closest(".ts-img-slider"); var slidesCount = sliderContainer.find(".slide").length; var activeSlide = sliderContainer.find(".slide.active").index(); if (activeSlide >= slidesCount - 1) { $(this).addClass('btn-disabled'); } else { if (activeSlide == slidesCount - 2) { $(this).addClass('btn-disabled'); } sliderContainer.find(".btn-prev").removeClass("btn-disabled"); sliderContainer.find(".slide.active").removeClass("active"); sliderContainer.find(".slide").eq(activeSlide + 1).addClass('active'); } } }); /** * LGBT Region Information API Equaldex */ // const EQUALDEX_API_KEY="81c576798cfb61934405cb4f530a689c752ef668"; // var equal_dex_div = $("#lgbt-info"); // if(equal_dex_div.length && equal_dex_div.length>0){ // let country_code = equal_dex_div.data("country"); // let url = "https://www.equaldex.com/api/region?apiKey="+EQUALDEX_API_KEY+"®ionid="+country_code+"&formatted=true"; // $.get(url, function(response){ // console.log(response); // let html = `
//
//
//
Homosexual activity
//

Illegal

//
//
//
Same-sex marriage
//

Illegal

//
//
//
Equal age of consent
//

Illegal

//
//
//
//
//
LGBT descrimination
//

Illegal

//
//
//
Same-sex adoption
//

Illegal

//
//
//
//
// Learn More // //
//
//
`; // equal_dex_div.html(html); // }) // } /** * Show All Trips */ $('.ts-btn-show-all').click(function (e) { e.preventDefault(); console.log("Hi, let me show all the trips...???????"); var container = $(this).closest('.trips').find('.ts-posts-container'); // $.ajax({ // data: form.serialize(), // type: 'post', // url: tsAjax.ajaxurl, // success: function(data) { // console.log(data); // if(data.trips.length>0){ // data.trips.forEach(function(trip){ // var existing_trip = $("#trip-"+trip.ID); // if(existing_trip.length<=0){ // var html = ` //
//
// ... //
//
${trip.title}
//

${trip.type}

//

${trip.content}

//
// //
//
// `; // container.append(html); // } // }); // } else { // let html = ` //
//

No trips found!

//
// `; // container.append(html); // } // self.find('.ts-btn-show-all').hide(); // }, // error: function(data){ // console.log(data); // var html = ` //
//

Error while loading the trips!

//
// `; // container.append(html); // } // }); container.find('.post').each(function () { $(this).css('display', 'block'); }); $(this).hide(); }); /** * Show All Hotels */ $('.ts-btn-show-all-hotels').click(function (e) { e.preventDefault(); var container = $(this).closest('.luxury-hotels').find('.hotels-container'); container.find('.hotel').each(function () { $(this).css('display', 'block'); }); // $.ajax({ // data: form.serialize(), // type: 'post', // url: tsAjax.ajaxurl, // success: function(data){ // console.log(data); // data.hotels.forEach(function(item){ // var html = ` //
// // //
//
//
//
    //
  • // //
  • //
  • // //
  • //
  • // //
  • //
  • // //
  • //
  • // //
  • //
//
//
//

${item.title}

//
//
//
//
// `; // container.append(html); // }); // self.find('.ts-btn-show-all-hotels').hide(); // }, // error: function(data){ // var html = ` //
//

Error while loading the trips!

//
// `; // container.append(html); // } // }); $(this).hide(); }); jQuery(document).ready(function ($) { function showMenu(menu) { // Hide all other dropdowns except the one being shown $('.dd-menu').not(menu).hide(); // Show the hovered menu menu.show(); } // Destinations Menu $('.nav-item.destinations').off('mouseenter').on('mouseenter', function (event) { event.stopPropagation(); $('#destinations-mm-wrapper').show(); // Show Destinations menu }); // Inspiration Menu $('.nav-link.inspiration').off('mouseenter').on('mouseenter', function (event) { event.stopPropagation(); $('#destinations-mm-wrapper').hide(); // Hide Destinations menu $(this).next('.dd-menu').show(); // Show Inspiration menu }); // Honeymoons Menu $('.nav-link.honeymoons').off('mouseenter').on('mouseenter', function (event) { event.stopPropagation(); $('#destinations-mm-wrapper').hide(); // Hide Destinations menu $(this).next('.dd-menu').show(); // Show Honeymoons menu }); // Close menus when clicking outside $(document).off('click').on('click', function (event) { if (!$(event.target).closest('.nav-item').length && !$(event.target).closest('.dd-menu').length) { $('.dd-menu').hide(); // Hide all menus } }); }); /* Mobile Menu Openner */ jQuery('.menu-openner a').click(function () { jQuery('#mobile-dropdown-menu').toggle(); jQuery('.ts-header').toggleClass('is-expanded'); }); jQuery('.mobile-menu-list .dropdown-parents .nav-link').click(function () { jQuery(this).parent().children(".dropdown-wrapper").toggle(); jQuery(this).parent().toggleClass("rotate-180"); }); jQuery('.mobile-menu-list .destinations .continents').click(function () { jQuery(this).parent().children('.cities').toggle(); jQuery(this).toggleClass("rotate-180"); }); // Close mobile menu when clicking outside jQuery(document).click(function (event) { if (!jQuery(event.target).closest('#mobile-dropdown-menu').length && !jQuery(event.target).closest('.menu-openner').length) { // If the clicked element is not inside #mobile-dropdown-menu or .menu-openner, close the menu jQuery('#mobile-dropdown-menu').hide(); jQuery('.ts-header').removeClass('is-expanded'); } // Add similar checks for other dropdowns if needed }); // Enquiry Form jQuery('.crmWebToEntityForm #btn-next').click(function (e) { e.preventDefault(); jQuery('.crmWebToEntityForm .first-tab').css('display', 'none'); jQuery('.xp-tab-head1').css('color', 'rgba(255, 255, 255, 0.3490196078)'); jQuery('.xp-tab-head2').css('color', 'rgba(255, 255, 255)'); jQuery('.xp-tab-head1 .fa.fa-check').css('opacity', '1'); jQuery('.crmWebToEntityForm .second-tab').css('display', 'block'); }); jQuery('.crmWebToEntityForm .xp-tab-head2').click(function (e) { e.preventDefault(); jQuery('.crmWebToEntityForm .first-tab').css('display', 'none'); jQuery('.xp-tab-head1').css('color', 'rgba(255, 255, 255, 0.3490196078)'); jQuery('.xp-tab-head2').css('color', 'rgba(255, 255, 255)'); jQuery('.xp-tab-head1 .fa.fa-check').css('opacity', '1'); jQuery('.crmWebToEntityForm .second-tab').css('display', 'block'); }); jQuery('.crmWebToEntityForm #btn-back').click(function (e) { e.preventDefault(); jQuery('.crmWebToEntityForm .first-tab').css('display', 'block'); jQuery('.xp-tab-head1 .fa.fa-check').css('opacity', '0'); jQuery('.xp-tab-head1').css('color', 'rgba(255, 255, 255)'); jQuery('.xp-tab-head2').css('color', 'rgba(255, 255, 255, 0.3490196078)'); jQuery('.crmWebToEntityForm .second-tab').css('display', 'none'); }); jQuery('.crmWebToEntityForm .xp-tab-head1').click(function (e) { e.preventDefault(); jQuery('.crmWebToEntityForm .first-tab').css('display', 'block'); jQuery('.xp-tab-head1 .fa.fa-check').css('opacity', '0'); jQuery('.xp-tab-head1').css('color', 'rgba(255, 255, 255)'); jQuery('.xp-tab-head2').css('color', 'rgba(255, 255, 255, 0.3490196078)'); jQuery('.crmWebToEntityForm .second-tab').css('display', 'none'); }); jQuery('.crmWebToEntityForm .slider').on('input', function () { // console.log(`[data-value='${currentValue}']`); var currentValue = this.value; var target = jQuery(".budget_range_slider_prices").find(`[data-value='${currentValue}']`); jQuery(".budget_range_slider_prices li").css('color', 'white'); target.css('color', '#C1916D'); // console.log(target[0].attributes['data-passed-value'].value); }); $('#filter-trips-btn').click(function(){ var holiday_type = ''; var departure = ''; var experience = ''; var suitable_for = ''; $('#holiday-type .item').each(function(){ if($(this).data('checked') == 1){ holiday_type = $(this).data('label'); console.log(`?? Holiday Type ${holiday_type}`); } }); $('#departure .item').each(function(){ if($(this).data('checked') == 1){ departure = $(this).data('label'); console.log(`?? Departure ${departure}`); } }); $('#experiences .item').each(function(){ if($(this).data('checked') == 1){ experience = $(this).data('label'); console.log(`?? Experience ${experience}`); } }); $('#suitable-for .item').each(function(){ if($(this).data('checked') == 1){ suitable_for = $(this).data('label'); console.log(`?? Suitable for ${suitable_for}`); } }); $('#trips .ts-posts-container .post').each(function(){ var flag = true; if(holiday_type != '' && holidayType !='all'){ //Holiday Type var holidayType = $(this).find('input[name="holiday_type"]').val(); if(holidayType !== holiday_type){ flag = false; } } if(departure != '' && flag == true){ console.log(`?? Departure Code Block!`); //Departure Dates var departureDates = $(this).find('input[name="departure[]"]').map(function(){ return this.value; }).get(); flag = departureDates.find(function(item){ if(item == departure){ console.log(`?? Departure Date = ${item}`); return true; } return false; }); if(flag == undefined){ flag = false; } } if(experience != '' && flag == true){ console.log(`?? Experience Code Block!`); //Experiences var experiences = $(this).find('input[name="experience[]"]').map(function(){ return this.value; }).get(); flag = experiences.find(function(item){ if(item == experience){ return true; } return false; }); if(flag == undefined){ flag = false; } } if(suitable_for != '' && flag == true){ console.log(`?? Suitable for Code Block!`); //Suitable For var suitable_for_data = $(this).find('input[name="suitable_for[]"]').map(function(){ return this.value; }).get(); flag = suitable_for_data.find(function(item){ if(item == suitable_for){ return true; } return false; }); if(flag == undefined){ flag = false; } } console.log(`FLAG VALUE = ${flag}`); if(!flag){ $(this).hide(); } else{ $(this).show(); } }); $(".ts_trip_search_filter").hide(); }); });