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 / js / dist / admin / pages / setup.js

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

151 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 var __webpack_exports__ = {};
3 /*!*************************************************!*\
4 !*** ./assets/src/apps/js/admin/pages/setup.js ***!
5 \*************************************************/
6 (function ($) {
7 'use strict';
8
9 let $main, $setupForm;
10
11 const checkForm = function checkForm($form) {
12 const $emails = $form.find('input[type="email"]');
13 let valid = true;
14 $emails.each(function () {
15 const $this = $(this);
16 $this.css('border-color', '');
17
18 switch ($this.attr('name')) {
19 case 'settings[paypal][paypal_email]':
20 case 'settings[paypal][paypal_sandbox_email]':
21 if (!$this.closest('tr').prev().find('input[type="checkbox"]').is(':checked')) {
22 return;
23 }
24
25 break;
26 }
27
28 if (!isEmail(this.value)) {
29 valid = false;
30 $this.css('border-color', '#FF0000');
31 }
32 });
33 return valid;
34 };
35
36 const blockContent = function blockContent(block) {
37 $main.toggleClass('loading', block === undefined ? true : block);
38 };
39
40 const getFormData = function getFormData(more) {
41 $setupForm = $('#learn-press-setup-form');
42 const data = $setupForm.serializeJSON();
43 return $.extend(data, more || {});
44 };
45
46 const replaceMainContent = function replaceMainContent(newContent) {
47 const $newContent = $(newContent);
48 $main.replaceWith($newContent);
49 $main = $newContent;
50 };
51 /*const navPages = function navPages( e ) {
52 e.preventDefault();
53 if ( ! checkForm( $setupForm ) ) {
54 return;
55 }
56 const loadUrl = $( this ).attr( 'href' );
57 $main.addClass( 'loading' );
58 $.post( {
59 url: loadUrl,
60 data: getFormData(),
61 success( res ) {
62 const $html = $( res );
63 replaceMainContent( $html.contents().filter( '#main' ) );
64 LP.setUrl( loadUrl );
65 $( '.learn-press-dropdown-pages' ).LP( 'DropdownPages' );
66 $( '.learn-press-tip' ).LP( 'QuickTip' );
67 $main.removeClass( 'loading' );
68 },
69 } );
70 };*/
71
72
73 const updateCurrency = function updateCurrency() {
74 const m = $(this).children(':selected').html().match(/\((.*)\)/),
75 symbol = m ? m[1] : '';
76 $('#currency-pos').children().each(function () {
77 const $option = $(this);
78 let text = $option.html();
79
80 switch ($option.val()) {
81 case 'left':
82 text = text.replace(/\( (.*)69/, '( ' + symbol + '69');
83 break;
84
85 case 'right':
86 text = text.replace(/9([^0-9]*) \)/, '9' + symbol + ' )');
87 break;
88
89 case 'left_with_space':
90 text = text.replace(/\( (.*) 6/, '( ' + symbol + ' 6');
91 break;
92
93 case 'right_with_space':
94 text = text.replace(/9 (.*) \)/, '9 ' + symbol + ' )');
95 break;
96 }
97
98 $option.html(text);
99 });
100 };
101
102 const updatePrice = function updatePrice() {
103 $.post({
104 url: '',
105 dataType: 'html',
106 data: getFormData({
107 'lp-ajax': 'get-price-format'
108 }),
109
110 success(res) {
111 $('#preview-price').html(res);
112 }
113
114 });
115 };
116
117 const createPages = function createPages(e) {
118 e.preventDefault();
119 blockContent();
120 $.post({
121 url: $(this).attr('href'),
122 dataType: 'html',
123 data: getFormData({
124 'lp-ajax': 'setup-create-pages'
125 }),
126
127 success(res) {
128 replaceMainContent($(res).contents().filter('#main'));
129 $('.learn-press-dropdown-pages').LP('DropdownPages');
130 blockContent(false);
131 }
132
133 });
134 };
135
136 function isEmail(email) {
137 const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
138 return re.test(email);
139 }
140
141 $(function () {
142 $main = $('#main');
143 $setupForm = $('#learn-press-setup-form');
144 $('.learn-press-select2').select2();
145 $(document). // on( 'click', '.buttons .button', navPages ).
146 on('change', '#currency', updateCurrency).on('change', 'input, select', updatePrice).on('click', '#create-pages', createPages);
147 });
148 })(jQuery);
149 /******/ })()
150 ;
151 //# sourceMappingURL=setup.js.map