1jQuery(document).ready(function ($) { 2 'use strict'; 3 woocommerce_multi_currency_switcher.use_session = _woocommerce_multi_currency_params.use_session; 4 woocommerce_multi_currency_switcher.ajax_url = _woocommerce_multi_currency_params.ajax_url; 5 woocommerce_multi_currency_switcher.switch_by_js = _woocommerce_multi_currency_params.switch_by_js; 6 woocommerce_multi_currency_switcher.init(); 7 jQuery(document.body).on('wmc_cache_compatible_finish', function () { 8 jQuery('.wmc-currency-loading').removeClass('wmc-currency-loading'); 9 jQuery('.wmc-select-currency-js').prop('disabled', false); 10 if (_woocommerce_multi_currency_params.do_not_reload_page == 1) { 11 if (typeof wc_checkout_params !== 'undefined') { 12 if (parseInt(wc_checkout_params.is_checkout) === 1) { 13 jQuery(document.body).trigger('update_checkout'); 14 } 15 } 16 if (typeof wc_add_to_cart_params !== 'undefined') { 17 if (parseInt(wc_add_to_cart_params.is_cart) === 1) { 18 jQuery('[name="update_cart"]').prop('disabled', false).trigger('click'); 19 } 20 } 21 } 22 }); 23 jQuery(document.body).on('wc_fragments_refreshed', function (event) { 24 25 }); 26}); 27 28window.woocommerce_multi_currency_switcher = { 29 use_session: 0, 30 ajax_url: '', 31 switch_by_js: '', 32 init: function () { 33 jQuery('body').on('click', '.wmc-currency-redirect', function (e) { 34 let $select = jQuery(this), $wmc_currency = $select.closest('.wmc-currency'), 35 $container = $select.closest('.woocommerce-multi-currency'); 36 if ($wmc_currency.hasClass('wmc-active')) { 37 e.preventDefault(); 38 return false; 39 } 40 e.stopPropagation(); 41 if (woocommerce_multi_currency_switcher.switch_by_js) { 42 e.preventDefault(); 43 wmcSwitchCurrency($select); 44 } 45 if ($container.hasClass('wmc-currency-trigger-click')) { 46 let $current = $container.find('.wmc-current-currency'), 47 $arrow = $container.find('.wmc-current-currency-arrow'); 48 if ($arrow.length === 0) { 49 $arrow = $container.find('.wmc-open-dropdown-currencies'); 50 } 51 let $sub_currency = $select.closest('.wmc-sub-currency'); 52 $sub_currency.find('.wmc-hidden').removeClass('wmc-hidden'); 53 $wmc_currency.addClass('wmc-hidden'); 54 if ($container.hasClass('wmc-price-switcher')) { 55 $current.html($select.html()); 56 $current.find('.wmc-price-switcher-code,.wmc-price-switcher-price').remove(); 57 } else { 58 if ($container.data('layout') === 'layout10') { 59 $current.find('.vi-flag-64').replaceWith($select.find('.vi-flag-64')); 60 jQuery('.wmc-text').attr('class', `wmc-text wmc-text-${$select.data('currency')}`).html(`<span class="wmc-text-currency-text">(${$select.data('currency')})</span>${$select.data('currency_symbol')}`); 61 } else { 62 $current.html($select.html()); 63 } 64 if ($arrow.length > 0) { 65 $current.append($arrow) 66 } 67 } 68 $select.closest('.wmc-currency-trigger-click-active').removeClass('wmc-currency-trigger-click-active'); 69 } 70 }).on('click', '.wmc-currency-wrapper .wmc-sub-currency > .wmc-currency', function (e) { 71 if ( _woocommerce_multi_currency_params.switch_container === '0' ) { 72 return; 73 } 74 let $select = jQuery(this).find('.wmc-currency-redirect'), $wmc_currency = $select.closest('.wmc-currency'), 75 $container = $select.closest('.woocommerce-multi-currency'); 76 if ($wmc_currency.hasClass('wmc-active')) { 77 e.preventDefault(); 78 return false; 79 } 80 e.stopPropagation(); 81 if (woocommerce_multi_currency_switcher.switch_by_js) { 82 e.preventDefault(); 83 wmcSwitchCurrency($select); 84 } 85 if ($container.hasClass('wmc-currency-trigger-click')) { 86 let $current = $container.find('.wmc-current-currency'), 87 $arrow = $container.find('.wmc-current-currency-arrow'); 88 if ($arrow.length === 0) { 89 $arrow = $container.find('.wmc-open-dropdown-currencies'); 90 } 91 let $sub_currency = $select.closest('.wmc-sub-currency'); 92 $sub_currency.find('.wmc-hidden').removeClass('wmc-hidden'); 93 $wmc_currency.addClass('wmc-hidden'); 94 if ($container.hasClass('wmc-price-switcher')) { 95 $current.html($select.html()); 96 $current.find('.wmc-price-switcher-code,.wmc-price-switcher-price').remove(); 97 } else { 98 if ($container.data('layout') === 'layout10') { 99 $current.find('.vi-flag-64').replaceWith($select.find('.vi-flag-64')); 100 jQuery('.wmc-text').attr('class', `wmc-text wmc-text-${$select.data('currency')}`).html(`<span class="wmc-text-currency-text">(${$select.data('currency')})</span>${$select.data('currency_symbol')}`); 101 } else { 102 $current.html($select.html()); 103 } 104 if ($arrow.length > 0) { 105 $current.append($arrow) 106 } 107 } 108 $select.closest('.wmc-currency-trigger-click-active').removeClass('wmc-currency-trigger-click-active'); 109 } 110 }); 111 112 jQuery('.wmc-select-currency-js').on('change', function (e) { 113 e.preventDefault(); 114 if (woocommerce_multi_currency_switcher.switch_by_js) { 115 wmcSwitchCurrency(jQuery(this)); 116 } else { 117 if (parseInt(_woocommerce_multi_currency_params.posts_submit) > 0) { 118 window.location.href = jQuery(this).val(); 119 } else { 120 window.history.replaceState({}, '', jQuery(this).val()); 121 window.location.reload(); 122 } 123 } 124 }) 125 },
126 setCookie: function (cname, cvalue, expire) { 127 var d = new Date(); 128 d.setTime(d.getTime() + (expire * 1000)); 129 var expires = "expires=" + d.toUTCString(); 130 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 131 }, 132 getCookie: function (cname) { 133 var name = cname + "="; 134 var decodedCookie = decodeURIComponent(document.cookie); 135 var ca = decodedCookie.split(';'); 136 for (var i = 0; i < ca.length; i++) { 137 var c = ca[i]; 138 while (c.charAt(0) == ' ') { 139 c = c.substring(1); 140 } 141 if (c.indexOf(name) == 0) { 142 return c.substring(name.length, c.length); 143 } 144 } 145 return ""; 146 }, 147 reload: function () { 148 let url = new URL(window.location.href); 149 if (parseInt(_woocommerce_multi_currency_params.posts_submit) > 0) { 150 url.searchParams.delete('wmc-currency'); 151 window.location.href = url.href.replace(url.hash, ''); 152 } else { 153 if (url.searchParams.get('wmc-currency')) { 154 url.searchParams.delete('wmc-currency'); 155 window.history.replaceState({}, '', url.href); 156 } 157 window.location.reload(); 158 } 159 }, 160}; 161 162var wmcSwitchCurrency = function ($switcher) { 163 let $wmc = $switcher.closest('.woocommerce-multi-currency'), currency = '', hash = ''; 164 if (!$wmc.hasClass('wmc-currency-loading')) { 165 if ($switcher.is('.wmc-select-currency-js')) { 166 currency = $switcher.val(); 167 } else { 168 currency = $switcher.data('currency'); 169 } 170 if (currency) { 171 $wmc.addClass('wmc-currency-loading'); 172 if ($switcher.is('.wmc-select-currency-js')) { 173 $wmc.prop('disabled', true); 174 } 175 if (woocommerce_multi_currency_switcher.use_session != 'cookie' && woocommerce_multi_currency_switcher.use_session != 0) { 176 jQuery.ajax({ 177 type: 'GET', 178 data: 'action=wmc_currency_switcher&wmc-currency=' + currency, 179 url: woocommerce_multi_currency_switcher.ajax_url, 180 xhrFields: {withCredentials: true}, 181 success: function (data) { 182 if (typeof wc_cart_fragments_params === 'undefined' || wc_cart_fragments_params === null) { 183 } else { 184 sessionStorage.removeItem(wc_cart_fragments_params.fragment_name); 185 } 186 if (_woocommerce_multi_currency_params.do_not_reload_page == 1) { 187 window.woocommerce_multi_currency.cacheCompatible(); 188 jQuery(document.body).trigger('wc_fragment_refresh'); 189 } else { 190 jQuery.when(jQuery(document.body).trigger('wc_fragment_refresh')).done(function () { 191 woocommerce_multi_currency_switcher.reload(); 192 }); 193 } 194 }, 195 error: function (html) { 196 }, 197 complete: function () { 198 if (_woocommerce_multi_currency_params.do_not_reload_page != 1) { 199 jQuery('.wmc-currency-loading').removeClass('wmc-currency-loading'); 200 jQuery('.wmc-select-currency-js').prop('disabled', false); 201 } 202 }, 203 }) 204 } else { 205 woocommerce_multi_currency_switcher.setCookie('wmc_current_currency', currency, 86400); 206 woocommerce_multi_currency_switcher.setCookie('wmc_current_currency_old', currency, 86400); 207 jQuery(document.body).trigger('wmc_switch_currency_by_js_set_cookie', currency); 208 if (typeof wc_cart_fragments_params === 'undefined' || wc_cart_fragments_params === null) { 209 } else { 210 sessionStorage.removeItem(wc_cart_fragments_params.fragment_name); 211 } 212 if (_woocommerce_multi_currency_params.do_not_reload_page == 1) { 213 window.woocommerce_multi_currency.cacheCompatible(); 214 jQuery(document.body).trigger('wc_fragment_refresh'); 215 } else { 216 jQuery.when(jQuery(document.body).trigger('wc_fragment_refresh')).done(function () { 217 jQuery('.wmc-currency-loading').removeClass('wmc-currency-loading'); 218 woocommerce_multi_currency_switcher.reload(); 219 }); 220 } 221 } 222 } 223 } 224};
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.