1// Add booking integrations in the selected elements 2function micoreLoadIntegrationContent() { 3 const $tempContainer = jQuery('#micore_temporal_loyalty_content'); 4 5 // Check temporal content in the DOM 6 if (!$tempContainer.length) return; 7 8 // Get temporal content 9 const $contentToMove = $tempContainer.find('div + div').first(); 10 11 if (!$contentToMove.length) return; 12 13 // Insert method types 14 const placementConfig = [ 15 { selector: '.micore-into-loyalty-target', method: 'append' }, 16 { selector: '.micore-before-loyalty-target', method: 'before' }, 17 { selector: '.micore-after-loyalty-target', method: 'after' } 18 ]; 19 20 placementConfig.forEach(({ selector, method }) => { 21 const $configEl = jQuery(selector); 22 23 const targetSelector = $configEl.text().trim(); 24 25 if (targetSelector) { 26 const $target = jQuery(targetSelector); 27 28 if ($target.length) { 29 // Clone original content 30 $target[method]($contentToMove.clone()); 31 } 32 } 33 }); 34 35 $tempContainer.remove(); 36} 37 38// Update finder integrations language 39function micoreUpdateForwarderUrlLanguage(forwarderURL) { 40 // Check if URL has lang parameter 41 if (/[?&]lang=/.test(forwarderURL)) return forwarderURL; 42 43 // Get current lang 44 const currentLang = (document.documentElement.lang || 'en').trim().split('-')[0]; 45 const separator = forwarderURL.includes('?') ? '&' : '?'; 46 47 // Return URL width current lang parameter 48 return forwarderURL.replace('#url=true', `${separator}lang=${currentLang}#url=true`); 49} 50 51// Overwrite old booking urls 52function micoreOverwriteCoreUrls() { 53 // Cache the configuration element 54 const $overwriteBookingDiv = jQuery('#micore_overwrite_booking_url'); 55 56 // Exit if the element doesn't exist to prevent errors 57 if (!$overwriteBookingDiv.length) return; 58 59 // Extract the redirect URL 60 const forwarderUrl = micoreUpdateForwarderUrlLanguage($overwriteBookingDiv.data('url')); 61 62 // Parse targets: Split by comma, trim whitespace, and filter out empty strings 63 const targets = ($overwriteBookingDiv.data('target') || '') 64 .split(',') 65 .map(t => t.trim()) 66 .filter(Boolean); 67 68 // Iterate over each target definition 69 targets.forEach(target => { 70 // Attempt to select the element directly by ID or Class 71 const $targetElement = jQuery(target); 72 73 // Target is a valid DOM selector 74 if ($targetElement.length) { 75 // Remove previous click handlers and assign a new click handler that forces the redirection. 76 $targetElement 77 .off('click') // Remove existing click events to prevent conflicts 78 .on('click', function (e) { 79 e.preventDefault(); 80 window.location.href = forwarderUrl; 81 }); 82 83 } 84 // Target is a substring to match inside an 'href' attribute 85 else { 86 // We look for elements containing the target string in their href 87 const $linkMatch = jQuery(`[href*="${target}"]`); 88 89 if ($linkMatch.length) { 90 // Update the href attribute directly and remove previous click action. 91 $linkMatch 92 .off('click') 93 .attr('href', forwarderUrl); 94 } 95 } 96 }); 97 98 // Remove the temporary configuration element from the DOM 99 $overwriteBookingDiv.remove(); 100} 101 102// Set custom Core params 103function micoreSetCustomCoreParams() { 104 const $customParams = jQuery('#micore_custom_params'); 105 106 // Return empty object if element not exist to avoid errors 107 if (!$customParams.length) return {}; 108 109 // Get ALL data attributes at once 110 const dataset = $customParams.data(); 111 const coreParams = {}; 112 113 // Extract specific values safely and check if the property exists in the dataset before assigning 114 if (dataset.chainSelectorValue) { 115 coreParams.chainSelectorValue = parseInt(dataset.chainSelectorValue, 10); 116 } 117 118 if (dataset.hsri) { 119 coreParams.hsri = dataset.hsri; 120 } 121 122 if (dataset.promocode) { 123 coreParams.promocode = dataset.promocode; 124 } 125 126 return coreParams; 127} 128 129// Set offset action for fixed finder 130function micoreFixedFinderOffset() { 131 // Cache the main element 132 const $fixedFinder = jQuery('#micore_fixed_finder[data-offset]'); 133 134 // Exit if element doesn't exist 135 if (!$fixedFinder.length) return; 136 137 /** 138 * Helper function to calculate the numeric scroll threshold. 139 * This logic handles both numeric offsets ("100") and selectors ("#header"). 140 */ 141 const calculateThreshold = () => { 142 const rawData = $fixedFinder.data('offset'); 143 const numericValue = parseInt(rawData, 10); 144 145 // The data-offset is NOT a valid number 146 if (isNaN(numericValue)) { 147 const $targetElement = jQuery(rawData); 148 149 // If the selector exists in the DOM, calculate top position + he
149ight 150 if ($targetElement.length) { 151 return $targetElement.offset().top + $targetElement.outerHeight(); 152 } 153 154 // Fallback: Selector not found 155 return 10; 156 } 157 158 // The data-offset is already a number 159 return numericValue; 160 }; 161 162 // Calculate the threshold 163 const scrollThreshold = calculateThreshold(); 164 165 // Set Scroll Event 166 jQuery(window).on('scroll', function () { 167 $fixedFinder.toggleClass('micore-offset-active', window.scrollY > scrollThreshold); 168 }); 169} 170 171// Set action for promocode toggles 172function micorePromocodeToggles() { 173 const $promocodeToggles = jQuery('.micore-promocode-toggle'); 174 175 // Check promocode toggles in the DOM 176 if (!$promocodeToggles.length || typeof window.Mirai !== 'object') return; 177 178 const updateToggleState = (isChecked) => { 179 // Get first promocode defined 180 const promocode = isChecked ? $promocodeToggles.last().data('promocode') : ''; 181 182 // Set promocode 183 window.Mirai.Event.publish("setStore", { 184 promocode: promocode 185 }); 186 }; 187 188 // On change 189 $promocodeToggles.on('change', function () { 190 // Get current toggle 191 const isChecked = jQuery(this).prop('checked'); 192 193 // Synchronize states 194 $promocodeToggles.not(this).prop('checked', isChecked); 195 196 updateToggleState(isChecked); 197 }); 198 199 // Set initial state 200 const initialCheck = $promocodeToggles.filter(':checked').length > 0; 201 202 $promocodeToggles.prop('checked', initialCheck); 203 updateToggleState(initialCheck); 204} 205 206// Reload core components inside elementor pop ups 207function micoreLoadCoreComponentsInElementorPopups() { 208 // Check for Elementor Editor mode first. 209 if (jQuery('body').hasClass('elementor-editor-active')) return; 210 211 // Cache the elements 212 const $popupComponents = jQuery('[data-elementor-type="popup"] [data-mirai-component]'); 213 214 // Validate existence and Global Object 215 if ($popupComponents.length && typeof window.Mirai === 'object') { 216 // Reset Component State 217 $popupComponents.removeAttr('data-ready'); 218 $popupComponents.find('> [data-role]').remove(); 219 220 // Reload Core components 221 window.Mirai.core(); 222 223 // Overwrite default core values 224 setTimeout(() => { 225 window.Mirai.Event.publish("setStore", micoreSetCustomCoreParams()); 226 }, 500); 227 } 228} 229 230micoreLoadIntegrationContent(); 231 232// ON LOAD CORE 233document.addEventListener('MIRAI:EVENT:core:events:ready', function () { 234 // ON LOAD FINDER 235 window.Mirai.Event.subscribe('finderLoaded', function ({ calendar, occupation, place, promocode } = {}) { 236 window.Mirai.Event.publish("setStore", micoreSetCustomCoreParams()); 237 }); 238}); 239 240jQuery(document).ready(function () { 241 micoreOverwriteCoreUrls(); 242 micoreFixedFinderOffset(); 243 micorePromocodeToggles(); 244}); 245 246jQuery(document).on('elementor/popup/show', function () { 247 micoreLoadCoreComponentsInElementorPopups(); 248});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.