Sha256: 76b6ccf7ac1ac5d7df3a6da6b9a46cd20fa913b90009f69cdb70f6dd5b893842
Contents?: true
Size: 1.7 KB
Versions: 1
Compression:
Stored size: 1.7 KB
Contents
document.addEventListener('turbolinks:load', function(event) { // this condition checks if this is the first initial load of turbolinks application if (!event.data.timing.visitStart) { var currencySelect = document.querySelectorAll('select[name=switch_to_currency]') if (currencySelect.length) { currencySelect.forEach(function (element) { element.addEventListener('change', function () { Harpiya.showProgressBar() var newCurrency = this.value // we need to make AJAX call here to the backend to set currency in session fetch(Harpiya.routes.set_currency(newCurrency), { method: 'GET' }).then(function (response) { switch (response.status) { case 200: Harpiya.setCurrency(newCurrency) document.getElementById('internationalization-options-desktop').classList.remove('show') break } }) }) }) } } }) // fix back button issue with different currency set // invalidate page if cached page has different currency then the current one document.addEventListener('turbolinks:load', function(event) { if (typeof (HARPIYA_DEFAULT_CURRENCY) !== 'undefined' && typeof (HARPIYA_CURRENCY) !== 'undefined') { if (HARPIYA_CURRENCY === HARPIYA_DEFAULT_CURRENCY) { var regexAnyCurrency = new RegExp('currency=') if (event.data.url.match(regexAnyCurrency) && !event.data.url.match(HARPIYA_CURRENCY)) { Harpiya.setCurrency(HARPIYA_CURRENCY) } } else { var regex = new RegExp('currency=' + HARPIYA_CURRENCY) if (!event.data.url.match(regex)) { Harpiya.setCurrency(HARPIYA_CURRENCY) } } } })
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
harpiya_frontend-4.3.0.alpha | app/assets/javascripts/harpiya/frontend/currency.js |