PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.2
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.2
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 / tools.js

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

126 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import getStepsUpgradeStatus from './tools/database/upgrade';
2 import createIndexes from './tools/database/create_indexs';
3 import reUpgradeDB from './tools/database/re-upgrade-db';
4 import cleanDatabases from './tools/database/clean_database';
5
6 import resetData from './tools/reset-data';
7
8 ( function( $ ) {
9 const $doc = $( document );
10 let isRunning = false;
11
12 const installSampleCourse = function installSampleCourse( e ) {
13 e.preventDefault();
14
15 const $button = $( this );
16
17 if ( isRunning ) {
18 return;
19 }
20
21 if ( ! confirm( lpGlobalSettings.i18n.confirm_install_sample_data ) ) {
22 return;
23 }
24
25 $button.addClass( 'disabled' ).html( $button.data( 'installing-text' ) );
26 $( '.lp-install-sample__response' ).remove();
27 isRunning = true;
28
29 $.ajax( {
30 url: $button.attr( 'href' ),
31 data: $( '.lp-install-sample__options' ).serializeJSON(),
32 success( response ) {
33 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
34 isRunning = false;
35 $( response ).insertBefore( $button.parent() );
36 },
37 error() {
38 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
39 isRunning = false;
40 $( response ).insertBefore( $button.parent() );
41 },
42 } );
43 };
44
45 const uninstallSampleCourse = function uninstallSampleCourse( e ) {
46 e.preventDefault();
47
48 const $button = $( this );
49
50 if ( isRunning ) {
51 return;
52 }
53
54 if ( ! confirm( lpGlobalSettings.i18n.confirm_uninstall_sample_data ) ) {
55 return;
56 }
57
58 $button.addClass( 'disabled' ).html( $button.data( 'uninstalling-text' ) );
59 isRunning = true;
60
61 $.ajax( {
62 url: $button.attr( 'href' ),
63 success( response ) {
64 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
65 isRunning = false;
66 $( response ).insertBefore( $button.parent() );
67 },
68 error() {
69 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
70 isRunning = false;
71 $( response ).insertBefore( $button.parent() );
72 },
73 } );
74 };
75
76 const clearHardCache = function clearHardCache( e ) {
77 e.preventDefault();
78 const $button = $( this );
79
80 if ( $button.hasClass( 'disabled' ) ) {
81 return;
82 }
83
84 $button.addClass( 'disabled' ).html( $button.data( 'cleaning-text' ) );
85 $.ajax( {
86 url: $button.attr( 'href' ),
87 data: {},
88 success( response ) {
89 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
90 },
91 error() {
92 $button.removeClass( 'disabled' ).html( $button.data( 'text' ) );
93 },
94 } );
95 };
96
97 const toggleHardCache = function toggleHardCache() {
98 $.ajax( {
99 url: 'admin.php?page=lp-toggle-hard-cache-option',
100 data: { v: this.checked ? 'yes' : 'no' },
101 success( response ) {
102 },
103 error() {
104 },
105 } );
106 };
107
108 const toggleOptions = function toggleOptions( e ) {
109 e.preventDefault();
110 $( '.lp-install-sample__options' ).toggleClass( 'hide-if-js' );
111 };
112
113 $( function() {
114 getStepsUpgradeStatus();
115 createIndexes();
116 reUpgradeDB();
117 resetData();
118 cleanDatabases();
119 $doc.on( 'click', '.lp-install-sample__install', installSampleCourse )
120 .on( 'click', '.lp-install-sample__uninstall', uninstallSampleCourse )
121 .on( 'click', '#learn-press-clear-cache', clearHardCache )
122 .on( 'click', 'input[name="enable_hard_cache"]', toggleHardCache )
123 .on( 'click', '.lp-install-sample__toggle-options', toggleOptions );
124 } );
125 }( jQuery ) );
126