PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 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 All 140 releases
← All changes | assets/js/dist/admin/pages/statistic.js +91 -129 4.1.7 → 4.4.9 View file →
@@ -1,5 +1,5 @@
1 -/******/ (function() { // webpackBootstrap
1 +/******/ (() => { // webpackBootstrap
2 2 var __webpack_exports__ = {};
3 3 /*!*****************************************************!*\
4 4 !*** ./assets/src/apps/js/admin/pages/statistic.js ***!
5 5 \*****************************************************/
@@ -6,9 +6,9 @@
6 6 (function ($) {
7 7 $.fn.LP_Chart_Line = function (data, config) {
8 8 return $.each(this, function () {
9 9 const $elem = $(this),
10 - $canvas = $('<canvas />');
10 + $canvas = $('<canvas />');
11 11 $elem.html('');
12 12 $canvas.appendTo($elem);
13 13 var lineChart = new Chart($canvas, {
14 14 type: 'line',
@@ -14,161 +14,142 @@
14 14 type: 'line',
15 15 data: data,
16 16 options: config
17 17 });
18 - }); //
18 + });
19 + //
19 20 };
20 -
21 21 $.fn.LP_Statistic_Users = function () {
22 22 if (parseInt($(this).length) === 0) {
23 23 return;
24 24 }
25 -
26 25 return $.each(this, function () {
27 26 const $buttons = $('.chart-buttons button').on('click', function () {
28 - const $button = $(this),
29 - type = $button.data('type');
30 - let from = '',
27 + const $button = $(this),
28 + type = $button.data('type');
29 + let from = '',
31 30 to = '';
32 - $buttons.not(this).not('[data-type="user-custom-time"]').prop('disabled', false);
33 -
34 - if (type == 'user-custom-time') {
35 - from = $('#user-custom-time input[name="from"]').val();
36 - to = $('#user-custom-time input[name="to"]').val();
37 -
38 - if (from == '' || to == '') {
39 - return false;
31 + $buttons.not(this).not('[data-type="user-custom-time"]').prop('disabled', false);
32 + if (type == 'user-custom-time') {
33 + from = $('#user-custom-time input[name="from"]').val();
34 + to = $('#user-custom-time input[name="to"]').val();
35 + if (from == '' || to == '') {
36 + return false;
37 + }
38 + } else {
39 + $button.prop('disabled', true);
40 40 }
41 - } else {
42 - $button.prop('disabled', true);
43 - }
44 -
45 - const $container = $('#learn-press-chart');
46 - $container.addClass('loading');
47 - $.ajax({
48 - url: 'admin-ajax.php',
49 - data: {
50 - action: 'learnpress_load_chart',
51 - type,
52 - range: [from, to]
53 - },
54 - dataType: 'text',
55 -
56 - success(response) {
57 - response = LP.parseJSON(response);
58 - $container.LP_Chart_Line(response, LP_Chart_Config);
59 - $container.removeClass('loading');
60 - }
61 -
41 + const $container = $('#learn-press-chart');
42 + $container.addClass('loading');
43 + $.ajax({
44 + url: 'admin-ajax.php',
45 + data: {
46 + action: 'learnpress_load_chart',
47 + type,
48 + range: [from, to]
49 + },
50 + dataType: 'text',
51 + success(response) {
52 + response = LP.parseJSON(response);
53 + $container.LP_Chart_Line(response, LP_Chart_Config);
54 + $container.removeClass('loading');
55 + }
56 + });
57 + return false;
58 + }),
59 + $inputs = $('.chart-buttons #user-custom-time input[type="text"]').on('change', function () {
60 + const _valid_date = function () {
61 + if (new Date($inputs[0].value) < new Date($inputs[1].value)) {
62 + return true;
63 + }
64 + };
65 + $buttons.filter('[data-type="user-custom-time"]').prop('disabled', $inputs.filter(function () {
66 + return this.value == '';
67 + }).get().length || !_valid_date());
62 68 });
63 - return false;
64 - }),
65 - $inputs = $('.chart-buttons #user-custom-time input[type="text"]').on('change', function () {
66 - const _valid_date = function () {
67 - if (new Date($inputs[0].value) < new Date($inputs[1].value)) {
68 - return true;
69 - }
70 - };
71 -
72 - $buttons.filter('[data-type="user-custom-time"]').prop('disabled', $inputs.filter(function () {
73 - return this.value == '';
74 - }).get().length || !_valid_date());
75 - });
76 69 });
77 70 };
78 -
79 71 $.fn.LP_Statistic_Courses = function () {
80 72 if (parseInt($(this).length) === 0) {
81 73 return;
82 74 }
83 -
84 75 return $.each(this, function () {
85 76 var $buttons = $('.chart-buttons button').on('click', function () {
86 - let $button = $(this),
77 + let $button = $(this),
87 78 type = $button.data('type'),
88 79 from = '',
89 80 to = '',
90 81 $container = $('#learn-press-chart');
91 - $buttons.not(this).not('[data-type="course-custom-time"]').prop('disabled', false);
92 -
93 - if (type == 'course-custom-time') {
94 - from = $('#course-custom-time input[name="from"]').val();
95 - to = $('#course-custom-time input[name="to"]').val();
96 -
97 - if (from == '' || to == '') {
98 - return false;
82 + $buttons.not(this).not('[data-type="course-custom-time"]').prop('disabled', false);
83 + if (type == 'course-custom-time') {
84 + from = $('#course-custom-time input[name="from"]').val();
85 + to = $('#course-custom-time input[name="to"]').val();
86 + if (from == '' || to == '') {
87 + return false;
88 + }
89 + } else {
90 + $button.prop('disabled', true);
99 91 }
100 - } else {
101 - $button.prop('disabled', true);
102 - }
103 -
104 - $container.addClass('loading');
105 - $.ajax({
106 - url: 'admin-ajax.php',
107 - data: {
108 - action: 'learnpress_load_chart',
109 - type,
110 - range: [from, to]
111 - },
112 - dataType: 'text',
113 -
114 - success(response) {
115 - response = LP.parseJSON(response);
116 - $container.LP_Chart_Line(response, LP_Chart_Config);
117 - $container.removeClass('loading');
118 - }
119 -
92 + $container.addClass('loading');
93 + $.ajax({
94 + url: 'admin-ajax.php',
95 + data: {
96 + action: 'learnpress_load_chart',
97 + type,
98 + range: [from, to]
99 + },
100 + dataType: 'text',
101 + success(response) {
102 + response = LP.parseJSON(response);
103 + $container.LP_Chart_Line(response, LP_Chart_Config);
104 + $container.removeClass('loading');
105 + }
106 + });
107 + return false;
108 + }),
109 + $inputs = $('.chart-buttons #course-custom-time input[type="text"]').on('change', function () {
110 + const _valid_date = function () {
111 + if (new Date($inputs[0].value) < new Date($inputs[1].value)) {
112 + return true;
113 + }
114 + };
115 + $buttons.filter('[data-type="course-custom-time"]').prop('disabled', $inputs.filter(function () {
116 + return this.value == '';
117 + }).get().length || !_valid_date());
120 118 });
121 - return false;
122 - }),
123 - $inputs = $('.chart-buttons #course-custom-time input[type="text"]').on('change', function () {
124 - const _valid_date = function () {
125 - if (new Date($inputs[0].value) < new Date($inputs[1].value)) {
126 - return true;
127 - }
128 - };
129 -
130 - $buttons.filter('[data-type="course-custom-time"]').prop('disabled', $inputs.filter(function () {
131 - return this.value == '';
132 - }).get().length || !_valid_date());
133 - });
134 119 });
135 120 };
136 -
137 121 $.fn.LP_Statistic_Orders = function () {
138 122 if (parseInt($(this).length) === 0) {
139 123 return;
140 124 }
141 -
142 125 $('.panel_report_option').hide();
143 126 $('#panel_report_sales_by_' + $('#report_sales_by').val()).show();
144 127 $('#report_sales_by').on('change', function () {
145 128 $('.panel_report_option').hide();
146 129 $('#panel_report_sales_by_' + $(this).val()).show();
147 -
148 130 if ('date' == $(this).val()) {
149 131 LP_Statistic_Orders_Upgrade_Chart();
150 132 }
151 133 });
134 +
152 135 /**
153 136 * Upgrade Chart for Order Statistics
154 137 *
155 138 * @return {boolean}
156 139 */
157 -
158 140 var LP_Statistic_Orders_Upgrade_Chart = function () {
159 141 let type = '',
160 - from = '',
161 - to = '',
162 - report_sales_by = 'date',
163 - cat_id = 0,
164 - course_id = 0;
142 + from = '',
143 + to = '',
144 + report_sales_by = 'date',
145 + cat_id = 0,
146 + course_id = 0;
165 147 report_sales_by = $('#report_sales_by').val();
166 148 $container = $('#learn-press-chart');
167 - $container.addClass('loading'); // get type
168 -
149 + $container.addClass('loading');
150 + // get type
169 151 const $buttons = $('.chart-buttons button:disabled').not('[data-type="order-custom-time"]');
170 -
171 152 if (parseInt($buttons.length) > 0) {
172 153 type = $($buttons[0]).data('type');
173 154 } else {
174 155 type = 'order-custom-time';
@@ -173,20 +154,17 @@
173 154 } else {
174 155 type = 'order-custom-time';
175 156 from = $('#order-custom-time input[name="from"]').val();
176 157 to = $('#order-custom-time input[name="to"]').val();
177 -
178 158 if (from == '' || to == '') {
179 159 return false;
180 160 }
181 161 }
182 -
183 162 if ('course' === report_sales_by) {
184 163 course_id = $('#report-by-course-id').val();
185 164 } else if ('category' === report_sales_by) {
186 165 cat_id = $('#report-by-course-category-id').val();
187 166 }
188 -
189 167 $.ajax({
190 168 url: 'admin-ajax.php',
191 169 data: {
192 170 action: 'learnpress_load_chart',
@@ -196,18 +174,15 @@
196 174 course_id,
197 175 cat_id
198 176 },
199 177 dataType: 'text',
200 -
201 178 success(response) {
202 179 response = LP.parseJSON(response);
203 180 $container.LP_Chart_Line(response, LP_Chart_Config);
204 181 $container.removeClass('loading');
205 182 }
206 -
207 183 });
208 184 };
209 -
210 185 $('#report-by-course-id').select2({
211 186 placeholder: 'Select a course',
212 187 minimumInputLength: 1,
213 188 ajax: {
@@ -213,22 +188,18 @@
213 188 ajax: {
214 189 url: ajaxurl + '?action=learnpress_search_course',
215 190 dataType: 'json',
216 191 quietMillis: 250,
217 -
218 192 data(term, page) {
219 193 return {
220 194 q: term // search term
221 -
222 195 };
223 196 },
224 -
225 197 results(data, page) {
226 198 return {
227 199 results: data.items
228 200 };
229 201 },
230 -
231 202 cache: true
232 203 }
233 204 });
234 205 $('#report-by-course-id').on('change', function () {
@@ -240,22 +211,18 @@
240 211 ajax: {
241 212 url: ajaxurl + '?action=learnpress_search_course_category',
242 213 dataType: 'json',
243 214 quietMillis: 250,
244 -
245 215 data(term, page) {
246 216 return {
247 217 q: term // search term
248 -
249 218 };
250 219 },
251 -
252 220 results(data, page) {
253 221 return {
254 222 results: data.items
255 223 };
256 224 },
257 -
258 225 cache: true
259 226 }
260 227 });
261 228 $('#report-by-course-category-id').on('change', function () {
@@ -262,20 +229,18 @@
262 229 LP_Statistic_Orders_Upgrade_Chart();
263 230 });
264 231 var $buttons = $('.chart-buttons button').on('click', function () {
265 232 const $button = $(this),
266 - type = $button.data('type'),
267 - from = '',
268 - to = '',
269 - $container = $('#learn-press-chart');
233 + type = $button.data('type'),
234 + from = '',
235 + to = '',
236 + $container = $('#learn-press-chart');
270 237 $buttons.not(this).not('[data-type="order-custom-time"]').prop('disabled', false);
271 -
272 238 if (type !== 'order-custom-time') {
273 239 $button.prop('disabled', true);
274 240 $('#order-custom-time input[name="from"]').val('');
275 241 $('#order-custom-time input[name="to"]').val('');
276 242 }
277 -
278 243 LP_Statistic_Orders_Upgrade_Chart();
279 244 return false;
280 245 });
281 246 var $inputs = $('.chart-buttons #order-custom-time input[type="text"]').on('change', function () {
@@ -283,15 +248,13 @@
283 248 if (new Date($inputs[0].value) < new Date($inputs[1].value)) {
284 249 return true;
285 250 }
286 251 };
287 -
288 252 $buttons.filter('[data-type="order-custom-time"]').prop('disabled', $inputs.filter(function () {
289 253 return this.value == '';
290 254 }).get().length || !_valid_date());
291 255 });
292 256 };
293 -
294 257 $(function () {
295 258 if (typeof $.fn.datepicker != 'undefined') {
296 259 $('.date-picker').datepicker({
297 260 dateFormat: 'yy/mm/dd'
@@ -296,9 +259,8 @@
296 259 $('.date-picker').datepicker({
297 260 dateFormat: 'yy/mm/dd'
298 261 });
299 262 }
300 -
301 263 $('.learn-press-statistic-users').LP_Statistic_Users();
302 264 $('.learn-press-statistic-courses').LP_Statistic_Courses();
303 265 $('.learn-press-statistic-orders').LP_Statistic_Orders();
304 266 });