| 1 |
'use strict'; |
| 2 |
(function ($) { |
| 3 |
|
| 4 |
const yay_currency = () => { |
| 5 |
if (window.history.replaceState) { |
| 6 |
window.history.replaceState(null, null, window.location.href); |
| 7 |
} |
| 8 |
}; |
| 9 |
|
| 10 |
// Define Filter & Action Hooks from YayCurrency |
| 11 |
window.yayCurrencyHooks = { |
| 12 |
addFilter: function (hookName, callback) { |
| 13 |
YayCurrency_Callback.Helper.addHook('filters', hookName, callback); |
| 14 |
}, |
| 15 |
applyFilters: YayCurrency_Callback.Helper.applyFilters, |
| 16 |
addAction: function (hookName, callback) { |
| 17 |
YayCurrency_Callback.Helper.addHook('actions', hookName, callback); |
| 18 |
}, |
| 19 |
doAction: YayCurrency_Callback.Helper.doAction |
| 20 |
}; |
| 21 |
|
| 22 |
jQuery(document).ready(function ($) { |
| 23 |
yay_currency($); |
| 24 |
const { yayCurrency } = window; |
| 25 |
const currencyID = YayCurrency_Callback.Helper.getCookie(yayCurrency.cookie_name); |
| 26 |
|
| 27 |
// Filter by Price (WooCommerce plugin) |
| 28 |
YayCurrency_Callback.Helper.handleFilterByPrice(currencyID); |
| 29 |
|
| 30 |
$(document.body).trigger('wc_fragment_refresh'); |
| 31 |
|
| 32 |
$(window).on('load resize scroll', YayCurrency_Callback.Helper.switcherUpwards()); |
| 33 |
|
| 34 |
// Use Param Url |
| 35 |
if (yayCurrency.yay_currency_use_params) { |
| 36 |
if (yayCurrency.yay_currency_param__name && currencyID) { |
| 37 |
YayCurrency_Callback.Helper.setCookie(yayCurrency.cookie_switcher_name ?? 'yay_currency_do_change_switcher', currencyID, 1); |
| 38 |
} |
| 39 |
} |
| 40 |
// Switcher Action |
| 41 |
YayCurrency_Callback.Helper.switcherAction(); |
| 42 |
|
| 43 |
// Convert |
| 44 |
YayCurrency_Callback.Helper.currencyConverter(); |
| 45 |
|
| 46 |
// Compatible with third party [Themes / Plugins] |
| 47 |
yayCurrencyHooks.doAction('yayCurrencyCompatibleThirdParty', [{ currencyID: currencyID }]); |
| 48 |
|
| 49 |
}); |
| 50 |
})(jQuery); |
| 51 |
|