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/sync-data.js +16 -65 4.1.7.3.2 → 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/sync-data.js ***!
5 5 \*****************************************************/
@@ -12,16 +12,13 @@
12 12 callback: null,
13 13 methodGetItems: '',
14 14 itemsKey: '',
15 15 chunkSize: 50,
16 -
17 16 sync(callback) {
18 17 if (this.syncing) {
19 18 return;
20 19 }
21 -
22 20 this.callback = callback;
23 -
24 21 if (this.items === false) {
25 22 this.get_items();
26 23 } else if (!this.dispatch()) {
27 24 this.completed = true;
@@ -27,30 +24,24 @@
27 24 this.completed = true;
28 25 this.callToCallback();
29 26 return;
30 27 }
31 -
32 28 this.syncing = true;
33 29 },
34 -
35 30 init() {
36 31 this.syncing = false;
37 32 this.items = false;
38 33 this.completed = false;
39 34 },
40 -
41 35 is_completed() {
42 36 return this.completed;
43 37 },
44 -
45 38 dispatch() {
46 39 const that = this,
47 - items = this.items ? this.items.splice(0, this.chunkSize) : false;
48 -
40 + items = this.items ? this.items.splice(0, this.chunkSize) : false;
49 41 if (!items || items.length === 0) {
50 42 return false;
51 43 }
52 -
53 44 $.ajax({
54 45 url: '',
55 46 data: {
56 47 'lp-ajax': this.id,
@@ -56,34 +47,26 @@
56 47 'lp-ajax': this.id,
57 48 sync: items
58 49 },
59 50 method: 'post',
60 -
61 51 success(response) {
62 52 response = LP.parseJSON(response);
63 53 that.syncing = false;
64 -
65 54 if (response.result !== 'success') {
66 55 that.completed = true;
67 56 }
68 -
69 57 that.callToCallback();
70 -
71 58 if (that.is_completed()) {
72 59 return;
73 60 }
74 -
75 61 that.sync(that.callback);
76 62 }
77 -
78 63 });
79 64 return true;
80 65 },
81 -
82 66 callToCallback() {
83 67 this.callback && this.callback.call(this);
84 68 },
85 -
86 69 get_items() {
87 70 const that = this;
88 71 $.ajax({
89 72 url: '',
@@ -90,13 +73,11 @@
90 73 data: {
91 74 'lp-ajax': this.id,
92 75 sync: this.methodGetItems
93 76 },
94 -
95 77 success(response) {
96 78 that.syncing = false;
97 79 response = LP.parseJSON(response);
98 -
99 80 if (response[that.itemsKey]) {
100 81 that.items = response[that.itemsKey];
101 82 that.sync(that.callback);
102 83 } else {
@@ -104,12 +85,10 @@
104 85 that.items = [];
105 86 that.callToCallback();
106 87 }
107 88 }
108 -
109 89 });
110 90 }
111 -
112 91 };
113 92 const Sync_Course_Orders = $.extend({}, Sync_Base, {
114 93 id: 'sync-course-orders',
115 94 methodGetItems: 'get-courses',
@@ -148,49 +127,37 @@
148 127 window.LP_Sync_Data = {
149 128 syncs: [],
150 129 syncing: 0,
151 130 options: {},
152 -
153 131 start(options) {
154 132 this.syncs = [];
155 133 this.options = $.extend({
156 134 onInit() {},
157 -
158 135 onStart() {},
159 -
160 136 onCompleted() {},
161 -
162 137 onCompletedAll() {}
163 -
164 138 }, options || {});
165 -
166 139 if (!this.get_syncs()) {
167 140 return;
168 141 }
169 -
170 142 this.reset();
171 143 this.options.onInit.call(this);
172 -
173 144 var that = this,
174 - syncing = 0,
175 - totalSyncs = this.syncs.length,
176 - syncCallback = function ($sync) {
177 - if ($sync.is_completed()) {
178 - syncing++;
179 - that.options.onCompleted.call(that, $sync);
180 -
181 - if (syncing >= totalSyncs) {
182 - that.options.onCompletedAll.call(that);
183 - return;
145 + syncing = 0,
146 + totalSyncs = this.syncs.length,
147 + syncCallback = function ($sync) {
148 + if ($sync.is_completed()) {
149 + syncing++;
150 + that.options.onCompleted.call(that, $sync);
151 + if (syncing >= totalSyncs) {
152 + that.options.onCompletedAll.call(that);
153 + return;
154 + }
155 + that.sync(syncing, syncCallback);
184 156 }
185 -
186 - that.sync(syncing, syncCallback);
187 - }
188 - };
189 -
157 + };
190 158 this.sync(syncing, syncCallback);
191 159 },
192 -
193 160 reset() {
194 161 for (const sync in this.syncs) {
195 162 try {
196 163 this[this.syncs[sync]].init();
@@ -196,47 +163,37 @@
196 163 this[this.syncs[sync]].init();
197 164 } catch (e) {}
198 165 }
199 166 },
200 -
201 167 sync(sync, callback) {
202 168 const that = this,
203 - $sync = this[this.syncs[sync]];
169 + $sync = this[this.syncs[sync]];
204 170 that.options.onStart.call(that, $sync);
205 171 $sync.sync(function () {
206 172 callback.call(that, $sync);
207 173 });
208 174 },
209 -
210 175 get_syncs() {
211 176 const syncs = $('input[name^="lp-repair"]:checked').serializeJSON()['lp-repair'];
212 -
213 177 if (!syncs) {
214 178 return false;
215 179 }
216 -
217 180 for (let sync in syncs) {
218 181 if (syncs[sync] !== 'yes') {
219 182 continue;
220 183 }
221 -
222 184 sync = sync.replace(/[-]+/g, '_');
223 -
224 185 if (!this[sync]) {
225 186 continue;
226 187 }
227 -
228 188 this.syncs.push(sync);
229 189 }
230 -
231 190 return this.syncs;
232 191 },
233 -
234 192 get_sync(id) {
235 193 id = id.replace(/[-]+/g, '_');
236 194 return this[id];
237 195 },
238 -
239 196 sync_course_orders: Sync_Course_Orders,
240 197 sync_user_orders: Sync_User_Orders,
241 198 sync_user_courses: Sync_User_Courses,
242 199 sync_course_final_quiz: Sync_Course_Final_Quiz,
@@ -245,9 +202,9 @@
245 202 };
246 203 $(document).ready(function () {
247 204 function initSyncs() {
248 205 const $chkAll = $('#learn-press-check-all-syncs'),
249 - $chks = $('#learn-press-syncs').find('[name^="lp-repair"]');
206 + $chks = $('#learn-press-syncs').find('[name^="lp-repair"]');
250 207 $chkAll.on('click', function () {
251 208 $chks.prop('checked', this.checked);
252 209 });
253 210 $chks.on('click', function () {
@@ -253,34 +210,28 @@
253 210 $chks.on('click', function () {
254 211 $chkAll.prop('checked', $chks.filter(':checked').length === $chks.length);
255 212 });
256 213 }
257 -
258 214 initSyncs();
259 215 }).on('click', '.lp-button-repair', function () {
260 216 function getInput(sync) {
261 217 return $('ul#learn-press-syncs').find('input[name*="' + sync + '"]');
262 218 }
263 -
264 219 LP_Sync_Data.start({
265 220 onInit() {
266 221 $('ul#learn-press-syncs').children().removeClass('syncing synced');
267 222 $('.lp-button-repair').prop('disabled', true);
268 223 },
269 -
270 224 onStart($sync) {
271 225 getInput($sync.id).closest('li').addClass('syncing');
272 226 },
273 -
274 227 onCompleted($sync) {
275 228 getInput($sync.id).closest('li').removeClass('syncing').addClass('synced');
276 229 },
277 -
278 230 onCompletedAll() {
279 231 $('ul#learn-press-syncs').children().removeClass('syncing synced');
280 232 $('.lp-button-repair').prop('disabled', false);
281 233 }
282 -
283 234 });
284 235 });
285 236 })(jQuery);
286 237 /******/ })()