LearnPress – WordPress LMS Plugin - Version 3.2.6.5

Version Description

(20.11.2019) = ~ Fixed email doesn't send. ~ Fixed some js errors. ~ Fixed js call twice times. ~ Fixed question doesn't show after added to quiz. ~ Fixed ignore some metadata when copying course. ~ Fixed search orders in backend.

Download this release

Release Info

Developer tunnhn
Plugin Icon 128x128 LearnPress – WordPress LMS Plugin
Version 3.2.6.5
Comparing to
See all releases

Code changes from version 3.2.6.4 to 3.2.6.5

assets/css/admin/admin.css CHANGED
@@ -2389,7 +2389,9 @@ ul .clearfix {
2389
  box-shadow: none;
2390
  font-weight: normal;
2391
  color: #777;
2392
- padding: 0; }
 
 
2393
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .main .question-settings {
2394
  border: 1px solid #ddd;
2395
  border-left: none;
@@ -2635,7 +2637,9 @@ ul .clearfix {
2635
  border: 0;
2636
  width: 100%;
2637
  margin: 0;
2638
- padding: 6px 0px;
 
 
2639
  -webkit-box-shadow: none;
2640
  -moz-box-shadow: none;
2641
  box-shadow: none;
@@ -2654,11 +2658,12 @@ ul .clearfix {
2654
  border-bottom: 1px solid #DDD;
2655
  display: inline-block; }
2656
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .footer .table-row .add-new-question .add-new {
2657
- display: inline;
2658
- position: relative; }
 
2659
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .footer .table-row .add-new-question .add-new ul.question-types {
2660
  position: absolute;
2661
- margin: 6px;
2662
  background-color: #FFF;
2663
  top: 100%;
2664
  border: 1px solid #DDD;
2389
  box-shadow: none;
2390
  font-weight: normal;
2391
  color: #777;
2392
+ padding: 0;
2393
+ min-height: auto;
2394
+ line-height: 1; }
2395
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .main .question-settings {
2396
  border: 1px solid #ddd;
2397
  border-left: none;
2637
  border: 0;
2638
  width: 100%;
2639
  margin: 0;
2640
+ padding: 6px 0;
2641
+ line-height: 1;
2642
+ min-height: auto;
2643
  -webkit-box-shadow: none;
2644
  -moz-box-shadow: none;
2645
  box-shadow: none;
2658
  border-bottom: 1px solid #DDD;
2659
  display: inline-block; }
2660
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .footer .table-row .add-new-question .add-new {
2661
+ display: inline-block;
2662
+ position: relative;
2663
+ vertical-align: top; }
2664
  #admin-editor-lp_quiz .lp-box-data-content .lp-list-questions .footer .table-row .add-new-question .add-new ul.question-types {
2665
  position: absolute;
2666
+ margin: 0;
2667
  background-color: #FFF;
2668
  top: 100%;
2669
  border: 1px solid #DDD;
assets/js/admin/admin.js CHANGED
@@ -36,19 +36,34 @@
36
  /******/ // define getter function for harmony exports
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
38
  /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
  /******/ }
45
  /******/ };
46
  /******/
47
  /******/ // define __esModule on exports
48
  /******/ __webpack_require__.r = function(exports) {
 
 
 
49
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
  /******/ };
51
  /******/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /******/ // getDefaultExport function for compatibility with non-harmony modules
53
  /******/ __webpack_require__.n = function(module) {
54
  /******/ var getter = module && module.__esModule ?
@@ -75,137 +90,134 @@
75
  /*!**************************************!*\
76
  !*** ./assets/src/js/admin/admin.js ***!
77
  \**************************************/
78
- /*! no static exports found */
79
- /***/ (function(module, exports, __webpack_require__) {
80
 
81
  "use strict";
82
-
83
-
84
- var _update = __webpack_require__(/*! ./pages/update */ "./assets/src/js/admin/pages/update.js");
85
-
86
- var _update2 = _interopRequireDefault(_update);
87
-
88
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
89
-
90
- ; /**
91
- * JS code may run in all pages in admin.
92
- *
93
- * @version 3.2.6
94
- */
95
  //import Utils from './utils';
96
  //import Test from './test';
97
 
98
- (function () {
99
- var $ = jQuery;
100
 
101
- var updateItemPreview = function updateItemPreview() {
102
- $.ajax({
103
- url: '',
104
- data: {
105
- 'lp-ajax': 'toggle_item_preview',
106
- item_id: this.value,
107
- previewable: this.checked ? 'yes' : 'no',
108
- nonce: $(this).attr('data-nonce')
109
- },
110
- dataType: 'text',
111
- success: function success(response) {
112
- response = LP.parseJSON(response);
113
- }
114
- });
115
- };
116
-
117
- /**
118
- * Callback event for button to creating pages inside error message.
119
- *
120
- * @param {Event} e
121
- */
122
- var createPages = function createPages(e) {
123
- var $button = $(this).addClass('disabled');
124
- e.preventDefault();
125
- $.post({
126
- url: $button.attr('href'),
127
- data: {
128
- 'lp-ajax': 'create-pages'
129
- },
130
- dataType: 'text',
131
- success: function success(res) {
132
- var $message = $button.closest('.lp-notice').html('<p>' + res + '</p>');
133
- setTimeout(function () {
134
- $message.fadeOut();
135
- }, 2000);
136
- }
137
- });
138
- };
139
 
140
- var hideUpgradeMessage = function hideUpgradeMessage(e) {
141
- e.preventDefault();
142
- var $btn = $(this);
143
- $btn.closest('.lp-upgrade-notice').fadeOut();
144
- $.post({
145
- url: '',
146
- data: {
147
- 'lp-hide-upgrade-message': 'yes'
148
- },
149
- success: function success(res) {}
150
- });
151
- };
152
 
153
- var pluginActions = function pluginActions(e) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
- // Premium addon
156
- if ($(e.target).hasClass('buy-now')) {
157
- return;
158
- }
159
 
160
- e.preventDefault();
 
 
161
 
162
- var $plugin = $(this).closest('.plugin-card');
163
- if ($(this).hasClass('updating-message')) {
164
- return;
165
- }
166
- $(this).addClass('updating-message button-working disabled');
167
  $.ajax({
168
- url: $(this).attr('href'),
169
- data: {},
170
- success: function success(r) {
171
- $.ajax({
172
- url: window.location.href,
173
- success: function success(r) {
174
- var $p = $(r).find('#' + $plugin.attr('id'));
175
- if ($p.length) {
176
- $plugin.replaceWith($p);
177
- } else {
178
- $plugin.find('.plugin-action-buttons a').removeClass('updating-message button-working').html(learn_press_admin_localize.plugin_installed);
179
- }
180
- }
181
- });
182
  }
 
183
  });
184
- };
185
-
186
- var preventDefault = function preventDefault(e) {
187
- e.preventDefault();
188
- return false;
189
- };
190
-
191
- var onReady = function onReady() {
192
-
193
- $('.learn-press-dropdown-pages').LP('DropdownPages');
194
- $('.learn-press-advertisement-slider').LP('Advertisement', 'a', 's').appendTo($('#wpbody-content'));
195
- $('.learn-press-toggle-item-preview').on('change', updateItemPreview);
196
- $('.learn-press-tip').LP('QuickTip');
197
- //$('.learn-press-tabs').LP('AdminTab');
198
-
199
- $(document).on('click', '#learn-press-create-pages', createPages).on('click', '.lp-upgrade-notice .close-notice', hideUpgradeMessage).on('click', '.plugin-action-buttons a', pluginActions).on('click', '[data-remove-confirm]', preventDefault).on('mousedown', '.lp-sortable-handle', function (e) {
200
- $('html, body').addClass('lp-item-moving');
201
- $(e.target).closest('.lp-sortable-handle').css('cursor', 'inherit');
202
- }).on('mouseup', function (e) {
203
- $('html, body').removeClass('lp-item-moving');
204
- $('.lp-sortable-handle').css('cursor', '');
205
- });
206
- };
207
-
208
- $(document).ready(onReady);
209
  })();
210
 
211
  /***/ }),
@@ -215,188 +227,184 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
215
  !*** ./assets/src/js/admin/pages/update.js ***!
216
  \*********************************************/
217
  /*! no static exports found */
