| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/*!*************************************************!*\ |
| 3 |
!*** ./assets/src/apps/js/admin/pages/setup.js ***! |
| 4 |
\*************************************************/ |
| 5 |
/** |
| 6 |
* Setup Wizard Script |
| 7 |
* |
| 8 |
* @since 4.2.8.6 |
| 9 |
*/ |
| 10 |
class SetupWizard { |
| 11 |
static selectors = { |
| 12 |
elSetupForm: '#learn-press-setup-form', |
| 13 |
elPreviewPrice: '#preview-price' |
| 14 |
}; |
| 15 |
init() { |
| 16 |
this.elSetupForm = document.querySelector(SetupWizard.selectors.elSetupForm); |
| 17 |
if (!this.elSetupForm) { |
| 18 |
return; |
| 19 |
} |
| 20 |
this.events(); |
| 21 |
} |
| 22 |
events() { |
| 23 |
document.addEventListener('change', e => { |
| 24 |
if (e.target.closest('input, select')) { |
| 25 |
this.saveSettings(); |
| 26 |
} |
| 27 |
}); |
| 28 |
} |
| 29 |
|
| 30 |
/* Post form data to current url, update preview price html with response */ |
| 31 |
saveSettings() { |
| 32 |
const formData = new FormData(this.elSetupForm); |
| 33 |
fetch(window.location.href, { |
| 34 |
method: 'POST', |
| 35 |
body: formData |
| 36 |
}).then(response => response.text()).then(html => { |
| 37 |
const elPreviewPrice = document.querySelector(SetupWizard.selectors.elPreviewPrice); |
| 38 |
if (elPreviewPrice) { |
| 39 |
elPreviewPrice.innerHTML = html; |
| 40 |
} |
| 41 |
}); |
| 42 |
} |
| 43 |
} |
| 44 |
document.addEventListener('DOMContentLoaded', () => { |
| 45 |
new SetupWizard().init(); |
| 46 |
}); |
| 47 |
/******/ })() |
| 48 |
; |
| 49 |
//# sourceMappingURL=setup.js.map |