PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / trunk
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses vtrunk
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / src / apps / js / admin / pages / setup.js

setup.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses trunk, at assets/src/apps/js/admin/pages/setup.js

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