218
- /***/ (function(module, exports, __webpack_require__) {
219
-
220
- "use strict";
221
-
222
-
223
- ;(function ($) {
224
- 'use strict';
225
-
226
- var Package = function Package(data) {
227
- this.data = data;
228
-
229
- var currentIndex = -1,
230
- currentVersion = null,
231
- currentPackage = null,
232
- versions = Object.keys(this.data);
233
-
234
- this.reset = function (current) {
235
- current = current === undefined || current > versions.length - 1 || current < 0 ? 0 : current;
236
- currentIndex = current;
237
- currentVersion = versions[current];
238
- currentPackage = this.data[currentVersion];
239
-
240
- return currentPackage;
241
- };
242
-
243
- this.next = function () {
244
- if (currentIndex >= versions.length - 1) {
245
- return false;
246
- }
247
 
248
- currentIndex++;
249
- this.reset(currentIndex);
 
 
250
 
251
- return currentPackage;
252
- };
 
 
253
 
254
- this.prev = function () {
255
- if (currentIndex <= 0) {
256
- return false;
257
- }
258
 
259
- currentIndex--;
260
- this.reset(currentIndex);
 
 
261
 
262
- return currentPackage;
263
- };
 
264
 
265
- this.currentVersion = function () {
266
- return currentVersion;
267
- };
268
 
269
- this.hasPackage = function () {
270
- return versions.length;
271
- };
272
 
273
- this.getPercentCompleted = function () {
274
- return currentIndex / versions.length;
275
- };
276
 
277
- this.getTotal = function () {
278
- return versions.length;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  };
280
-
281
- if (!this.data) {
282
- return;
283
- }
284
- };
285
- var UpdaterSettings = {
286
- el: '#learn-press-updater',
287
- data: {
288
- packages: null,
289
- status: '',
290
- force: false
291
- },
292
- watch: {
293
- packages: function packages(newPackages, oldPackages) {
294
- if (newPackages) {}
295
- }
296
- },
297
- mounted: function mounted() {
298
- $(this.$el).show();
299
- },
300
- methods: {
301
- getUpdatePackages: function getUpdatePackages(callback) {
302
- var that = this;
303
- $.ajax({
304
- url: lpGlobalSettings.admin_url,
305
- data: {
306
- 'lp-ajax': 'get-update-packages',
307
- force: this.force,
308
- _wpnonce: lpGlobalSettings._wpnonce
309
- },
310
- success: function success(res) {
311
- var packages = LP.parseJSON(res);
312
- that.packages = new Package(packages);
313
- callback && callback.call(that);
314
- }
315
- });
316
- },
317
- start: function start(e, force) {
318
- this.packages = null;
319
- this.force = force;
320
- this.getUpdatePackages(function () {
321
- if (this.packages.hasPackage()) {
322
- var p = this.packages.next();
323
- this.status = 'updating';
324
- this.doUpdate(p);
325
- }
326
- });
327
- },
328
- getPackages: function getPackages() {
329
- return this.packages ? this.packages.data : {};
330
- },
331
- hasPackage: function hasPackage() {
332
- return !$.isEmptyObject(this.getPackages());
333
- },
334
- updateButtonClass: function updateButtonClass() {
335
- return {
336
- 'disabled': this.status === 'updating'
337
- };
338
  },
339
- doUpdate: function doUpdate(p, i) {
340
- var that = this;
341
-
342
- p = p ? p : this.packages.next();
343
- i = i ? i : 1;
344
-
345
- if (p) {
346
- $.ajax({
347
- url: lpGlobalSettings.admin_url,
348
- data: {
349
- 'lp-ajax': 'do-update-package',
350
- package: p,
351
- version: this.packages.currentVersion(),
352
- _wpnonce: lpGlobalSettings._wpnonce,
353
- force: this.force,
354
- i: i
355
- },
356
- success: function success(res) {
357
- var response = LP.parseJSON(res),
358
- $status = $(that.$el).find('.updater-progress-status');
359
- if (response.done === 'yes') {
360
- that.update(that.packages.getPercentCompleted() * 100);
361
- that.doUpdate();
362
- } else {
363
- var newWidth = that.packages.getPercentCompleted() * 100;
364
- if (response.percent) {
365
- var stepWidth = 1 / that.packages.getTotal();
366
- newWidth += stepWidth * response.percent;
367
- }
368
-
369
- that.update(newWidth);
370
- that.doUpdate(p, ++i);
371
- }
372
- },
373
- error: function error() {
374
- that.doUpdate(p, i);
375
- }
376
- });
377
- } else {
378
- that.update(100).addClass('completed');
379
- setTimeout(function (x) {
380
- x.status = 'completed';
381
- }, 2000, this);
382
  }
 
 
 
 
383
  },
384
- update: function update(value) {
385
- return $(this.$el).find('.updater-progress-status').css('width', value + '%').attr('data-value', parseInt(value));
386
  }
 
 
 
 
 
 
387
  }
388
- };
389
-
390
- function init() {
 
 
 
391
 
392
- window.lpGlobalSettings = window.lpGlobalSettings || {};
 
393
 
394
- if ($('#learn-press-updater').length) {
395
- var Updater = new Vue(UpdaterSettings);
396
- }
397
  }
 
398
 
399
- $(document).ready(init);
400
  })(jQuery);
401
 
402
  /***/ })
36
  /******/ // define getter function for harmony exports
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
38
  /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
 
 
 
 
40
  /******/ }
41
  /******/ };
42
  /******/
43
  /******/ // define __esModule on exports
44
  /******/ __webpack_require__.r = function(exports) {
45
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
+ /******/ }
48
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
  /******/ };
50
  /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__.t = function(value, mode) {
57
+ /******/ if(mode & 1) value = __webpack_require__(value);
58
+ /******/ if(mode & 8) return value;
59
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
+ /******/ var ns = Object.create(null);
61
+ /******/ __webpack_require__.r(ns);
62
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
+ /******/ return ns;
65
+ /******/ };
66
+ /******/
67
  /******/ // getDefaultExport function for compatibility with non-harmony modules
68
  /******/ __webpack_require__.n = function(module) {
69
  /******/ var getter = module && module.__esModule ?
90
  /*!**************************************!*\
91
  !*** ./assets/src/js/admin/admin.js ***!
92
  \**************************************/
93
+ /*! no exports provided */
94
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
95
 
96
  "use strict";
97
+ __webpack_require__.r(__webpack_exports__);
98
+ /* harmony import */ var _pages_update__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pages/update */ "./assets/src/js/admin/pages/update.js");
99
+ /* harmony import */ var _pages_update__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_pages_update__WEBPACK_IMPORTED_MODULE_0__);
100
+ /**
101
+ * JS code may run in all pages in admin.
102
+ *
103
+ * @version 3.2.6
104
+ */
 
 
 
 
 
105
  //import Utils from './utils';
106
  //import Test from './test';
107
 
108
+ ;
 
109
 
110
+ (function () {
111
+ var $ = jQuery;
112
+
113
+ var updateItemPreview = function updateItemPreview() {
114
+ $.ajax({
115
+ url: '',
116
+ data: {
117
+ 'lp-ajax': 'toggle_item_preview',
118
+ item_id: this.value,
119
+ previewable: this.checked ? 'yes' : 'no',
120
+ nonce: $(this).attr('data-nonce')
121
+ },
122
+ dataType: 'text',
123
+ success: function success(response) {
124
+ response = LP.parseJSON(response);
125
+ }
126
+ });
127
+ };
128
+ /**
129
+ * Callback event for button to creating pages inside error message.
130
+ *
131
+ * @param {Event} e
132
+ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
 
 
 
 
 
 
 
 
 
 
 
 
134
 
135
+ var createPages = function createPages(e) {
136
+ var $button = $(this).addClass('disabled');
137
+ e.preventDefault();
138
+ $.post({
139
+ url: $button.attr('href'),
140
+ data: {
141
+ 'lp-ajax': 'create-pages'
142
+ },
143
+ dataType: 'text',
144
+ success: function success(res) {
145
+ var $message = $button.closest('.lp-notice').html('<p>' + res + '</p>');
146
+ setTimeout(function () {
147
+ $message.fadeOut();
148
+ }, 2000);
149
+ }
150
+ });
151
+ };
152
+
153
+ var hideUpgradeMessage = function hideUpgradeMessage(e) {
154
+ e.preventDefault();
155
+ var $btn = $(this);
156
+ $btn.closest('.lp-upgrade-notice').fadeOut();
157
+ $.post({
158
+ url: '',
159
+ data: {
160
+ 'lp-hide-upgrade-message': 'yes'
161
+ },
162
+ success: function success(res) {}
163
+ });
164
+ };
165
+
166
+ var pluginActions = function pluginActions(e) {
167
+ // Premium addon
168
+ if ($(e.target).hasClass('buy-now')) {
169
+ return;
170
+ }
171
 
172
+ e.preventDefault();
173
+ var $plugin = $(this).closest('.plugin-card');
 
 
174
 
175
+ if ($(this).hasClass('updating-message')) {
176
+ return;
177
+ }
178
 
179
+ $(this).addClass('updating-message button-working disabled');
180
+ $.ajax({
181
+ url: $(this).attr('href'),
182
+ data: {},
183
+ success: function success(r) {
184
  $.ajax({
185
+ url: window.location.href,
186
+ success: function success(r) {
187
+ var $p = $(r).find('#' + $plugin.attr('id'));
188
+
189
+ if ($p.length) {
190
+ $plugin.replaceWith($p);
191
+ } else {
192
+ $plugin.find('.plugin-action-buttons a').removeClass('updating-message button-working').html(learn_press_admin_localize.plugin_installed);
 
 
 
 
 
 
193
  }
194
+ }
195
  });
196
+ }
197
+ });
198
+ };
199
+
200
+ var preventDefault = function preventDefault(e) {
201
+ e.preventDefault();
202
+ return false;
203
+ };
204
+
205
+ var onReady = function onReady() {
206
+ $('.learn-press-dropdown-pages').LP('DropdownPages');
207
+ $('.learn-press-advertisement-slider').LP('Advertisement', 'a', 's').appendTo($('#wpbody-content'));
208
+ $('.learn-press-toggle-item-preview').on('change', updateItemPreview);
209
+ $('.learn-press-tip').LP('QuickTip'); //$('.learn-press-tabs').LP('AdminTab');
210
+
211
+ $(document).on('click', '#learn-press-create-pages', createPages).on('click', '.lp-upgrade-notice .close-notice', hideUpgradeMessage).on('click', '.plugin-action-buttons a', pluginActions).on('click', '[data-remove-confirm]', preventDefault).on('mousedown', '.lp-sortable-handle', function (e) {
212
+ $('html, body').addClass('lp-item-moving');
213
+ $(e.target).closest('.lp-sortable-handle').css('cursor', 'inherit');
214
+ }).on('mouseup', function (e) {
215
+ $('html, body').removeClass('lp-item-moving');
216
+ $('.lp-sortable-handle').css('cursor', '');
217
+ });
218
+ };
219
+
220
+ $(document).ready(onReady);
221
  })();
222
 
223
  /***/ }),
227
  !*** ./assets/src/js/admin/pages/update.js ***!
228
  \*********************************************/
229
  /*! no static exports found */
230
+ /***/ (function(module, exports) {
231
+
232
+ ;
233
+
234
+ (function ($) {
235
+ 'use strict';
236
+
237
+ var Package = function Package(data) {
238
+ this.data = data;
239
+ var currentIndex = -1,
240
+ currentVersion = null,
241
+ currentPackage = null,
242
+ versions = Object.keys(this.data);
243
+
244
+ this.reset = function (current) {
245
+ current = current === undefined || current > versions.length - 1 || current < 0 ? 0 : current;
246
+ currentIndex = current;
247
+ currentVersion = versions[current];
248
+ currentPackage = this.data[currentVersion];
249
+ return currentPackage;
250
+ };
 
 
 
 
 
 
 
 
251
 
252
+ this.next = function () {
253
+ if (currentIndex >= versions.length - 1) {
254
+ return false;
255
+ }
256
 
257
+ currentIndex++;
258
+ this.reset(currentIndex);
259
+ return currentPackage;
260
+ };
261
 
262
+ this.prev = function () {
263
+ if (currentIndex <= 0) {
264
+ return false;
265
+ }
266
 
267
+ currentIndex--;
268
+ this.reset(currentIndex);
269
+ return currentPackage;
270
+ };
271
 
272
+ this.currentVersion = function () {
273
+ return currentVersion;
274
+ };
275
 
276
+ this.hasPackage = function () {
277
+ return versions.length;
278
+ };
279
 
280
+ this.getPercentCompleted = function () {
281
+ return currentIndex / versions.length;
282
+ };
283
 
284
+ this.getTotal = function () {
285
+ return versions.length;
286
+ };
287
 
288
+ if (!this.data) {
289
+ return;
290
+ }
291
+ };
292
+
293
+ var UpdaterSettings = {
294
+ el: '#learn-press-updater',
295
+ data: {
296
+ packages: null,
297
+ status: '',
298
+ force: false
299
+ },
300
+ watch: {
301
+ packages: function packages(newPackages, oldPackages) {
302
+ if (newPackages) {}
303
+ }
304
+ },
305
+ mounted: function mounted() {
306
+ $(this.$el).show();
307
+ },
308
+ methods: {
309
+ getUpdatePackages: function getUpdatePackages(callback) {
310
+ var that = this;
311
+ $.ajax({
312
+ url: lpGlobalSettings.admin_url,
313
+ data: {
314
+ 'lp-ajax': 'get-update-packages',
315
+ force: this.force,
316
+ _wpnonce: lpGlobalSettings._wpnonce
317
+ },
318
+ success: function success(res) {
319
+ var packages = LP.parseJSON(res);
320
+ that.packages = new Package(packages);
321
+ callback && callback.call(that);
322
+ }
323
+ });
324
+ },
325
+ start: function start(e, force) {
326
+ this.packages = null;
327
+ this.force = force;
328
+ this.getUpdatePackages(function () {
329
+ if (this.packages.hasPackage()) {
330
+ var p = this.packages.next();
331
+ this.status = 'updating';
332
+ this.doUpdate(p);
333
+ }
334
+ });
335
+ },
336
+ getPackages: function getPackages() {
337
+ return this.packages ? this.packages.data : {};
338
+ },
339
+ hasPackage: function hasPackage() {
340
+ return !$.isEmptyObject(this.getPackages());
341
+ },
342
+ updateButtonClass: function updateButtonClass() {
343
+ return {
344
+ 'disabled': this.status === 'updating'
345
  };
346
+ },
347
+ doUpdate: function doUpdate(p, i) {
348
+ var that = this;
349
+ p = p ? p : this.packages.next();
350
+ i = i ? i : 1;
351
+
352
+ if (p) {
353
+ $.ajax({
354
+ url: lpGlobalSettings.admin_url,
355
+ data: {
356
+ 'lp-ajax': 'do-update-package',
357
+ "package": p,
358
+ version: this.packages.currentVersion(),
359
+ _wpnonce: lpGlobalSettings._wpnonce,
360
+ force: this.force,
361
+ i: i
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  },
363
+ success: function success(res) {
364
+ var response = LP.parseJSON(res),
365
+ $status = $(that.$el).find('.updater-progress-status');
366
+
367
+ if (response.done === 'yes') {
368
+ that.update(that.packages.getPercentCompleted() * 100);
369
+ that.doUpdate();
370
+ } else {
371
+ var newWidth = that.packages.getPercentCompleted() * 100;
372
+
373
+ if (response.percent) {
374
+ var stepWidth = 1 / that.packages.getTotal();
375
+ newWidth += stepWidth * response.percent;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
+
378
+ that.update(newWidth);
379
+ that.doUpdate(p, ++i);
380
+ }
381
  },
382
+ error: function error() {
383
+ that.doUpdate(p, i);
384
  }
385
+ });
386
+ } else {
387
+ that.update(100).addClass('completed');
388
+ setTimeout(function (x) {
389
+ x.status = 'completed';
390
+ }, 2000, this);
391
  }
392
+ },
393
+ update: function update(value) {
394
+ return $(this.$el).find('.updater-progress-status').css('width', value + '%').attr('data-value', parseInt(value));
395
+ }
396
+ }
397
+ };
398
 
399
+ function init() {
400
+ window.lpGlobalSettings = window.lpGlobalSettings || {};
401
 
402
+ if ($('#learn-press-updater').length) {
403
+ var Updater = new Vue(UpdaterSettings);
 
404
  }
405
+ }
406
 
407
+ $(document).ready(init);
408
  })(jQuery);
409
 
410
  /***/ })
assets/js/admin/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){var e={};function a(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,a),s.l=!0,s.exports}a.m=t,a.c=e,a.d=function(t,e,n){a.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},a.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,"a",e),e},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},a.p="",a(a.s=62)}({61:function(t,e,a){"use strict";!function(t){var e={el:"#learn-press-updater",data:{packages:null,status:"",force:!1},watch:{packages:function(t,e){}},mounted:function(){t(this.$el).show()},methods:{getUpdatePackages:function(e){var a=this;t.ajax({url:lpGlobalSettings.admin_url,data:{"lp-ajax":"get-update-packages",force:this.force,_wpnonce:lpGlobalSettings._wpnonce},success:function(t){var n=LP.parseJSON(t);a.packages=new function(t){this.data=t;var e=-1,a=null,n=null,s=Object.keys(this.data);this.reset=function(t){return t=void 0===t||t>s.length-1||t<0?0:t,e=t,a=s[t],n=this.data[a]},this.next=function(){return!(e>=s.length-1)&&(e++,this.reset(e),n)},this.prev=function(){return!(e<=0)&&(e--,this.reset(e),n)},this.currentVersion=function(){return a},this.hasPackage=function(){return s.length},this.getPercentCompleted=function(){return e/s.length},this.getTotal=function(){return s.length},this.data}(n),e&&e.call(a)}})},start:function(t,e){this.packages=null,this.force=e,this.getUpdatePackages(function(){if(this.packages.hasPackage()){var t=this.packages.next();this.status="updating",this.doUpdate(t)}})},getPackages:function(){return this.packages?this.packages.data:{}},hasPackage:function(){return!t.isEmptyObject(this.getPackages())},updateButtonClass:function(){return{disabled:"updating"===this.status}},doUpdate:function(e,a){var n=this;e=e||this.packages.next(),a=a||1,e?t.ajax({url:lpGlobalSettings.admin_url,data:{"lp-ajax":"do-update-package",package:e,version:this.packages.currentVersion(),_wpnonce:lpGlobalSettings._wpnonce,force:this.force,i:a},success:function(s){var r=LP.parseJSON(s);t(n.$el).find(".updater-progress-status");if("yes"===r.done)n.update(100*n.packages.getPercentCompleted()),n.doUpdate();else{var i=100*n.packages.getPercentCompleted();if(r.percent)i+=1/n.packages.getTotal()*r.percent;n.update(i),n.doUpdate(e,++a)}},error:function(){n.doUpdate(e,a)}}):(n.update(100).addClass("completed"),setTimeout(function(t){t.status="completed"},2e3,this))},update:function(e){return t(this.$el).find(".updater-progress-status").css("width",e+"%").attr("data-value",parseInt(e))}}};t(document).ready(function(){window.lpGlobalSettings=window.lpGlobalSettings||{},t("#learn-press-updater").length&&new Vue(e)})}(jQuery)},62:function(t,e,a){"use strict";!function(t){t&&t.__esModule}(a(61));!function(){var t=jQuery,e=function(){t.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:t(this).attr("data-nonce")},dataType:"text",success:function(t){t=LP.parseJSON(t)}})},a=function(e){var a=t(this).addClass("disabled");e.preventDefault(),t.post({url:a.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(t){var e=a.closest(".lp-notice").html("<p>"+t+"</p>");setTimeout(function(){e.fadeOut()},2e3)}})},n=function(e){e.preventDefault(),t(this).closest(".lp-upgrade-notice").fadeOut(),t.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(t){}})},s=function(e){if(!t(e.target).hasClass("buy-now")){e.preventDefault();var a=t(this).closest(".plugin-card");t(this).hasClass("updating-message")||(t(this).addClass("updating-message button-working disabled"),t.ajax({url:t(this).attr("href"),data:{},success:function(e){t.ajax({url:window.location.href,success:function(e){var n=t(e).find("#"+a.attr("id"));n.length?a.replaceWith(n):a.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))}},r=function(t){return t.preventDefault(),!1};t(document).ready(function(){t(".learn-press-dropdown-pages").LP("DropdownPages"),t(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(t("#wpbody-content")),t(".learn-press-toggle-item-preview").on("change",e),t(".learn-press-tip").LP("QuickTip"),t(document).on("click","#learn-press-create-pages",a).on("click",".lp-upgrade-notice .close-notice",n).on("click",".plugin-action-buttons a",s).on("click","[data-remove-confirm]",r).on("mousedown",".lp-sortable-handle",function(e){t("html, body").addClass("lp-item-moving"),t(e.target).closest(".lp-sortable-handle").css("cursor","inherit")}).on("mouseup",function(e){t("html, body").removeClass("lp-item-moving"),t(".lp-sortable-handle").css("cursor","")})})}()}});
1
+ !function(e){var t={};function n(a){if(t[a])return t[a].exports;var s=t[a]={i:a,l:!1,exports:{}};return e[a].call(s.exports,s,s.exports,n),s.l=!0,s.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(a,s,function(t){return e[t]}.bind(null,s));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}({16:function(e,t,n){"use strict";n.r(t);var a,s,r,i,o,u;n(17);a=jQuery,s=function(){a.ajax({url:"",data:{"lp-ajax":"toggle_item_preview",item_id:this.value,previewable:this.checked?"yes":"no",nonce:a(this).attr("data-nonce")},dataType:"text",success:function(e){e=LP.parseJSON(e)}})},r=function(e){var t=a(this).addClass("disabled");e.preventDefault(),a.post({url:t.attr("href"),data:{"lp-ajax":"create-pages"},dataType:"text",success:function(e){var n=t.closest(".lp-notice").html("<p>"+e+"</p>");setTimeout((function(){n.fadeOut()}),2e3)}})},i=function(e){e.preventDefault(),a(this).closest(".lp-upgrade-notice").fadeOut(),a.post({url:"",data:{"lp-hide-upgrade-message":"yes"},success:function(e){}})},o=function(e){if(!a(e.target).hasClass("buy-now")){e.preventDefault();var t=a(this).closest(".plugin-card");a(this).hasClass("updating-message")||(a(this).addClass("updating-message button-working disabled"),a.ajax({url:a(this).attr("href"),data:{},success:function(e){a.ajax({url:window.location.href,success:function(e){var n=a(e).find("#"+t.attr("id"));n.length?t.replaceWith(n):t.find(".plugin-action-buttons a").removeClass("updating-message button-working").html(learn_press_admin_localize.plugin_installed)}})}}))}},u=function(e){return e.preventDefault(),!1},a(document).ready((function(){a(".learn-press-dropdown-pages").LP("DropdownPages"),a(".learn-press-advertisement-slider").LP("Advertisement","a","s").appendTo(a("#wpbody-content")),a(".learn-press-toggle-item-preview").on("change",s),a(".learn-press-tip").LP("QuickTip"),a(document).on("click","#learn-press-create-pages",r).on("click",".lp-upgrade-notice .close-notice",i).on("click",".plugin-action-buttons a",o).on("click","[data-remove-confirm]",u).on("mousedown",".lp-sortable-handle",(function(e){a("html, body").addClass("lp-item-moving"),a(e.target).closest(".lp-sortable-handle").css("cursor","inherit")})).on("mouseup",(function(e){a("html, body").removeClass("lp-item-moving"),a(".lp-sortable-handle").css("cursor","")}))}))},17:function(e,t){!function(e){"use strict";var t=function(e){this.data=e;var t=-1,n=null,a=null,s=Object.keys(this.data);this.reset=function(e){return e=void 0===e||e>s.length-1||e<0?0:e,t=e,n=s[e],a=this.data[n]},this.next=function(){return!(t>=s.length-1)&&(t++,this.reset(t),a)},this.prev=function(){return!(t<=0)&&(t--,this.reset(t),a)},this.currentVersion=function(){return n},this.hasPackage=function(){return s.length},this.getPercentCompleted=function(){return t/s.length},this.getTotal=function(){return s.length},this.data},n={el:"#learn-press-updater",data:{packages:null,status:"",force:!1},watch:{packages:function(e,t){}},mounted:function(){e(this.$el).show()},methods:{getUpdatePackages:function(n){var a=this;e.ajax({url:lpGlobalSettings.admin_url,data:{"lp-ajax":"get-update-packages",force:this.force,_wpnonce:lpGlobalSettings._wpnonce},success:function(e){var s=LP.parseJSON(e);a.packages=new t(s),n&&n.call(a)}})},start:function(e,t){this.packages=null,this.force=t,this.getUpdatePackages((function(){if(this.packages.hasPackage()){var e=this.packages.next();this.status="updating",this.doUpdate(e)}}))},getPackages:function(){return this.packages?this.packages.data:{}},hasPackage:function(){return!e.isEmptyObject(this.getPackages())},updateButtonClass:function(){return{disabled:"updating"===this.status}},doUpdate:function(t,n){var a=this;t=t||this.packages.next(),n=n||1,t?e.ajax({url:lpGlobalSettings.admin_url,data:{"lp-ajax":"do-update-package",package:t,version:this.packages.currentVersion(),_wpnonce:lpGlobalSettings._wpnonce,force:this.force,i:n},success:function(s){var r=LP.parseJSON(s);e(a.$el).find(".updater-progress-status");if("yes"===r.done)a.update(100*a.packages.getPercentCompleted()),a.doUpdate();else{var i=100*a.packages.getPercentCompleted();if(r.percent)i+=1/a.packages.getTotal()*r.percent;a.update(i),a.doUpdate(t,++n)}},error:function(){a.doUpdate(t,n)}}):(a.update(100).addClass("completed"),setTimeout((function(e){e.status="completed"}),2e3,this))},update:function(t){return e(this.$el).find(".updater-progress-status").css("width",t+"%").attr("data-value",parseInt(t))}}};e(document).ready((function(){if(window.lpGlobalSettings=window.lpGlobalSettings||{},e("#learn-press-updater").length)new Vue(n)}))}(jQuery)}});
assets/js/admin/conditional-logic.js CHANGED
@@ -36,19 +36,34 @@
36
  /******/ // define getter function for harmony exports
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
38
  /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
  /******/ }
45
  /******/ };
46
  /******/
47
  /******/ // define __esModule on exports
48
  /******/ __webpack_require__.r = function(exports) {
 
 
 
49
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
  /******/ };
51
  /******/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /******/ // getDefaultExport function for compatibility with non-harmony modules
53
  /******/ __webpack_require__.n = function(module) {
54
  /******/ var getter = module && module.__esModule ?
@@ -76,10 +91,7 @@
76
  !*** ./assets/src/js/admin/utils/conditional-logic.js ***!
77
  \********************************************************/
78
  /*! no static exports found */
79
- /***/ (function(module, exports, __webpack_require__) {
80
-
81
- "use strict";
82
-
83
 
84
  /**
85
  * Conditional Logic for metabox fields
@@ -88,232 +100,279 @@
88
  * @package LearnPress/JS
89
  * @version 3.0.0
90
  */
91
- ;(function ($) {
92
- window.conditional_logic_gray_state = function (state, field) {
93
- if (state) {
94
- $(this).removeClass('disabled');
95
- } else {
96
- $(this).addClass('disabled');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  }
98
- };
99
- var Conditional_Logic = window.Conditional_Logic = function (options) {
100
- this.options = $.extend({}, options || {});
101
- this.updateAll();
102
- };
103
-
104
- Conditional_Logic.prototype = $.extend(Conditional_Logic.prototype, {
105
- evaluate: function evaluate(changedId, conditionals) {
106
- if (!conditionals) {
107
- return undefined;
108
- }
109
- if (!conditionals || !$.isArray(conditionals.conditional)) {
110
- return undefined;
111
- }
112
- var show = undefined,
113
- controls = conditionals.conditional;
114
- for (var i in controls) {
115
- var _show = this.evaluateRequirement(controls[i]),
116
- operator = (controls[i].combine || 'and').toLowerCase();
117
- if (_show !== undefined && show !== undefined) {
118
- if (operator === 'and') {
119
- show = show && _show;
120
- } else {
121
- show = show || _show;
122
- }
123
- } else if (show === undefined) {
124
- show = _show;
125
- }
126
- }
127
- return show;
128
- },
129
- evaluateRequirement: function evaluateRequirement(requirement) {
130
- if (!requirement) {
131
- return undefined;
132
- }
133
- if (!requirement['field']) {
134
- return undefined;
135
- }
136
- if (requirement['compare'] === undefined) {
137
- requirement['compare'] = '=';
138
- }
139
- var control = $('#field-' + requirement.field);
140
- switch (requirement['state']) {
141
- case 'show':
142
- return control.is(':visible');
143
- break;
144
- case 'hide':
145
- return !control.is(':visible');
146
- break;
147
- default:
148
- var value = '';
149
- switch (this.getFieldType(control)) {
150
- case 'yes-no':
151
- var $chk = control.find('input[type="checkbox"]');
152
- value = $chk.is(':checked') ? $chk.val() : '';
153
- break;
154
- case 'radio':
155
- value = control.find('input:checked').val();
156
- break;
157
- default:
158
- value = control.find('input, select').val();
159
-
160
- }
161
-
162
- return this.compare(requirement['value'], value, requirement['compare']);
163
- }
164
- },
165
-
166
- compare: function compare(value2, value1, operator) {
167
- var show = undefined;
168
- switch (operator) {
169
- case '===':
170
- show = value1 === value2;
171
- break;
172
- case '==':
173
- case '=':
174
- case 'equals':
175
- case 'equal':
176
- show = value1 === value2;
177
- break;
178
- case '!==':
179
- show = value1 !== value2;
180
- break;
181
- case '!=':
182
- case 'not equal':
183
- show = value1 !== value2;
184
- break;
185
- case '>=':
186
- case 'greater or equal':
187
- case 'equal or greater':
188
- show = value1 >= value2;
189
- break;
190
- case '<=':
191
- case 'smaller or equal':
192
- case 'equal or smaller':
193
- show = value1 <= value2;
194
- break;
195
- case '>':
196
- case 'greater':
197
- show = value1 > value2;
198
- break;
199
- case '<':
200
- case 'smaller':
201
- show = value1 < value2;
202
- break;
203
- case 'contains':
204
- case 'in':
205
- var _array, _string;
206
- if ($.isArray(value1) && !$.isArray(value2)) {
207
- _array = value1;
208
- _string = value2;
209
- } else if ($.isArray(value2) && !$.isArray(value1)) {
210
- _array = value2;
211
- _string = value1;
212
- }
213
- if (_array && _string) {
214
- if (-1 === $.inArray(_string, _array)) {
215
- show = false;
216
- }
217
- } else {
218
- if (-1 === value1.indexOf(value2) && -1 === value2.indexOf(value1)) {
219
- show = false;
220
- }
221
- }
222
- break;
223
- default:
224
- show = value1 === value2;
225
- }
226
- if (show !== undefined) {
227
- return show;
228
- }
229
- return true;
230
- },
231
- hasConditional: function hasConditional(source, target) {
232
- if (!this.options.conditionals) {
233
- return;
234
- }
235
- if (!this.options.conditionals[target]) {
236
- return false;
237
- }
238
- for (var i in this.options.conditionals[target]['conditional']) {
239
- if (this.options.conditionals[target]['conditional'][i].field === source) {
240
- return this.options.conditionals[target];
241
- }
242
- }
243
- return false;
244
- },
245
- update: function update(changedField, $fields) {
246
- var $changedField = $(changedField),
247
- id = this.getFieldName($changedField);
248
- $fields = $fields || $('.rwmb-field');
249
- _.forEach($fields, function (field) {
250
- var thisField = $(field),
251
- thisId = this.getFieldName(thisField);
252
-
253
- if (thisId === id) {
254
- return;
255
- }
256
- var conditional = this.hasConditional(id, thisId);
257
-
258
- if (!conditional) {
259
- return;
260
- }
261
- var show = this.evaluate($changedField, conditional);
262
-
263
- if (show !== undefined) {
264
- if (conditional.state === 'hide') {
265
- show = !show;
266
- }
267
- if ($.isFunction(window[conditional.state_callback])) {
268
- window[conditional.state_callback].call(thisField, show, thisField);
269
- } else {
270
- thisField.toggle(show);
271
- }
272
- }
273
- }, this);
274
- },
275
- updateAll: function updateAll() {
276
- var $fields = $('.rwmb-field'),
277
- that = this;
278
- _.forEach($fields, function (field) {
279
- var $field = $(field),
280
- type = this.getFieldType($field),
281
- id = $field.find('.rwmb-field-name').val();
282
- if (!id) {
283
- return;
284
- }
285
- $field.attr('id', 'field-' + id);
286
-
287
- if (-1 === _.indexOf(this.supportFields, type)) {
288
- return;
289
- }
290
- $field.find('input, select, textarea').on('change', function () {
291
- that.update($(this).closest('.rwmb-field'), $fields);
292
- }).trigger('change');
293
- }, this);
294
- },
295
- getFieldType: function getFieldType(field) {
296
- var $field = $(field);
297
- if ($field.length === 0) {
298
- return false;
299
  }
300
- var className = $field.get(0).className,
301
- m = className.match(/rwmb-([^\s]*)-wrapper/);
302
- if (m) {
303
- return m[1];
304
  }
305
- return false;
306
- },
307
- getFieldName: function getFieldName(field) {
308
- return $(field).find('.rwmb-field-name').val();
309
- },
310
- supportFields: ['yes-no', 'text', 'number', 'radio']
311
- });
312
- $(document).ready(function () {
313
- if (window.lp_conditional_logic !== undefined) {
314
- new Conditional_Logic({ conditionals: lp_conditional_logic });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  }
316
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  })(jQuery);
318
 
319
  /***/ })
36
  /******/ // define getter function for harmony exports
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
38
  /******/ if(!__webpack_require__.o(exports, name)) {
39
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
 
 
 
 
40
  /******/ }
41
  /******/ };
42
  /******/
43
  /******/ // define __esModule on exports
44
  /******/ __webpack_require__.r = function(exports) {
45
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47
+ /******/ }
48
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
49
  /******/ };
50
  /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__.t = function(value, mode) {
57
+ /******/ if(mode & 1) value = __webpack_require__(value);
58
+ /******/ if(mode & 8) return value;
59
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60
+ /******/ var ns = Object.create(null);
61
+ /******/ __webpack_require__.r(ns);
62
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64
+ /******/ return ns;
65
+ /******/ };
66
+ /******/
67
  /******/ // getDefaultExport function for compatibility with non-harmony modules
68
  /******/ __webpack_require__.n = function(module) {
69
  /******/ var getter = module && module.__esModule ?
91
  !*** ./assets/src/js/admin/utils/conditional-logic.js ***!
92
  \********************************************************/
93
  /*! no static exports found */
94
+ /***/ (function(module, exports) {
 
 
 
95
 
96
  /**
97
  * Conditional Logic for metabox fields
100
  * @package LearnPress/JS
101
  * @version 3.0.0
102
  */
103
+ ;
104
+
105
+ (function ($) {
106
+ window.conditional_logic_gray_state = function (state, field) {
107
+ if (state) {
108
+ $(this).removeClass('disabled');
109
+ } else {
110
+ $(this).addClass('disabled');
111
+ }
112
+ };
113
+
114
+ var Conditional_Logic = window.Conditional_Logic = function (options) {
115
+ this.options = $.extend({}, options || {});
116
+ this.updateAll();
117
+ };
118
+
119
+ Conditional_Logic.prototype = $.extend(Conditional_Logic.prototype, {
120
+ evaluate: function evaluate(changedId, conditionals) {
121
+ if (!conditionals) {
122
+ return undefined;
123
+ }
124
+
125
+ if (!conditionals || !$.isArray(conditionals.conditional)) {
126
+ return undefined;
127
+ }
128
+
129
+ var show = undefined,
130
+ controls = conditionals.conditional;
131
+
132
+ for (var i in controls) {
133
+ var _show = this.evaluateRequirement(controls[i]),
134
+ operator = (controls[i].combine || 'and').toLowerCase();
135
+
136
+ if (_show !== undefined && show !== undefined) {
137
+ if (operator === 'and') {
138
+ show = show && _show;
139
+ } else {
140
+ show = show || _show;
141
+ }
142
+ } else if (show === undefined) {
143
+ show = _show;
144
  }
145
+ }
146
+
147
+ return show;
148
+ },
149
+ evaluateRequirement: function evaluateRequirement(requirement) {
150
+ if (!requirement) {
151
+ return undefined;
152
+ }
153
+
154
+ if (!requirement['field']) {
155
+ return undefined;
156
+ }
157
+
158
+ if (requirement['compare'] === undefined) {
159
+ requirement['compare'] = '=';
160
+ }
161
+
162
+ var control = $('#field-' + requirement.field);
163
+
164
+ switch (requirement['state']) {
165
+ case 'show':
166
+ return control.is(':visible');
167
+ break;
168
+
169
+ case 'hide':
170
+ return !control.is(':visible');
171
+ break;
172
+
173
+ default:
174
+ var value = '';
175
+
176
+ switch (this.getFieldType(control)) {
177
+ case 'yes-no':
178
+ var $chk = control.find('input[type="checkbox"]');
179
+ value = $chk.is(':checked') ? $chk.val() : '';
180
+ break;
181
+
182
+ case 'radio':
183
+ value = control.find('input:checked').val();
184
+ break;
185
+
186
+ default:
187
+ value = control.find('input, select').val();
188
+ }
189
+
190
+ return this.compare(requirement['value'], value, requirement['compare']);
191
+ }
192
+ },
193
+ compare: function compare(value2, value1, operator) {
194
+ var show = undefined;
195
+
196
+ switch (operator) {
197
+ case '===':
198
+ show = value1 === value2;
199
+ break;
200
+
201
+ case '==':
202
+ case '=':
203
+ case 'equals':
204
+ case 'equal':
205
+ show = value1 === value2;
206
+ break;
207
+
208
+ case '!==':
209
+ show = value1 !== value2;
210
+ break;
211
+
212
+ case '!=':
213
+ case 'not equal':
214
+ show = value1 !== value2;
215
+ break;
216
+
217
+ case '>=':
218
+ case 'greater or equal':
219
+ case 'equal or greater':
220
+ show = value1 >= value2;
221
+ break;
222
+
223
+ case '<=':
224
+ case 'smaller or equal':
225
+ case 'equal or smaller':
226
+ show = value1 <= value2;
227
+ break;
228
+
229
+ case '>':
230
+ case 'greater':
231
+ show = value1 > value2;
232
+ break;
233
+
234
+ case '<':
235
+ case 'smaller':
236
+ show = value1 < value2;
237
+ break;
238
+
239
+ case 'contains':
240
+ case 'in':
241
+ var _array, _string;
242
+
243
+ if ($.isArray(value1) && !$.isArray(value2)) {
244
+ _array = value1;
245
+ _string = value2;
246
+ } else if ($.isArray(value2) && !$.isArray(value1)) {
247
+ _array = value2;
248
+ _string = value1;
249
+ }
250
+
251
+ if (_array && _string) {
252
+ if (-1 === $.inArray(_string, _array)) {
253
+ show = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  }
255
+ } else {
256
+ if (-1 === value1.indexOf(value2) && -1 === value2.indexOf(value1)) {
257
+ show = false;
 
258
  }
259
+ }
260
+
261
+ break;
262
+
263
+ default:
264
+ show = value1 === value2;
265
+ }
266
+
267
+ if (show !== undefined) {
268
+ return show;
269
+ }
270
+
271
+ return true;
272
+ },
273
+ hasConditional: function hasConditional(source, target) {
274
+ if (!this.options.conditionals) {
275
+ return;
276
+ }
277
+
278
+ if (!this.options.conditionals[target]) {
279
+ return false;
280
+ }
281
+
282
+ for (var i in this.options.conditionals[target]['conditional']) {
283
+ if (this.options.conditionals[target]['conditional'][i].field === source) {
284
+ return this.options.conditionals[target];
285
+ }
286
+ }
287
+
288
+ return false;
289
+ },
290
+ update: function update(changedField, $fields) {
291
+ var $changedField = $(changedField),
292
+ id = this.getFieldName($changedField);
293
+ $fields = $fields || $('.rwmb-field');
294
+
295
+ _.forEach($fields, function (field) {
296
+ var thisField = $(field),
297
+ thisId = this.getFieldName(thisField);
298
+
299
+ if (thisId === id) {
300
+ return;
301
  }
302
+
303
+ var conditional = this.hasConditional(id, thisId);
304
+
305
+ if (!conditional) {
306
+ return;
307
+ }
308
+
309
+ var show = this.evaluate($changedField, conditional);
310
+
311
+ if (show !== undefined) {
312
+ if (conditional.state === 'hide') {
313
+ show = !show;
314
+ }
315
+
316
+ if ($.isFunction(window[conditional.state_callback])) {
317
+ window[conditional.state_callback].call(thisField, show, thisField);
318
+ } else {
319
+ thisField.toggle(show);
320
+ }
321
+ }
322
+ }, this);
323
+ },
324
+ updateAll: function updateAll() {
325
+ var $fields = $('.rwmb-field'),
326
+ that = this;
327
+
328
+ _.forEach($fields, function (field) {
329
+ var $field = $(field),
330
+ type = this.getFieldType($field),
331
+ id = $field.find('.rwmb-field-name').val();
332
+
333
+ if (!id) {
334
+ return;
335
+ }
336
+
337
+ $field.attr('id', 'field-' + id);
338
+
339
+ if (-1 === _.indexOf(this.supportFields, type)) {
340
+ return;
341
+ }
342
+
343
+ $field.find('input, select, textarea').on('change', function () {
344
+ that.update($(this).closest('.rwmb-field'), $fields);
345
+ }).trigger('change');
346
+ }, this);
347
+ },
348
+ getFieldType: function getFieldType(field) {
349
+ var $field = $(field);
350
+
351
+ if ($field.length === 0) {
352
+ return false;
353
+ }
354
+
355
+ var className = $field.get(0).className,
356
+ m = className.match(/rwmb-([^\s]*)-wrapper/);
357
+
358
+ if (m) {
359
+ return m[1];
360
+ }
361
+
362
+ return false;
363
+ },
364
+ getFieldName: function getFieldName(field) {
365
+ return $(field).find('.rwmb-field-name').val();
366
+ },
367
+ supportFields: ['yes-no', 'text', 'number', 'radio']
368
+ });
369
+ $(document).ready(function () {
370
+ if (window.lp_conditional_logic !== undefined) {
371
+ new Conditional_Logic({
372
+ conditionals: lp_conditional_logic
373
+ });
374
+ }
375
+ });
376
  })(jQuery);
377
 
378
  /***/ })
assets/js/admin/conditional-logic.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var i={};function t(a){if(i[a])return i[a].exports;var n=i[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=i,t.d=function(e,i,a){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:a})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},t.p="",t(t.s=10)}({10:function(e,i,t){"use strict";!function(e){window.conditional_logic_gray_state=function(i,t){i?e(this).removeClass("disabled"):e(this).addClass("disabled")};var i=window.Conditional_Logic=function(i){this.options=e.extend({},i||{}),this.updateAll()};i.prototype=e.extend(i.prototype,{evaluate:function(i,t){if(t&&t&&e.isArray(t.conditional)){var a=void 0,n=t.conditional;for(var r in n){var o=this.evaluateRequirement(n[r]),s=(n[r].combine||"and").toLowerCase();void 0!==o&&void 0!==a?a="and"===s?a&&o:a||o:void 0===a&&(a=o)}return a}},evaluateRequirement:function(i){if(i&&i.field){void 0===i.compare&&(i.compare="=");var t=e("#field-"+i.field);switch(i.state){case"show":return t.is(":visible");case"hide":return!t.is(":visible");default:var a="";switch(this.getFieldType(t)){case"yes-no":var n=t.find('input[type="checkbox"]');a=n.is(":checked")?n.val():"";break;case"radio":a=t.find("input:checked").val();break;default:a=t.find("input, select").val()}return this.compare(i.value,a,i.compare)}}},compare:function(i,t,a){var n=void 0;switch(a){case"===":n=t===i;break;case"==":case"=":case"equals":case"equal":n=t===i;break;case"!==":n=t!==i;break;case"!=":case"not equal":n=t!==i;break;case">=":case"greater or equal":case"equal or greater":n=t>=i;break;case"<=":case"smaller or equal":case"equal or smaller":n=t<=i;break;case">":case"greater":n=t>i;break;case"<":case"smaller":n=t<i;break;case"contains":case"in":var r,o;e.isArray(t)&&!e.isArray(i)?(r=t,o=i):e.isArray(i)&&!e.isArray(t)&&(r=i,o=t),r&&o?-1===e.inArray(o,r)&&(n=!1):-1===t.indexOf(i)&&-1===i.indexOf(t)&&(n=!1);break;default:n=t===i}return void 0===n||n},hasConditional:function(e,i){if(this.options.conditionals){if(!this.options.conditionals[i])return!1;for(var t in this.options.conditionals[i].conditional)if(this.options.conditionals[i].conditional[t].field===e)return this.options.conditionals[i];return!1}},update:function(i,t){var a=e(i),n=this.getFieldName(a);t=t||e(".rwmb-field"),_.forEach(t,function(i){var t=e(i),r=this.getFieldName(t);if(r!==n){var o=this.hasConditional(n,r);if(o){var s=this.evaluate(a,o);void 0!==s&&("hide"===o.state&&(s=!s),e.isFunction(window[o.state_callback])?window[o.state_callback].call(t,s,t):t.toggle(s))}}},this)},updateAll:function(){var i=e(".rwmb-field"),t=this;_.forEach(i,function(a){var n=e(a),r=this.getFieldType(n),o=n.find(".rwmb-field-name").val();o&&(n.attr("id","field-"+o),-1!==_.indexOf(this.supportFields,r)&&n.find("input, select, textarea").on("change",function(){t.update(e(this).closest(".rwmb-field"),i)}).trigger("change"))},this)},getFieldType:function(i){var t=e(i);if(0===t.length)return!1;var a=t.get(0).className.match(/rwmb-([^\s]*)-wrapper/);return!!a&&a[1]},getFieldName:function(i){return e(i).find(".rwmb-field-name").val()},supportFields:["yes-no","text","number","radio"]}),e(document).ready(function(){void 0!==window.lp_conditional_logic&&new i({conditionals:lp_conditional_logic})})}(jQuery)}});
1
+ !function(e){var i={};function t(a){if(i[a])return i[a].exports;var n=i[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=i,t.d=function(e,i,a){t.o(e,i)||Object.defineProperty(e,i,{enumerable:!0,get:a})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,i){if(1&i&&(e=t(e)),8&i)return e;if(4&i&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(t.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&i&&"string"!=typeof e)for(var n in e)t.d(a,n,function(i){return e[i]}.bind(null,n));return a},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},t.p="",t(t.s=8)}({8:function(e,i){!function(e){window.conditional_logic_gray_state=function(i,t){i?e(this).removeClass("disabled"):e(this).addClass("disabled")};var i=window.Conditional_Logic=function(i){this.options=e.extend({},i||{}),this.updateAll()};i.prototype=e.extend(i.prototype,{evaluate:function(i,t){if(t&&t&&e.isArray(t.conditional)){var a=void 0,n=t.conditional;for(var r in n){var o=this.evaluateRequirement(n[r]),s=(n[r].combine||"and").toLowerCase();void 0!==o&&void 0!==a?a="and"===s?a&&o:a||o:void 0===a&&(a=o)}return a}},evaluateRequirement:function(i){if(i&&i.field){void 0===i.compare&&(i.compare="=");var t=e("#field-"+i.field);switch(i.state){case"show":return t.is(":visible");case"hide":return!t.is(":visible");default:var a="";switch(this.getFieldType(t)){case"yes-no":var n=t.find('input[type="checkbox"]');a=n.is(":checked")?n.val():"";break;case"radio":a=t.find("input:checked").val();break;default:a=t.find("input, select").val()}return this.compare(i.value,a,i.compare)}}},compare:function(i,t,a){var n=void 0;switch(a){case"===":n=t===i;break;case"==":case"=":case"equals":case"equal":n=t===i;break;case"!==":n=t!==i;break;case"!=":case"not equal":n=t!==i;break;case">=":case"greater or equal":case"equal or greater":n=t>=i;break;case"<=":case"smaller or equal":case"equal or smaller":n=t<=i;break;case">":case"greater":n=t>i;break;case"<":case"smaller":n=t<i;break;case"contains":case"in":var r,o;e.isArray(t)&&!e.isArray(i)?(r=t,o=i):e.isArray(i)&&!e.isArray(t)&&(r=i,o=t),r&&o?-1===e.inArray(o,r)&&(n=!1):-1===t.indexOf(i)&&-1===i.indexOf(t)&&(n=!1);break;default:n=t===i}return void 0===n||n},hasConditional:function(e,i){if(this.options.conditionals){if(!this.options.conditionals[i])return!1;for(var t in this.options.conditionals[i].conditional)if(this.options.conditionals[i].conditional[t].field===e)return this.options.conditionals[i];return!1}},update:function(i,t){var a=e(i),n=this.getFieldName(a);t=t||e(".rwmb-field"),_.forEach(t,(function(i){var t=e(i),r=this.getFieldName(t);if(r!==n){var o=this.hasConditional(n,r);if(o){var s=this.evaluate(a,o);void 0!==s&&("hide"===o.state&&(s=!s),e.isFunction(window[o.state_callback])?window[o.state_callback].call(t,s,t):t.toggle(s))}}}),this)},updateAll:function(){var i=e(".rwmb-field"),t=this;_.forEach(i,(function(a){var n=e(a),r=this.getFieldType(n),o=n.find(".rwmb-field-name").val();o&&(n.attr("id","field-"+o),-1!==_.indexOf(this.supportFields,r)&&n.find("input, select, textarea").on("change",(function(){t.update(e(this).closest(".rwmb-field"),i)})).trigger("change"))}),this)},getFieldType:function(i){var t=e(i);if(0===t.length)return!1;var a=t.get(0).className.match(/rwmb-([^\s]*)-wrapper/);return!!a&&a[1]},getFieldName:function(i){return e(i).find(".rwmb-field-name").val()},supportFields:["yes-no","text","number","radio"]}),e(document).ready((function(){void 0!==window.lp_conditional_logic&&new i({conditionals:lp_conditional_logic})}))}(jQuery)}});
assets/js/admin/editor/course.js CHANGED
@@ -36,19 +36,34 @@
36
  /******/ // define getter function for harmony exports
37
  /******/ __webpack_require__.d = function(exports, name, getter) {
38
  /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
  /******/ }
45
  /******/ };
46
  /******/
47
  /******/ // define __esModule on exports
48
  /******/ __webpack_require__.r = function(exports) {
 
 
 
49
  /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
  /******/ };
51
  /******/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /******/ // getDefaultExport function for compatibility with non-harmony modules
53
  /******/ __webpack_require__.n = function(module) {
54
  /******/ var getter = module && module.__esModule ?
@@ -75,207 +90,188 @@
75
  /*!**************************************************************!*\
76
  !*** ./assets/src/js/admin/editor/actions/course-section.js ***!
77
  \**************************************************************/
78
- /*! no static exports found */
79
- /***/ (function(module, exports, __webpack_require__) {
80
 
81
  "use strict";
82
-
83
-
84
- Object.defineProperty(exports, "__esModule", {
85
- value: true
86
- });
87
  var CourseCurriculum = {
88
- toggleAllSections: function toggleAllSections(context) {
89
- var hidden = context.getters['isHiddenAllSections'];
90
 
91
- if (hidden) {
92
- context.commit('OPEN_ALL_SECTIONS');
93
- } else {
94
- context.commit('CLOSE_ALL_SECTIONS');
95
- }
96
-
97
- LP.Request({
98
- type: 'hidden-sections',
99
- hidden: context.getters['hiddenSections']
100
- });
101
- },
102
-
103
- updateSectionsOrder: function updateSectionsOrder(context, order) {
104
- LP.Request({
105
- type: 'sort-sections',
106
- order: JSON.stringify(order)
107
- }).then(function (response) {
108
- var result = response.body;
109
- var order_sections = result.data;
110
- context.commit('SORT_SECTION', order_sections);
111
- }, function (error) {
112
- console.error(error);
113
- });
114
- },
115
-
116
- toggleSection: function toggleSection(context, section) {
117
- if (section.open) {
118
- context.commit('CLOSE_SECTION', section);
119
- } else {
120
- context.commit('OPEN_SECTION', section);
121
- }
122
-
123
- LP.Request({
124
- type: 'hidden-sections',
125
- hidden: context.getters['hiddenSections']
126
- });
127
- },
128
-
129
- updateSection: function updateSection(context, section) {
130
- context.commit('UPDATE_SECTION_REQUEST', section.id);
131
-
132
- LP.Request({
133
- type: 'update-section',
134
- section: JSON.stringify(section)
135
- }).then(function () {
136
- context.commit('UPDATE_SECTION_SUCCESS', section.id);
137
- }).catch(function () {
138
- context.commit('UPDATE_SECTION_FAILURE', section.id);
139
- });
140
- },
141
-
142
- removeSection: function removeSection(context, payload) {
143
- context.commit('REMOVE_SECTION', payload.index);
144
-
145
- LP.Request({
146
- type: 'remove-section',
147
- section_id: payload.section.id
148
- }).then(function (response) {
149
- var result = response.body;
150
- }, function (error) {
151
- console.error(error);
152
- });
153
- },
154
-
155
- newSection: function newSection(context, name) {
156
- var newSection = {
157
- type: 'new-section',
158
- section_name: name,
159
- temp_id: LP.uniqueId()
160
- };
161
- context.commit('ADD_NEW_SECTION', {
162
- id: newSection.temp_id,
163
- items: [],
164
- open: false,
165
- title: newSection.section_name
166
- });
167
-
168
- LP.Request(newSection).then(function (response) {
169
- var result = response.body;
170
-
171
- if (result.success) {
172
- var section = $.extend({}, result.data, { open: true });
173
-
174
- // update course section
175
- context.commit('ADD_NEW_SECTION', section);
176
- }
177
- }, function (error) {
178
- console.error(error);
179
- });
180
- },
181
-
182
- updateSectionItem: function updateSectionItem(context, payload) {
183
- context.commit('UPDATE_SECTION_ITEM_REQUEST', payload.item.id);
184
-
185
- LP.Request({
186
- type: 'update-section-item',
187
- section_id: payload.section_id,
188
- item: JSON.stringify(payload.item)
189
-
190
- }).then(function (response) {
191
- context.commit('UPDATE_SECTION_ITEM_SUCCESS', payload.item.id);
192
 
193
- var result = response.body;
194
- if (result.success) {
195
- var item = result.data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
- context.commit('UPDATE_SECTION_ITEM', { section_id: payload.section_id, item: item });
198
- }
199
- }, function (error) {
200
- context.commit('UPDATE_SECTION_ITEM_FAILURE', payload.item.id);
201
- console.error(error);
202
- });
203
- },
204
-
205
- removeSectionItem: function removeSectionItem(context, payload) {
206
- var id = payload.item.id;
207
- context.commit('REMOVE_SECTION_ITEM', payload);
208
- payload.item.temp_id = 0;
209
- LP.Request({
210
- type: 'remove-section-item',
211
- section_id: payload.section_id,
212
- item_id: id
213
- }).then(function () {
214
- context.commit('REMOVE_SECTION_ITEM', payload);
215
- });
216
- },
217
-
218
- deleteSectionItem: function deleteSectionItem(context, payload) {
219
- var id = payload.item.id;
220
- context.commit('REMOVE_SECTION_ITEM', payload);
221
- payload.item.temp_id = 0;
222
- LP.Request({
223
- type: 'delete-section-item',
224
- section_id: payload.section_id,
225
- item_id: id
226
- }).then(function () {
227
- context.commit('REMOVE_SECTION_ITEM', payload);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  });
229
- },
230
-
231
- newSectionItem: function newSectionItem(context, payload) {
232
-
233
- context.commit('APPEND_EMPTY_ITEM_TO_SECTION', payload);
234
- //context.commit('UPDATE_SECTION_ITEMS', {section_id: payload.section_id, items: result.data});
235
- LP.Request({
236
- type: 'new-section-item',
237
- section_id: payload.section_id,
238
- item: JSON.stringify(payload.item)
239
- }).then(function (response) {
240
- var result = response.body;
241
-
242
- if (result.success) {
243
- // context.commit('UPDATE_SECTION_ITEMS', {section_id: payload.section_id, items: result.data});
244
- var items = {};
245
- $.each(result.data, function (i, a) {
246
- items[a.old_id ? a.old_id : a.id] = a;
247
- });
248
- context.commit('UPDATE_ITEM_SECTION_BY_ID', {
249
- section_id: payload.section_id,
250
- items: items
251
- });
252
- }
253
- }, function (error) {
254
- console.error(error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  });
256
- },
257
-
258
- updateSectionItems: function updateSectionItems(_ref, payload) {
259
- var state = _ref.state;
260
-
261
- LP.Request({
262
- type: 'update-section-items',
263
- section_id: payload.section_id,
264
- items: JSON.stringify(payload.items),
265
- last_section: state.sections[state.sections.length - 1] === payload.section_id
266
- }).then(function (response) {
267
- var result = response.body;
268
-
269
- if (result.success) {
270
- // console.log(result);
271
- }
272
- }, function (error) {
273
- console.error(error);
274
  });
275
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  };
277
-
278
- exports.default = CourseCurriculum;
279
 
280
  /***/ }),
281
 
@@ -283,66 +279,58 @@ exports.default = CourseCurriculum;
283
  /*!******************************************************!*\
284
  !*** ./assets/src/js/admin/editor/actions/course.js ***!
285
  \******************************************************/
286
- /*! no static exports found */
287
- /***/ (function(module, exports, __webpack_require__) {
288
 
289
  "use strict";
290
-
291
-
292
- Object.defineProperty(exports, "__esModule", {
293
- value: true
294
- });
295
  var Course = {
296
- heartbeat: function heartbeat(context) {
297
- LP.Request({
298
- type: 'heartbeat'
299
- }).then(function (response) {
300
- var result = response.body;
301
- context.commit('UPDATE_HEART_BEAT', !!result.success);
302
- }, function (error) {
303
- context.commit('UPDATE_HEART_BEAT', false);
304
- });
305
- },
306
-
307
- draftCourse: function draftCourse(context, payload) {
308
- var auto_draft = context.getters['autoDraft'];
309
-
310
- if (auto_draft) {
311
- LP.Request({
312
- type: 'draft-course',
313
- course: JSON.stringify(payload)
314
- }).then(function (response) {
315
- var result = response.body;
316
-
317
- if (!result.success) {
318
- return;
319
- }
320
-
321
- context.commit('UPDATE_AUTO_DRAFT_STATUS', false);
322
- });
323
  }
324
- },
325
 
326
- newRequest: function newRequest(context) {
327
- context.commit('INCREASE_NUMBER_REQUEST');
328
- context.commit('UPDATE_STATUS', 'loading');
329
-
330
- window.onbeforeunload = function () {
331
- return '';
332
- };
333
- },
334
 
335
- requestCompleted: function requestCompleted(context, status) {
336
- context.commit('DECREASE_NUMBER_REQUEST');
 
 
 
 
337
 
338
- if (context.getters.currentRequest === 0) {
339
- context.commit('UPDATE_STATUS', status);
340
- window.onbeforeunload = null;
341
- }
342
  }
 
343
  };
344
-
345
- exports.default = Course;
346
 
347
  /***/ }),
348
 
@@ -350,91 +338,78 @@ exports.default = Course;
350
  /*!******************************************************************!*\
351
  !*** ./assets/src/js/admin/editor/actions/modal-course-items.js ***!
352
  \******************************************************************/
353
- /*! no static exports found */
354
- /***/ (function(module, exports, __webpack_require__) {
355
 
356
  "use strict";
357
-
358
-
359
- Object.defineProperty(exports, "__esModule", {
360
- value: true
361
- });
362
  var ModalCourseItems = {
363
-
364
- toggle: function toggle(context) {
365
- context.commit('TOGGLE');
366
- },
367
-
368
- open: function open(context, sectionId) {
369
- context.commit('SET_SECTION', sectionId);
370
- context.commit('RESET');
371
- context.commit('TOGGLE');
372
- },
373
-
374
- searchItems: function searchItems(context, payload) {
375
- context.commit('SEARCH_ITEMS_REQUEST');
376
-
377
- LP.Request({
378
- type: 'search-items',
379
- query: payload.query,
380
- item_type: payload.type,
381
- page: payload.page,
382
- exclude: JSON.stringify([])
383
- }).then(function (response) {
384
- var result = response.body;
385
-
386
- if (!result.success) {
387
- return;
388
- }
389
-
390
- var data = result.data;
391
-
392
- context.commit('SET_LIST_ITEMS', data.items);
393
- context.commit('UPDATE_PAGINATION', data.pagination);
394
- context.commit('SEARCH_ITEMS_SUCCESS');
395
- }, function (error) {
396
- context.commit('SEARCH_ITEMS_FAILURE');
397
-
398
- console.error(error);
399
- });
400
- },
401
-
402
- addItem: function addItem(context, item) {
403
- context.commit('ADD_ITEM', item);
404
- },
405
-
406
- removeItem: function removeItem(context, index) {
407
- context.commit('REMOVE_ADDED_ITEM', index);
408
- },
409
-
410
- addItemsToSection: function addItemsToSection(context) {
411
- var items = context.getters.addedItems;
412
-
413
- if (items.length > 0) {
414
- LP.Request({
415
- type: 'add-items-to-section',
416
- section_id: context.getters.section,
417
- items: JSON.stringify(items)
418
- }).then(function (response) {
419
- var result = response.body;
420
-
421
- if (result.success) {
422
- context.commit('TOGGLE');
423
-
424
- var items = result.data;
425
- context.commit('ss/UPDATE_SECTION_ITEMS', {
426
- section_id: context.getters.section,
427
- items: items
428
- }, { root: true });
429
- }
430
- }, function (error) {
431
- console.error(error);
432
- });
433
  }
 
 
 
434
  }
 
435
  };
436
-
437
- exports.default = ModalCourseItems;
438
 
439
  /***/ }),
440
 
@@ -442,43 +417,36 @@ exports.default = ModalCourseItems;
442
  /*!**********************************************!*\
443
  !*** ./assets/src/js/admin/editor/course.js ***!
444
  \**********************************************/
445
- /*! no static exports found */
446
- /***/ (function(module, exports, __webpack_require__) {
447
 
448
  "use strict";
 
 
 
449
 
450
 
451
- var _http = __webpack_require__(/*! ./http */ "./assets/src/js/admin/editor/http.js");
452
-
453
- var _http2 = _interopRequireDefault(_http);
454
-
455
- var _course = __webpack_require__(/*! ./store/course */ "./assets/src/js/admin/editor/store/course.js");
456
-
457
- var _course2 = _interopRequireDefault(_course);
458
-
459
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
460
-
461
  window.$Vue = window.$Vue || Vue;
462
  window.$Vuex = window.$Vuex || Vuex;
463
-
464
  var $ = window.jQuery;
465
-
466
  /**
467
  * Init app.
468
  *
469
  * @since 3.0.0
470
  */
471
- $(document).ready(function () {
472
 
473
- window.LP_Curriculum_Store = new $Vuex.Store((0, _course2.default)(lpAdminCourseEditorSettings));
474
- (0, _http2.default)({ ns: 'LPCurriculumRequest', store: LP_Curriculum_Store });
475
-
476
- setTimeout(function () {
477
- window.LP_Course_Editor = new $Vue({
478
- el: '#admin-editor-lp_course',
479
- template: '<lp-course-editor></lp-course-editor>'
480
- });
481
- }, 100);
 
 
 
482
  });
483
 
484
  /***/ }),
@@ -487,44 +455,38 @@ $(document).ready(function () {
487
  /*!**************************************************************!*\
488
  !*** ./assets/src/js/admin/editor/getters/course-section.js ***!
489
  \**************************************************************/
490
- /*! no static exports found */
491
- /***/ (function(module, exports, __webpack_require__) {
492
 
493
  "use strict";
494
-
495
-
496
- Object.defineProperty(exports, "__esModule", {
497
- value: true
498
- });
499
  var CourseCurriculum = {
500
- sections: function sections(state) {
501
- return state.sections || [];
502
- },
503
- urlEdit: function urlEdit(state) {
504
- return state.urlEdit;
505
- },
506
- hiddenSections: function hiddenSections(state) {
507
- return state.sections.filter(function (section) {
508
- return !section.open;
509
- }).map(function (section) {
510
- return parseInt(section.id);
511
- });
512
- },
513
- isHiddenAllSections: function isHiddenAllSections(state, getters) {
514
- var sections = getters['sections'];
515
- var hiddenSections = getters['hiddenSections'];
516
-
517
- return hiddenSections.length === sections.length;
518
- },
519
- statusUpdateSection: function statusUpdateSection(state) {
520
- return state.statusUpdateSection;
521
- },
522
- statusUpdateSectionItem: function statusUpdateSectionItem(state) {
523
- return state.statusUpdateSectionItem;
524
- }
525
  };
526
-
527
- exports.default = CourseCurriculum;
528
 
529
  /***/ }),
530
 
@@ -532,46 +494,41 @@ exports.default = CourseCurriculum;
532
  /*!******************************************************!*\
533
  !*** ./assets/src/js/admin/editor/getters/course.js ***!
534
  \******************************************************/
535
- /*! no static exports found */
536
- /***/ (function(module, exports, __webpack_require__) {
537
 
538
  "use strict";
539
-
540
-
541
- Object.defineProperty(exports, "__esModule", {
542
- value: true
543
- });
544
  var Course = {
545
- heartbeat: function heartbeat(state) {
546
- return state.heartbeat;
547
- },
548
- action: function action(state) {
549
- return state.action;
550
- },
551
- id: function id(state) {
552
- return state.course_id;
553
- },
554
- autoDraft: function autoDraft(state) {
555
- return state.auto_draft;
556
- },
557
- disable_curriculum: function disable_curriculum(state) {
558
- return state.disable_curriculum;
559
- },
560
- status: function status(state) {
561
- return state.status || 'error';
562
- },
563
- currentRequest: function currentRequest(state) {
564
- return state.countCurrentRequest || 0;
565
- },
566
- urlAjax: function urlAjax(state) {
567
- return state.ajax;
568
- },
569
- nonce: function nonce(state) {
570
- return state.nonce;
571
- }
572
  };
573
-
574
- exports.default = Course;
575
 
576
  /***/ }),
577
 
@@ -579,49 +536,42 @@ exports.default = Course;
579
  /*!******************************************************************!*\
580
  !*** ./assets/src/js/admin/editor/getters/modal-course-items.js ***!
581
  \******************************************************************/
582
- /*! no static exports found */
583
- /***/ (function(module, exports, __webpack_require__) {
584
 
585
  "use strict";
586
-
587
-
588
- Object.defineProperty(exports, "__esModule", {
589
- value: true
590
- });
591
-
592
  var Getters = {
593
- status: function status(state) {
594
- return state.status;
595
- },
596
- pagination: function pagination(state) {
597
- return state.pagination;
598
- },
599
- items: function items(state, _getters) {
600
- return state.items.map(function (item) {
601
- var find = _getters.addedItems.find(function (_item) {
602
- return item.id === _item.id;
603
- });
604
-
605
- item.added = !!find;
606
-
607
- return item;
608
- });
609
- },
610
- addedItems: function addedItems(state) {
611
- return state.addedItems;
612
- },
613
- isOpen: function isOpen(state) {
614
- return state.open;
615
- },
616
- types: function types(state) {
617
- return state.types;
618
- },
619
- section: function section(state) {
620
- return state.sectionId;
621
- }
622
  };
623
-
624
- exports.default = Getters;
625
 
626
  /***/ }),
627
 
@@ -629,76 +579,68 @@ exports.default = Getters;
629
  /*!********************************************!*\
630
  !*** ./assets/src/js/admin/editor/http.js ***!
631
  \********************************************/
632
- /*! no static exports found */
633
- /***/ (function(module, exports, __webpack_require__) {
634
 
635
  "use strict";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
 
 
 
 
 
 
637
 
638
- Object.defineProperty(exports, "__esModule", {
639
- value: true
640
- });
641
- exports.default = HTTP;
642
- function HTTP(options) {
643
- var $ = window.jQuery;
644
- var $VueHTTP = Vue.http;
645
-
646
- options = $.extend({
647
- ns: 'LPRequest',
648
- store: false
649
- }, options || {});
650
-
651
- var $publishingAction = null;
652
-
653
- LP.Request = function (payload) {
654
- $publishingAction = $('#publishing-action');
655
-
656
- payload['id'] = options.store.getters.id;
657
- payload['nonce'] = options.store.getters.nonce;
658
- payload['lp-ajax'] = options.store.getters.action;
659
- payload['code'] = options.store.getters.code;
660
-
661
- $publishingAction.find('#publish').addClass('disabled');
662
- $publishingAction.find('.spinner').addClass('is-active');
663
- $publishingAction.addClass('code-' + payload['code']);
664
-
665
- return $VueHTTP.post(options.store.getters.urlAjax, payload, {
666
- emulateJSON: true,
667
- params: {
668
- namespace: options.ns,
669
- code: payload['code']
670
- }
671
- });
672
- };
673
 
674
- $VueHTTP.interceptors.push(function (request, next) {
675
- if (request.params['namespace'] !== options.ns) {
676
- next();
677
- return;
678
- }
679
 
680
- options.store.dispatch('newRequest');
681
-
682
- next(function (response) {
683
- if (!jQuery.isPlainObject(response.body)) {
684
- response.body = LP.parseJSON(response.body);
685
- }
686
-
687
- var body = response.body;
688
- var result = body.success || false;
689
-
690
- if (result) {
691
- options.store.dispatch('requestCompleted', 'successful');
692
- } else {
693
- options.store.dispatch('requestCompleted', 'failed');
694
- }
695
- $publishingAction.removeClass('code-' + request.params.code);
696
- if (!$publishingAction.attr('class')) {
697
- $publishingAction.find('#publish').removeClass('disabled');
698
- $publishingAction.find('.spinner').removeClass('is-active');
699
- }
700
- });
701
  });
 
702
  }
703
 
704
  /***/ }),
@@ -707,187 +649,172 @@ function HTTP(options) {
707
  /*!****************************************************************!*\
708
  !*** ./assets/src/js/admin/editor/mutations/course-section.js ***!
709
  \****************************************************************/
710
- /*! no static exports found */
711
- /***/ (function(module, exports, __webpack_require__) {
712
 
713
  "use strict";
714
-
715
-
716
- Object.defineProperty(exports, "__esModule", {
717
- value: true
718