LearnPress – WordPress LMS Plugin - Version 3.2.6.2

Version Description

~ Fixed cannt add items to course.

Download this release

Release Info

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

Code changes from version 3.2.6 to 3.2.6.2

assets/js/admin/admin.js CHANGED
@@ -44,6 +44,11 @@
44
  /******/ }
45
  /******/ };
46
  /******/
 
 
 
 
 
47
  /******/ // getDefaultExport function for compatibility with non-harmony modules
48
  /******/ __webpack_require__.n = function(module) {
49
  /******/ var getter = module && module.__esModule ?
@@ -59,19 +64,24 @@
59
  /******/ // __webpack_public_path__
60
  /******/ __webpack_require__.p = "";
61
  /******/
 
62
  /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 14);
64
  /******/ })
65
  /************************************************************************/
66
  /******/ ({
67
 
68
- /***/ 14:
 
 
 
 
69
  /***/ (function(module, exports, __webpack_require__) {
70
 
71
  "use strict";
72
 
73
 
74
- var _update = __webpack_require__(15);
75
 
76
  var _update2 = _interopRequireDefault(_update);
77
 
@@ -200,7 +210,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
200
 
201
  /***/ }),
202
 
203
- /***/ 15:
 
 
 
 
204
  /***/ (function(module, exports, __webpack_require__) {
205
 
206
  "use strict";
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 ?
64
  /******/ // __webpack_public_path__
65
  /******/ __webpack_require__.p = "";
66
  /******/
67
+ /******/
68
  /******/ // Load entry module and return exports
69
+ /******/ return __webpack_require__(__webpack_require__.s = "./assets/src/js/admin/admin.js");
70
  /******/ })
71
  /************************************************************************/
72
  /******/ ({
73
 
74
+ /***/ "./assets/src/js/admin/admin.js":
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
 
210
 
211
  /***/ }),
212
 
213
+ /***/ "./assets/src/js/admin/pages/update.js":
214
+ /*!*********************************************!*\
215
+ !*** ./assets/src/js/admin/pages/update.js ***!
216
+ \*********************************************/
217
+ /*! no static exports found */
218
  /***/ (function(module, exports, __webpack_require__) {
219
 
220
  "use strict";
assets/js/admin/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){function e(n){if(a[n])return a[n].exports;var s=a[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var a={};e.m=t,e.c=a,e.d=function(t,a,n){e.o(t,a)||Object.defineProperty(t,a,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,"a",a),a},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=14)}({14:function(t,e,a){"use strict";var n=a(15);!function(t){t&&t.__esModule}(n);!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)}})}}))}},i=function(t){return t.preventDefault(),!1},r=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]",i).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","")})};t(document).ready(r)}()},15:function(t,e,a){"use strict";!function(t){function e(){if(window.lpGlobalSettings=window.lpGlobalSettings||{},t("#learn-press-updater").length){new Vue(n)}}var a=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={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 n=this;t.ajax({url:lpGlobalSettings.admin_url,data:{"lp-ajax":"get-update-packages",force:this.force,_wpnonce:lpGlobalSettings._wpnonce},success:function(t){var s=LP.parseJSON(t);n.packages=new a(s),e&&e.call(n)}})},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 i=LP.parseJSON(s);t(n.$el).find(".updater-progress-status");if("yes"===i.done)n.update(100*n.packages.getPercentCompleted()),n.doUpdate();else{var r=100*n.packages.getPercentCompleted();if(i.percent){r+=1/n.packages.getTotal()*i.percent}n.update(r),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(e)}(jQuery)}});
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","")})})}()}});
assets/js/admin/conditional-logic.js CHANGED
@@ -44,6 +44,11 @@
44
  /******/ }
45
  /******/ };
46
  /******/
 
 
 
 
 
47
  /******/ // getDefaultExport function for compatibility with non-harmony modules
48
  /******/ __webpack_require__.n = function(module) {
49
  /******/ var getter = module && module.__esModule ?
@@ -59,13 +64,18 @@
59
  /******/ // __webpack_public_path__
60
  /******/ __webpack_require__.p = "";
61
  /******/
 
62
  /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 11);
64
  /******/ })
65
  /************************************************************************/
66
  /******/ ({
67
 
68
- /***/ 11:
 
 
 
 
69
  /***/ (function(module, exports, __webpack_require__) {
70
 
71
  "use strict";
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 ?
64
  /******/ // __webpack_public_path__
65
  /******/ __webpack_require__.p = "";
66
  /******/
67
+ /******/
68
  /******/ // Load entry module and return exports
69
+ /******/ return __webpack_require__(__webpack_require__.s = "./assets/src/js/admin/utils/conditional-logic.js");
70
  /******/ })
71
  /************************************************************************/
72
  /******/ ({
73
 
74
+ /***/ "./assets/src/js/admin/utils/conditional-logic.js":
75
+ /*!********************************************************!*\
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";
assets/js/admin/conditional-logic.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){function i(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,i),n.l=!0,n.exports}var t={};i.m=e,i.c=t,i.d=function(e,t,a){i.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:a})},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,i){return Object.prototype.hasOwnProperty.call(e,i)},i.p="",i(i.s=11)}({11: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,n=a.match(/rwmb-([^\s]*)-wrapper/);return!!n&&n[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,{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)}});
assets/js/admin/editor/course.js CHANGED
@@ -44,6 +44,11 @@
44
  /******/ }
45
  /******/ };
46
  /******/
 
 
 
 
 
47
  /******/ // getDefaultExport function for compatibility with non-harmony modules
48
  /******/ __webpack_require__.n = function(module) {
49
  /******/ var getter = module && module.__esModule ?
@@ -59,20 +64,18 @@
59
  /******/ // __webpack_public_path__
60
  /******/ __webpack_require__.p = "";
61
  /******/
 
62
  /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 28);
64
  /******/ })
65
  /************************************************************************/
66
- /******/ ([
67
- /* 0 */,
68
- /* 1 */,
69
- /* 2 */,
70
- /* 3 */,
71
- /* 4 */,
72
- /* 5 */,
73
- /* 6 */,
74
- /* 7 */,
75
- /* 8 */
76
  /***/ (function(module, exports, __webpack_require__) {
77
 
78
  "use strict";
@@ -81,304 +84,206 @@
81
  Object.defineProperty(exports, "__esModule", {
82
  value: true
83
  });
84
- exports.default = HTTP;
85
- function HTTP(options) {
86
- var $ = window.jQuery;
87
- var $VueHTTP = Vue.http;
88
-
89
- options = $.extend({
90
- ns: 'LPRequest',
91
- store: false
92
- }, options || {});
93
-
94
- var $publishingAction = null;
95
-
96
- LP.Request = function (payload) {
97
- $publishingAction = $('#publishing-action');
98
-
99
- payload['id'] = options.store.getters.id;
100
- payload['nonce'] = options.store.getters.nonce;
101
- payload['lp-ajax'] = options.store.getters.action;
102
- payload['code'] = options.store.getters.code;
103
-
104
- $publishingAction.find('#publish').addClass('disabled');
105
- $publishingAction.find('.spinner').addClass('is-active');
106
- $publishingAction.addClass('code-' + payload['code']);
107
-
108
- return $VueHTTP.post(options.store.getters.urlAjax, payload, {
109
- emulateJSON: true,
110
- params: {
111
- namespace: options.ns,
112
- code: payload['code']
113
- }
114
- });
115
- };
116
 
117
- $VueHTTP.interceptors.push(function (request, next) {
118
- if (request.params['namespace'] !== options.ns) {
119
- next();
120
- return;
121
  }
122
 
123
- options.store.dispatch('newRequest');
124
-
125
- next(function (response) {
126
- if (!jQuery.isPlainObject(response.body)) {
127
- response.body = LP.parseJSON(response.body);
128
- }
129
-
130
- var body = response.body;
131
- var result = body.success || false;
132
-
133
- if (result) {
134
- options.store.dispatch('requestCompleted', 'successful');
135
- } else {
136
- options.store.dispatch('requestCompleted', 'failed');
137
- }
138
- $publishingAction.removeClass('code-' + request.params.code);
139
- if (!$publishingAction.attr('class')) {
140
- $publishingAction.find('#publish').removeClass('disabled');
141
- $publishingAction.find('.spinner').removeClass('is-active');
142
- }
143
  });
144
- });
145
- }
146
-
147
- /***/ }),
148
- /* 9 */,
149
- /* 10 */,
150
- /* 11 */,
151
- /* 12 */
152
- /***/ (function(module, exports, __webpack_require__) {
153
-
154
- "use strict";
155
-
156
-
157
- Object.defineProperty(exports, "__esModule", {
158
- value: true
159
- });
160
- var $ = window.jQuery;
161
- var i18n = function i18n(i18n) {
162
- var state = $.extend({}, i18n);
163
- var getters = {
164
- all: function all(state) {
165
- return state;
166
- }
167
- };
168
-
169
- return {
170
- namespaced: true,
171
- state: state,
172
- getters: getters
173
- };
174
- };
175
-
176
- exports.default = i18n;
177
-
178
- /***/ }),
179
- /* 13 */,
180
- /* 14 */,
181
- /* 15 */,
182
- /* 16 */,
183
- /* 17 */,
184
- /* 18 */,
185
- /* 19 */,
186
- /* 20 */,
187
- /* 21 */,
188
- /* 22 */,
189
- /* 23 */,
190
- /* 24 */,
191
- /* 25 */,
192
- /* 26 */,
193
- /* 27 */,
194
- /* 28 */
195
- /***/ (function(module, exports, __webpack_require__) {
196
-
197
- "use strict";
198
-
199
-
200
- var _http = __webpack_require__(8);
201
-
202
- var _http2 = _interopRequireDefault(_http);
203
-
204
- var _course = __webpack_require__(29);
205
-
206
- var _course2 = _interopRequireDefault(_course);
207
-
208
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
209
-
210
- window.$Vue = window.$Vue || Vue;
211
- window.$Vuex = window.$Vuex || Vuex;
212
-
213
- var $ = window.jQuery;
214
-
215
- /**
216
- * Init app.
217
- *
218
- * @since 3.0.0
219
- */
220
- $(document).ready(function () {
221
-
222
- window.LP_Curriculum_Store = new $Vuex.Store((0, _course2.default)(lpAdminCourseEditorSettings));
223
- (0, _http2.default)({ ns: 'LPCurriculumRequest', store: LP_Curriculum_Store });
224
 
225
- setTimeout(function () {
226
- window.LP_Course_Editor = new $Vue({
227
- el: '#admin-editor-lp_course',
228
- template: '<lp-course-editor></lp-course-editor>'
 
 
 
 
 
 
229
  });
230
- }, 100);
231
- });
232
-
233
- /***/ }),
234
- /* 29 */
235
- /***/ (function(module, exports, __webpack_require__) {
236
-
237
- "use strict";
238
-
239
-
240
- Object.defineProperty(exports, "__esModule", {
241
- value: true
242
- });
243
-
244
- var _modalCourseItems = __webpack_require__(30);
245
-
246
- var _modalCourseItems2 = _interopRequireDefault(_modalCourseItems);
247
-
248
- var _courseSection = __webpack_require__(34);
249
-
250
- var _courseSection2 = _interopRequireDefault(_courseSection);
251
-
252
- var _i18n = __webpack_require__(12);
253
-
254
- var _i18n2 = _interopRequireDefault(_i18n);
255
-
256
- var _course = __webpack_require__(38);
257
-
258
- var _course2 = _interopRequireDefault(_course);
259
-
260
- var _course3 = __webpack_require__(39);
261
-
262
- var _course4 = _interopRequireDefault(_course3);
263
-
264
- var _course5 = __webpack_require__(40);
265
-
266
- var _course6 = _interopRequireDefault(_course5);
267
-
268
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
269
-
270
- var $ = window.jQuery;
271
- var Course = function Course(data) {
272
- var state = $.extend({}, data.root);
273
-
274
- state.status = 'success';
275
- state.heartbeat = true;
276
- state.countCurrentRequest = 0;
277
 
278
- return {
279
- state: state,
280
- getters: _course2.default,
281
- mutations: _course4.default,
282
- actions: _course6.default,
283
- modules: {
284
- ci: (0, _modalCourseItems2.default)(data),
285
- i18n: (0, _i18n2.default)(data.i18n),
286
- ss: (0, _courseSection2.default)(data)
287
  }
288
- };
289
- };
290
 
291
- exports.default = Course;
292
-
293
- /***/ }),
294
- /* 30 */
295
- /***/ (function(module, exports, __webpack_require__) {
296
-
297
- "use strict";
298
 
 
 
299
 
300
- Object.defineProperty(exports, "__esModule", {
301
- value: true
302
- });
 
 
 
 
 
 
303
 
304
- exports.default = function (data) {
305
- var state = $.extend({}, data.chooseItems);
306
- state.sectionId = false;
307
- state.pagination = '';
308
- state.status = '';
309
 
310
- return {
311
- namespaced: true,
312
- state: state,
313
- getters: _modalCourseItems2.default,
314
- mutations: _modalCourseItems4.default,
315
- actions: _modalCourseItems6.default
316
- };
317
- };
 
318
 
319
- var _modalCourseItems = __webpack_require__(31);
 
 
 
 
 
 
 
 
 
 
 
320
 
321
- var _modalCourseItems2 = _interopRequireDefault(_modalCourseItems);
 
322
 
323
- var _modalCourseItems3 = __webpack_require__(32);
 
324
 
325
- var _modalCourseItems4 = _interopRequireDefault(_modalCourseItems3);
 
 
 
 
 
 
326
 
327
- var _modalCourseItems5 = __webpack_require__(33);
 
328
 
329
- var _modalCourseItems6 = _interopRequireDefault(_modalCourseItems5);
 
 
 
330
 
331
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 
332
 
333
- var $ = jQuery;
 
 
334
 
335
- /***/ }),
336
- /* 31 */
337
- /***/ (function(module, exports, __webpack_require__) {
 
 
 
 
338
 
339
- "use strict";
 
 
 
 
 
 
 
 
 
 
 
340
 
 
 
 
 
 
 
 
 
 
 
 
 
341
 
342
- Object.defineProperty(exports, "__esModule", {
343
- value: true
344
- });
345
 
346
- var Getters = {
347
- status: function status(state) {
348
- return state.status;
349
- },
350
- pagination: function pagination(state) {
351
- return state.pagination;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
352
  },
353
- items: function items(state, _getters) {
354
- return state.items.map(function (item) {
355
- var find = _getters.addedItems.find(function (_item) {
356
- return item.id === _item.id;
357
- });
358
 
359
- item.added = !!find;
 
360
 
361
- return item;
 
 
 
 
 
 
 
 
 
 
 
 
362
  });
363
- },
364
- addedItems: function addedItems(state) {
365
- return state.addedItems;
366
- },
367
- isOpen: function isOpen(state) {
368
- return state.open;
369
- },
370
- types: function types(state) {
371
- return state.types;
372
- },
373
- section: function section() {
374
- return state.sectionId;
375
  }
376
  };
377
 
378
- exports.default = Getters;
379
 
380
  /***/ }),
381
- /* 32 */
 
 
 
 
 
382
  /***/ (function(module, exports, __webpack_require__) {
383
 
384
  "use strict";
@@ -387,48 +292,65 @@ exports.default = Getters;
387
  Object.defineProperty(exports, "__esModule", {
388
  value: true
389
  });
390
- var Mutations = {
391
- 'TOGGLE': function TOGGLE(state) {
392
- state.open = !state.open;
393
- },
394
- 'SET_SECTION': function SET_SECTION(state, sectionId) {
395
- state.sectionId = sectionId;
396
- },
397
- 'SET_LIST_ITEMS': function SET_LIST_ITEMS(state, items) {
398
- state.items = items;
399
- },
400
- 'ADD_ITEM': function ADD_ITEM(state, item) {
401
- state.addedItems.push(item);
402
- },
403
- 'REMOVE_ADDED_ITEM': function REMOVE_ADDED_ITEM(state, item) {
404
- state.addedItems.forEach(function (_item, index) {
405
- if (_item.id === item.id) {
406
- state.addedItems.splice(index, 1);
407
- }
408
  });
409
  },
410
- 'RESET': function RESET(state) {
411
- state.addedItems = [];
412
- state.items = [];
413
- },
414
- 'UPDATE_PAGINATION': function UPDATE_PAGINATION(state, pagination) {
415
- state.pagination = pagination;
416
- },
417
- 'SEARCH_ITEMS_REQUEST': function SEARCH_ITEMS_REQUEST(state) {
418
- state.status = 'loading';
 
 
 
 
 
 
 
 
 
419
  },
420
- 'SEARCH_ITEMS_SUCCESS': function SEARCH_ITEMS_SUCCESS(state) {
421
- state.status = 'successful';
 
 
 
 
 
 
422
  },
423
- 'SEARCH_ITEMS_FAILURE': function SEARCH_ITEMS_FAILURE(state) {
424
- state.status = 'failed';
 
 
 
 
 
 
425
  }
426
  };
427
 
428
- exports.default = Mutations;
429
 
430
  /***/ }),
431
- /* 33 */
 
 
 
 
 
432
  /***/ (function(module, exports, __webpack_require__) {
433
 
434
  "use strict";
@@ -515,60 +437,102 @@ var ModalCourseItems = {
515
  exports.default = ModalCourseItems;
516
 
517
  /***/ }),
518
- /* 34 */
 
 
 
 
 
519
  /***/ (function(module, exports, __webpack_require__) {
520
 
521
  "use strict";
522
 
523
 
524
- Object.defineProperty(exports, "__esModule", {
525
- value: true
526
- });
527
 
528
- exports.default = function (data) {
529
- var state = $.extend({}, data.sections);
530
 
531
- state.statusUpdateSection = {};
532
- state.statusUpdateSectionItem = {};
533
 
534
- state.sections = state.sections.map(function (section) {
535
- var hiddenSections = state.hidden_sections;
536
- var find = hiddenSections.find(function (sectionId) {
537
- return parseInt(section.id) === parseInt(sectionId);
538
- });
539
 
540
- section.open = !find;
541
 
542
- return section;
543
- });
544
 
545
- return {
546
- namespaced: true,
547
- state: state,
548
- getters: _courseSection6.default,
549
- mutations: _courseSection4.default,
550
- actions: _courseSection2.default
551
- };
552
- };
553
 
554
- var _courseSection = __webpack_require__(35);
 
 
 
 
 
555
 
556
- var _courseSection2 = _interopRequireDefault(_courseSection);
 
557
 
558
- var _courseSection3 = __webpack_require__(36);
 
 
 
 
 
 
559
 
560
- var _courseSection4 = _interopRequireDefault(_courseSection3);
561
 
562
- var _courseSection5 = __webpack_require__(37);
 
 
 
 
 
563
 
564
- var _courseSection6 = _interopRequireDefault(_courseSection5);
565
 
566
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
567
 
568
- var $ = jQuery;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
 
570
  /***/ }),
571
- /* 35 */
 
 
 
 
 
572
  /***/ (function(module, exports, __webpack_require__) {
573
 
574
  "use strict";
@@ -577,199 +541,173 @@ var $ = jQuery;
577
  Object.defineProperty(exports, "__esModule", {
578
  value: true
579
  });
580
- var CourseCurriculum = {
581
- toggleAllSections: function toggleAllSections(context) {
582
- var hidden = context.getters['isHiddenAllSections'];
583
-
584
- if (hidden) {
585
- context.commit('OPEN_ALL_SECTIONS');
586
- } else {
587
- context.commit('CLOSE_ALL_SECTIONS');
588
- }
589
-
590
- LP.Request({
591
- type: 'hidden-sections',
592
- hidden: context.getters['hiddenSections']
593
- });
594
  },
595
-
596
- updateSectionsOrder: function updateSectionsOrder(context, order) {
597
- LP.Request({
598
- type: 'sort-sections',
599
- order: JSON.stringify(order)
600
- }).then(function (response) {
601
- var result = response.body;
602
- var order_sections = result.data;
603
- context.commit('SORT_SECTION', order_sections);
604
- }, function (error) {
605
- console.error(error);
606
- });
 
 
 
 
 
 
 
 
607
  },
 
 
 
 
608
 
609
- toggleSection: function toggleSection(context, section) {
610
- if (section.open) {
611
- context.commit('CLOSE_SECTION', section);
612
- } else {
613
- context.commit('OPEN_SECTION', section);
614
- }
615
 
616
- LP.Request({
617
- type: 'hidden-sections',
618
- hidden: context.getters['hiddenSections']
619
- });
620
- },
621
 
622
- updateSection: function updateSection(context, section) {
623
- context.commit('UPDATE_SECTION_REQUEST', section.id);
 
 
 
 
624
 
625
- LP.Request({
626
- type: 'update-section',
627
- section: JSON.stringify(section)
628
- }).then(function () {
629
- context.commit('UPDATE_SECTION_SUCCESS', section.id);
630
- }).catch(function () {
631
- context.commit('UPDATE_SECTION_FAILURE', section.id);
632
- });
 
 
 
 
 
633
  },
 
 
 
 
 
634
 
635
- removeSection: function removeSection(context, payload) {
636
- context.commit('REMOVE_SECTION', payload.index);
637
 
638
- LP.Request({
639
- type: 'remove-section',
640
- section_id: payload.section.id
641
- }).then(function (response) {
642
- var result = response.body;
643
- }, function (error) {
644
- console.error(error);
645
  });
646
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
647
 
648
- newSection: function newSection(context, name) {
649
- var newSection = {
650
- type: 'new-section',
651
- section_name: name,
652
- temp_id: LP.uniqueId()
653
- };
654
- context.commit('ADD_NEW_SECTION', {
655
- id: newSection.temp_id,
656
- items: [],
657
- open: false,
658
- title: newSection.section_name
659
- });
660
 
661
- LP.Request(newSection).then(function (response) {
662
- var result = response.body;
663
 
664
- if (result.success) {
665
- var section = $.extend({}, result.data, { open: true });
 
 
 
 
666
 
667
- // update course section
668
- context.commit('ADD_NEW_SECTION', section);
669
- }
670
- }, function (error) {
671
- console.error(error);
672
- });
673
- },
674
 
675
- updateSectionItem: function updateSectionItem(context, payload) {
676
- context.commit('UPDATE_SECTION_ITEM_REQUEST', payload.item.id);
677
 
678
- LP.Request({
679
- type: 'update-section-item',
680
- section_id: payload.section_id,
681
- item: JSON.stringify(payload.item)
 
 
 
682
 
683
- }).then(function (response) {
684
- context.commit('UPDATE_SECTION_ITEM_SUCCESS', payload.item.id);
 
 
685
 
686
- var result = response.body;
687
- if (result.success) {
688
- var item = result.data;
689
 
690
- context.commit('UPDATE_SECTION_ITEM', { section_id: payload.section_id, item: item });
691
- }
692
- }, function (error) {
693
- context.commit('UPDATE_SECTION_ITEM_FAILURE', payload.item.id);
694
- console.error(error);
695
- });
696
- },
697
 
698
- removeSectionItem: function removeSectionItem(context, payload) {
699
- var id = payload.item.id;
700
- context.commit('REMOVE_SECTION_ITEM', payload);
701
- payload.item.temp_id = 0;
702
- LP.Request({
703
- type: 'remove-section-item',
704
- section_id: payload.section_id,
705
- item_id: id
706
- }).then(function () {
707
- context.commit('REMOVE_SECTION_ITEM', payload);
708
- });
709
- },
710
 
711
- deleteSectionItem: function deleteSectionItem(context, payload) {
712
- var id = payload.item.id;
713
- context.commit('REMOVE_SECTION_ITEM', payload);
714
- payload.item.temp_id = 0;
715
- LP.Request({
716
- type: 'delete-section-item',
717
- section_id: payload.section_id,
718
- item_id: id
719
- }).then(function () {
720
- context.commit('REMOVE_SECTION_ITEM', payload);
721
  });
722
- },
723
 
724
- newSectionItem: function newSectionItem(context, payload) {
 
 
 
 
725
 
726
- context.commit('APPEND_EMPTY_ITEM_TO_SECTION', payload);
727
- //context.commit('UPDATE_SECTION_ITEMS', {section_id: payload.section_id, items: result.data});
728
- LP.Request({
729
- type: 'new-section-item',
730
- section_id: payload.section_id,
731
- item: JSON.stringify(payload.item)
732
- }).then(function (response) {
733
- var result = response.body;
734
 
735
- if (result.success) {
736
- // context.commit('UPDATE_SECTION_ITEMS', {section_id: payload.section_id, items: result.data});
737
- var items = {};
738
- $.each(result.data, function (i, a) {
739
- items[a.old_id ? a.old_id : a.id] = a;
740
- });
741
- context.commit('UPDATE_ITEM_SECTION_BY_ID', {
742
- section_id: payload.section_id,
743
- items: items
744
- });
745
  }
746
- }, function (error) {
747
- console.error(error);
748
- });
749
- },
750
 
751
- updateSectionItems: function updateSectionItems(context, payload) {
752
- LP.Request({
753
- type: 'update-section-items',
754
- section_id: payload.section_id,
755
- items: JSON.stringify(payload.items),
756
- last_section: state.sections[state.sections.length - 1] === payload.section_id
757
- }).then(function (response) {
758
- var result = response.body;
759
 
760
- if (result.success) {
761
- // console.log(result);
 
 
 
 
 
 
 
762
  }
763
- }, function (error) {
764
- console.error(error);
765
  });
766
- }
767
- };
768
-
769
- exports.default = CourseCurriculum;
770
 
771
  /***/ }),
772
- /* 36 */
 
 
 
 
 
773
  /***/ (function(module, exports, __webpack_require__) {
774
 
775
  "use strict";
@@ -952,7 +890,12 @@ var CourseCurriculum = {
952
  exports.default = CourseCurriculum;
953
 
954
  /***/ }),
955
- /* 37 */
 
 
 
 
 
956
  /***/ (function(module, exports, __webpack_require__) {
957
 
958
  "use strict";
@@ -961,38 +904,39 @@ exports.default = CourseCurriculum;
961
  Object.defineProperty(exports, "__esModule", {
962
  value: true
963
  });
964
- var CourseCurriculum = {
965
- sections: function sections(state) {
966
- return state.sections || [];
967
- },
968
- urlEdit: function urlEdit(state) {
969
- return state.urlEdit;
970
- },
971
- hiddenSections: function hiddenSections(state) {
972
- return state.sections.filter(function (section) {
973
- return !section.open;
974
- }).map(function (section) {
975
- return parseInt(section.id);
976
- });
977
  },
978
- isHiddenAllSections: function isHiddenAllSections(state, getters) {
979
- var sections = getters['sections'];
980
- var hiddenSections = getters['hiddenSections'];
981
 
982
- return hiddenSections.length === sections.length;
 
983
  },
984
- statusUpdateSection: function statusUpdateSection(state) {
985
- return state.statusUpdateSection;
 
986
  },
987
- statusUpdateSectionItem: function statusUpdateSectionItem(state) {
988
- return state.statusUpdateSectionItem;
 
989
  }
990
  };
991
 
992
- exports.default = CourseCurriculum;
993
 
994
  /***/ }),
995
- /* 38 */
 
 
 
 
 
996
  /***/ (function(module, exports, __webpack_require__) {
997
 
998
  "use strict";
@@ -1001,40 +945,53 @@ exports.default = CourseCurriculum;
1001
  Object.defineProperty(exports, "__esModule", {
1002
  value: true
1003
  });
1004
- var Course = {
1005
- heartbeat: function heartbeat(state) {
1006
- return state.heartbeat;
1007
  },
1008
- action: function action(state) {
1009
- return state.action;
1010
  },
1011
- id: function id(state) {
1012
- return state.course_id;
1013
  },
1014
- autoDraft: function autoDraft(state) {
1015
- return state.auto_draft;
1016
  },
1017
- disable_curriculum: function disable_curriculum(state) {
1018
- return state.disable_curriculum;
 
 
 
 
1019
  },
1020
- status: function status(state) {
1021
- return state.status || 'error';
 
1022
  },
1023
- currentRequest: function currentRequest(state) {
1024
- return state.countCurrentRequest || 0;
1025
  },
1026
- urlAjax: function urlAjax(state) {
1027
- return state.ajax;
1028
  },
1029
- nonce: function nonce(state) {
1030
- return state.nonce;
 
 
 
1031
  }
1032
  };
1033
 
1034
- exports.default = Course;
1035
 
1036
  /***/ }),
1037
- /* 39 */
 
 
 
 
 
1038
  /***/ (function(module, exports, __webpack_require__) {
1039
 
1040
  "use strict";
@@ -1043,34 +1000,56 @@ exports.default = Course;
1043
  Object.defineProperty(exports, "__esModule", {
1044
  value: true
1045
  });
1046
- var Course = {
1047
 
1048
- 'UPDATE_HEART_BEAT': function UPDATE_HEART_BEAT(state, status) {
1049
- state.heartbeat = !!status;
1050
- },
1051
 
1052
- 'UPDATE_AUTO_DRAFT_STATUS': function UPDATE_AUTO_DRAFT_STATUS(state, status) {
1053
- // check auto draft status
1054
- state.auto_draft = status;
1055
- },
1056
 
1057
- 'UPDATE_STATUS': function UPDATE_STATUS(state, status) {
1058
- state.status = status;
1059
- },
 
 
1060
 
1061
- 'INCREASE_NUMBER_REQUEST': function INCREASE_NUMBER_REQUEST(state) {
1062
- state.countCurrentRequest++;
1063
- },
1064
 
1065
- 'DECREASE_NUMBER_REQUEST': function DECREASE_NUMBER_REQUEST(state) {
1066
- state.countCurrentRequest--;
1067
- }
 
 
 
 
 
 
 
1068
  };
1069
 
1070
- exports.default = Course;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1071
 
1072
  /***/ }),
1073
- /* 40 */
 
 
 
 
 
1074
  /***/ (function(module, exports, __webpack_require__) {
1075
 
1076
  "use strict";
@@ -1079,58 +1058,137 @@ exports.default = Course;
1079
  Object.defineProperty(exports, "__esModule", {
1080
  value: true
1081
  });
1082
- var Course = {
1083
- heartbeat: function heartbeat(context) {
1084
- LP.Request({
1085
- type: 'heartbeat'
1086
- }).then(function (response) {
1087
- var result = response.body;
1088
- context.commit('UPDATE_HEART_BEAT', !!result.success);
1089
- }, function (error) {
1090
- context.commit('UPDATE_HEART_BEAT', false);
1091
- });
1092
- },
1093
 
1094
- draftCourse: function draftCourse(context, payload) {
1095
- var auto_draft = context.getters['autoDraft'];
1096
 
1097
- if (auto_draft) {
1098
- LP.Request({
1099
- type: 'draft-course',
1100
- course: JSON.stringify(payload)
1101
- }).then(function (response) {
1102
- var result = response.body;
1103
 
1104
- if (!result.success) {
1105
- return;
1106
- }
1107
 
1108
- context.commit('UPDATE_AUTO_DRAFT_STATUS', false);
1109
- });
1110
- }
1111
- },
1112
 
1113
- newRequest: function newRequest(context) {
1114
- context.commit('INCREASE_NUMBER_REQUEST');
1115
- context.commit('UPDATE_STATUS', 'loading');
1116
 
1117
- window.onbeforeunload = function () {
1118
- return '';
1119
- };
1120
- },
1121
 
1122
- requestCompleted: function requestCompleted(context, status) {
1123
- context.commit('DECREASE_NUMBER_REQUEST');
1124
 
1125
- if (context.getters.currentRequest === 0) {
1126
- context.commit('UPDATE_STATUS', status);
1127
- window.onbeforeunload = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  }
1129
- }
1130
  };
1131
 
1132
  exports.default = Course;
1133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1134
  /***/ })
1135
- /******/ ]);
 
1136
  //# sourceMappingURL=course.js.map
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 ?
64
  /******/ // __webpack_public_path__
65
  /******/ __webpack_require__.p = "";
66
  /******/
67
+ /******/
68
  /******/ // Load entry module and return exports
69
+ /******/ return __webpack_require__(__webpack_require__.s = "./assets/src/js/admin/editor/course.js");
70
  /******/ })
71
  /************************************************************************/
72
+ /******/ ({
73
+
74
+ /***/ "./assets/src/js/admin/editor/actions/course-section.js":
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";
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
+
282
+ /***/ "./assets/src/js/admin/editor/actions/course.js":
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";
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
+
349
+ /***/ "./assets/src/js/admin/editor/actions/modal-course-items.js":
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";
437
  exports.default = ModalCourseItems;
438
 
439
  /***/ }),
440
+
441
+ /***/ "./assets/src/js/admin/editor/course.js":
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
+ /***/ }),
485
 
486
+ /***/ "./assets/src/js/admin/editor/getters/course-section.js":
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
+
531
+ /***/ "./assets/src/js/admin/editor/getters/course.js":
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";
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
 
578
+ /***/ "./assets/src/js/admin/editor/getters/modal-course-items.js":
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
 
628
+ /***/ "./assets/src/js/admin/editor/http.js":
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
  /***/ }),
705
+
706
+ /***/ "./assets/src/js/admin/editor/mutations/course-section.js":
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";
890
  exports.default = CourseCurriculum;
891
 
892
  /***/ }),
893
+
894
+ /***/ "./assets/src/js/admin/editor/mutations/course.js":
895
+ /*!********************************************************!*\
896
+ !*** ./assets/src/js/admin/editor/mutations/course.js ***!
897
+ \********************************************************/
898
+ /*! no static exports found */
899
  /***/ (function(module, exports, __webpack_require__) {
900
 
901
  "use strict";
904
  Object.defineProperty(exports, "__esModule", {
905
  value: true
906
  });
907
+ var Course = {
908
+
909
+ 'UPDATE_HEART_BEAT': function UPDATE_HEART_BEAT(state, status) {
910
+ state.heartbeat = !!status;
911
+ },
912
+
913
+ 'UPDATE_AUTO_DRAFT_STATUS': function UPDATE_AUTO_DRAFT_STATUS(state, status) {
914
+ // check auto draft status
915
+ state.auto_draft = status;
 
 
 
 
916
  },
 
 
 
917
 
918
+ 'UPDATE_STATUS': function UPDATE_STATUS(state, status) {
919
+ state.status = status;
920
  },
921
+
922
+ 'INCREASE_NUMBER_REQUEST': function INCREASE_NUMBER_REQUEST(state) {
923
+ state.countCurrentRequest++;
924
  },
925
+
926
+ 'DECREASE_NUMBER_REQUEST': function DECREASE_NUMBER_REQUEST(state) {
927
+ state.countCurrentRequest--;
928
  }
929
  };
930
 
931
+ exports.default = Course;
932
 
933
  /***/ }),
934
+
935
+ /***/ "./assets/src/js/admin/editor/mutations/modal-course-items.js":
936
+ /*!********************************************************************!*\
937
+ !*** ./assets/src/js/admin/editor/mutations/modal-course-items.js ***!
938
+ \********************************************************************/
939
+ /*! no static exports found */
940
  /***/ (function(module, exports, __webpack_require__) {
941
 
942
  "use strict";
945
  Object.defineProperty(exports, "__esModule", {
946
  value: true
947
  });
948
+ var Mutations = {
949
+ 'TOGGLE': function TOGGLE(state) {
950
+ state.open = !state.open;
951
  },
952
+ 'SET_SECTION': function SET_SECTION(state, sectionId) {
953
+ state.sectionId = sectionId;
954
  },
955
+ 'SET_LIST_ITEMS': function SET_LIST_ITEMS(state, items) {
956
+ state.items = items;
957
  },
958
+ 'ADD_ITEM': function ADD_ITEM(state, item) {
959
+ state.addedItems.push(item);
960
  },
961
+ 'REMOVE_ADDED_ITEM': function REMOVE_ADDED_ITEM(state, item) {
962
+ state.addedItems.forEach(function (_item, index) {
963
+ if (_item.id === item.id) {
964
+ state.addedItems.splice(index, 1);
965
+ }
966
+ });
967
  },
968
+ 'RESET': function RESET(state) {
969
+ state.addedItems = [];
970
+ state.items = [];
971
  },
972
+ 'UPDATE_PAGINATION': function UPDATE_PAGINATION(state, pagination) {
973
+ state.pagination = pagination;
974
  },
975
+ 'SEARCH_ITEMS_REQUEST': function SEARCH_ITEMS_REQUEST(state) {
976
+ state.status = 'loading';
977
  },
978
+ 'SEARCH_ITEMS_SUCCESS': function SEARCH_ITEMS_SUCCESS(state) {
979
+ state.status = 'successful';
980
+ },
981
+ 'SEARCH_ITEMS_FAILURE': function SEARCH_ITEMS_FAILURE(state) {
982
+ state.status = 'failed';
983
  }
984
  };
985
 
986
+ exports.default = Mutations;
987
 
988
  /***/ }),
989
+
990
+ /***/ "./assets/src/js/admin/editor/store/course-section.js":
991
+ /*!************************************************************!*\
992
+ !*** ./assets/src/js/admin/editor/store/course-section.js ***!
993
+ \************************************************************/
994
+ /*! no static exports found */
995
  /***/ (function(module, exports, __webpack_require__) {
996
 
997
  "use strict";
1000
  Object.defineProperty(exports, "__esModule", {
1001
  value: true
1002
  });
 
1003
 
1004
+ exports.default = function (data) {
1005
+ var state = $.extend({}, data.sections);
 
1006
 
1007
+ state.statusUpdateSection = {};
1008
+ state.statusUpdateSectionItem = {};
 
 
1009
 
1010
+ state.sections = state.sections.map(function (section) {
1011
+ var hiddenSections = state.hidden_sections;
1012
+ var find = hiddenSections.find(function (sectionId) {
1013
+ return parseInt(section.id) === parseInt(sectionId);
1014
+ });
1015
 
1016
+ section.open = !find;
 
 
1017
 
1018
+ return section;
1019
+ });
1020
+
1021
+ return {
1022
+ namespaced: true,
1023
+ state: state,
1024
+ getters: _courseSection6.default,
1025
+ mutations: _courseSection4.default,
1026
+ actions: _courseSection2.default
1027
+ };
1028
  };
1029
 
1030
+ var _courseSection = __webpack_require__(/*! ../actions/course-section */ "./assets/src/js/admin/editor/actions/course-section.js");
1031
+
1032
+ var _courseSection2 = _interopRequireDefault(_courseSection);
1033
+
1034
+ var _courseSection3 = __webpack_require__(/*! ../mutations/course-section */ "./assets/src/js/admin/editor/mutations/course-section.js");
1035
+
1036
+ var _courseSection4 = _interopRequireDefault(_courseSection3);
1037
+
1038
+ var _courseSection5 = __webpack_require__(/*! ../getters/course-section */ "./assets/src/js/admin/editor/getters/course-section.js");
1039
+
1040
+ var _courseSection6 = _interopRequireDefault(_courseSection5);
1041
+
1042
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1043
+
1044
+ var $ = jQuery;
1045
 
1046
  /***/ }),
1047
+
1048
+ /***/ "./assets/src/js/admin/editor/store/course.js":
1049
+ /*!****************************************************!*\
1050
+ !*** ./assets/src/js/admin/editor/store/course.js ***!
1051
+ \****************************************************/
1052
+ /*! no static exports found */
1053
  /***/ (function(module, exports, __webpack_require__) {
1054
 
1055
  "use strict";
1058
  Object.defineProperty(exports, "__esModule", {
1059
  value: true
1060
  });
 
 
 
 
 
 
 
 
 
 
 
1061
 
1062
+ var _modalCourseItems = __webpack_require__(/*! ../store/modal-course-items */ "./assets/src/js/admin/editor/store/modal-course-items.js");
 
1063
 
1064
+ var _modalCourseItems2 = _interopRequireDefault(_modalCourseItems);
 
 
 
 
 
1065
 
1066
+ var _courseSection = __webpack_require__(/*! ../store/course-section */ "./assets/src/js/admin/editor/store/course-section.js");
 
 
1067
 
1068
+ var _courseSection2 = _interopRequireDefault(_courseSection);
 
 
 
1069
 
1070
+ var _i18n = __webpack_require__(/*! ../store/i18n */ "./assets/src/js/admin/editor/store/i18n.js");
 
 
1071
 
1072
+ var _i18n2 = _interopRequireDefault(_i18n);
 
 
 
1073
 
1074
+ var _course = __webpack_require__(/*! ../getters/course */ "./assets/src/js/admin/editor/getters/course.js");
 
1075
 
1076
+ var _course2 = _interopRequireDefault(_course);
1077
+
1078
+ var _course3 = __webpack_require__(/*! ../mutations/course */ "./assets/src/js/admin/editor/mutations/course.js");
1079
+
1080
+ var _course4 = _interopRequireDefault(_course3);
1081
+
1082
+ var _course5 = __webpack_require__(/*! ../actions/course */ "./assets/src/js/admin/editor/actions/course.js");
1083
+
1084
+ var _course6 = _interopRequireDefault(_course5);
1085
+
1086
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1087
+
1088
+ var $ = window.jQuery;
1089
+ var Course = function Course(data) {
1090
+ var state = $.extend({}, data.root);
1091
+
1092
+ state.status = 'success';
1093
+ state.heartbeat = true;
1094
+ state.countCurrentRequest = 0;
1095
+
1096
+ return {
1097
+ state: state,
1098
+ getters: _course2.default,
1099
+ mutations: _course4.default,
1100
+ actions: _course6.default,
1101
+ modules: {
1102
+ ci: (0, _modalCourseItems2.default)(data),
1103
+ i18n: (0, _i18n2.default)(data.i18n),
1104
+ ss: (0, _courseSection2.default)(data)
1105
  }
1106
+ };
1107
  };
1108
 
1109
  exports.default = Course;
1110
 
1111
+ /***/ }),
1112
+
1113
+ /***/ "./assets/src/js/admin/editor/store/i18n.js":
1114
+ /*!**************************************************!*\
1115
+ !*** ./assets/src/js/admin/editor/store/i18n.js ***!
1116
+ \**************************************************/
1117
+ /*! no static exports found */
1118
+ /***/ (function(module, exports, __webpack_require__) {
1119
+
1120
+ "use strict";
1121
+
1122
+
1123
+ Object.defineProperty(exports, "__esModule", {
1124
+ value: true
1125
+ });
1126
+ var $ = window.jQuery;
1127
+ var i18n = function i18n(i18n) {
1128
+ var state = $.extend({}, i18n);
1129
+ var getters = {
1130
+ all: function all(state) {
1131
+ return state;
1132
+ }
1133
+ };
1134
+
1135
+ return {
1136
+ namespaced: true,
1137
+ state: state,
1138
+ getters: getters
1139
+ };
1140
+ };
1141
+
1142
+ exports.default = i18n;
1143
+
1144
+ /***/ }),
1145
+
1146
+ /***/ "./assets/src/js/admin/editor/store/modal-course-items.js":
1147
+ /*!****************************************************************!*\
1148
+ !*** ./assets/src/js/admin/editor/store/modal-course-items.js ***!
1149
+ \****************************************************************/
1150
+ /*! no static exports found */
1151
+ /***/ (function(module, exports, __webpack_require__) {
1152
+
1153
+ "use strict";
1154
+
1155
+
1156
+ Object.defineProperty(exports, "__esModule", {
1157
+ value: true
1158
+ });
1159
+
1160
+ exports.default = function (data) {
1161
+ var state = $.extend({}, data.chooseItems);
1162
+ state.sectionId = false;
1163
+ state.pagination = '';
1164
+ state.status = '';
1165
+
1166
+ return {
1167
+ namespaced: true,
1168
+ state: state,
1169
+ getters: _modalCourseItems2.default,
1170
+ mutations: _modalCourseItems4.default,
1171
+ actions: _modalCourseItems6.default
1172
+ };
1173
+ };
1174
+
1175
+ var _modalCourseItems = __webpack_require__(/*! ../getters/modal-course-items */ "./assets/src/js/admin/editor/getters/modal-course-items.js");
1176
+
1177
+ var _modalCourseItems2 = _interopRequireDefault(_modalCourseItems);
1178
+
1179
+ var _modalCourseItems3 = __webpack_require__(/*! ../mutations/modal-course-items */ "./assets/src/js/admin/editor/mutations/modal-course-items.js");
1180
+
1181
+ var _modalCourseItems4 = _interopRequireDefault(_modalCourseItems3);
1182
+
1183
+ var _modalCourseItems5 = __webpack_require__(/*! ../actions/modal-course-items */ "./assets/src/js/admin/editor/actions/modal-course-items.js");
1184
+
1185
+ var _modalCourseItems6 = _interopRequireDefault(_modalCourseItems5);
1186
+
1187
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1188
+
1189
+ var $ = jQuery;
1190
+
1191
  /***/ })
1192
+
1193
+ /******/ });
1194
  //# sourceMappingURL=course.js.map
assets/js/admin/editor/course.min.js CHANGED
@@ -1 +1 @@
1
- !function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=28)}([,,,,,,,,function(t,e,n){"use strict";function i(t){var e=window.jQuery,n=Vue.http;t=e.extend({ns:"LPRequest",store:!1},t||{});var i=null;LP.Request=function(o){return i=e("#publishing-action"),o.id=t.store.getters.id,o.nonce=t.store.getters.nonce,o["lp-ajax"]=t.store.getters.action,o.code=t.store.getters.code,i.find("#publish").addClass("disabled"),i.find(".spinner").addClass("is-active"),i.addClass("code-"+o.code),n.post(t.store.getters.urlAjax,o,{emulateJSON:!0,params:{namespace:t.ns,code:o.code}})},n.interceptors.push(function(e,n){if(e.params.namespace!==t.ns)return void n();t.store.dispatch("newRequest"),n(function(n){jQuery.isPlainObject(n.body)||(n.body=LP.parseJSON(n.body)),n.body.success?t.store.dispatch("requestCompleted","successful"):t.store.dispatch("requestCompleted","failed"),i.removeClass("code-"+e.params.code),i.attr("class")||(i.find("#publish").removeClass("disabled"),i.find(".spinner").removeClass("is-active"))})})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i},,,,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=window.jQuery,o=function(t){return{namespaced:!0,state:i.extend({},t),getters:{all:function(t){return t}}}};e.default=o},,,,,,,,,,,,,,,,function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}var o=n(8),s=i(o),u=n(29),c=i(u);window.$Vue=window.$Vue||Vue,window.$Vuex=window.$Vuex||Vuex,(0,window.jQuery)(document).ready(function(){window.LP_Curriculum_Store=new $Vuex.Store((0,c.default)(lpAdminCourseEditorSettings)),(0,s.default)({ns:"LPCurriculumRequest",store:LP_Curriculum_Store}),setTimeout(function(){window.LP_Course_Editor=new $Vue({el:"#admin-editor-lp_course",template:"<lp-course-editor></lp-course-editor>"})},100)})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(30),s=i(o),u=n(34),c=i(u),r=n(12),d=i(r),a=n(38),f=i(a),_=n(39),E=i(_),m=n(40),S=i(m),l=window.jQuery,T=function(t){var e=l.extend({},t.root);return e.status="success",e.heartbeat=!0,e.countCurrentRequest=0,{state:e,getters:f.default,mutations:E.default,actions:S.default,modules:{ci:(0,s.default)(t),i18n:(0,d.default)(t.i18n),ss:(0,c.default)(t)}}};e.default=T},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=a.extend({},t.chooseItems);return e.sectionId=!1,e.pagination="",e.status="",{namespaced:!0,state:e,getters:s.default,mutations:c.default,actions:d.default}};var o=n(31),s=i(o),u=n(32),c=i(u),r=n(33),d=i(r),a=jQuery},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={status:function(t){return t.status},pagination:function(t){return t.pagination},items:function(t,e){return t.items.map(function(t){var n=e.addedItems.find(function(e){return t.id===e.id});return t.added=!!n,t})},addedItems:function(t){return t.addedItems},isOpen:function(t){return t.open},types:function(t){return t.types},section:function(){return state.sectionId}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={TOGGLE:function(t){t.open=!t.open},SET_SECTION:function(t,e){t.sectionId=e},SET_LIST_ITEMS:function(t,e){t.items=e},ADD_ITEM:function(t,e){t.addedItems.push(e)},REMOVE_ADDED_ITEM:function(t,e){t.addedItems.forEach(function(n,i){n.id===e.id&&t.addedItems.splice(i,1)})},RESET:function(t){t.addedItems=[],t.items=[]},UPDATE_PAGINATION:function(t,e){t.pagination=e},SEARCH_ITEMS_REQUEST:function(t){t.status="loading"},SEARCH_ITEMS_SUCCESS:function(t){t.status="successful"},SEARCH_ITEMS_FAILURE:function(t){t.status="failed"}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={toggle:function(t){t.commit("TOGGLE")},open:function(t,e){t.commit("SET_SECTION",e),t.commit("RESET"),t.commit("TOGGLE")},searchItems:function(t,e){t.commit("SEARCH_ITEMS_REQUEST"),LP.Request({type:"search-items",query:e.query,item_type:e.type,page:e.page,exclude:JSON.stringify([])}).then(function(e){var n=e.body;if(n.success){var i=n.data;t.commit("SET_LIST_ITEMS",i.items),t.commit("UPDATE_PAGINATION",i.pagination),t.commit("SEARCH_ITEMS_SUCCESS")}},function(e){t.commit("SEARCH_ITEMS_FAILURE"),console.error(e)})},addItem:function(t,e){t.commit("ADD_ITEM",e)},removeItem:function(t,e){t.commit("REMOVE_ADDED_ITEM",e)},addItemsToSection:function(t){var e=t.getters.addedItems;e.length>0&&LP.Request({type:"add-items-to-section",section_id:t.getters.section,items:JSON.stringify(e)}).then(function(e){var n=e.body;if(n.success){t.commit("TOGGLE");var i=n.data;t.commit("ss/UPDATE_SECTION_ITEMS",{section_id:t.getters.section,items:i},{root:!0})}},function(t){console.error(t)})}};e.default=i},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=a.extend({},t.sections);return e.statusUpdateSection={},e.statusUpdateSectionItem={},e.sections=e.sections.map(function(t){var n=e.hidden_sections,i=n.find(function(e){return parseInt(t.id)===parseInt(e)});return t.open=!i,t}),{namespaced:!0,state:e,getters:d.default,mutations:c.default,actions:s.default}};var o=n(35),s=i(o),u=n(36),c=i(u),r=n(37),d=i(r),a=jQuery},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={toggleAllSections:function(t){t.getters.isHiddenAllSections?t.commit("OPEN_ALL_SECTIONS"):t.commit("CLOSE_ALL_SECTIONS"),LP.Request({type:"hidden-sections",hidden:t.getters.hiddenSections})},updateSectionsOrder:function(t,e){LP.Request({type:"sort-sections",order:JSON.stringify(e)}).then(function(e){var n=e.body,i=n.data;t.commit("SORT_SECTION",i)},function(t){console.error(t)})},toggleSection:function(t,e){e.open?t.commit("CLOSE_SECTION",e):t.commit("OPEN_SECTION",e),LP.Request({type:"hidden-sections",hidden:t.getters.hiddenSections})},updateSection:function(t,e){t.commit("UPDATE_SECTION_REQUEST",e.id),LP.Request({type:"update-section",section:JSON.stringify(e)}).then(function(){t.commit("UPDATE_SECTION_SUCCESS",e.id)}).catch(function(){t.commit("UPDATE_SECTION_FAILURE",e.id)})},removeSection:function(t,e){t.commit("REMOVE_SECTION",e.index),LP.Request({type:"remove-section",section_id:e.section.id}).then(function(t){t.body},function(t){console.error(t)})},newSection:function(t,e){var n={type:"new-section",section_name:e,temp_id:LP.uniqueId()};t.commit("ADD_NEW_SECTION",{id:n.temp_id,items:[],open:!1,title:n.section_name}),LP.Request(n).then(function(e){var n=e.body;if(n.success){var i=$.extend({},n.data,{open:!0});t.commit("ADD_NEW_SECTION",i)}},function(t){console.error(t)})},updateSectionItem:function(t,e){t.commit("UPDATE_SECTION_ITEM_REQUEST",e.item.id),LP.Request({type:"update-section-item",section_id:e.section_id,item:JSON.stringify(e.item)}).then(function(n){t.commit("UPDATE_SECTION_ITEM_SUCCESS",e.item.id);var i=n.body;if(i.success){var o=i.data;t.commit("UPDATE_SECTION_ITEM",{section_id:e.section_id,item:o})}},function(n){t.commit("UPDATE_SECTION_ITEM_FAILURE",e.item.id),console.error(n)})},removeSectionItem:function(t,e){var n=e.item.id;t.commit("REMOVE_SECTION_ITEM",e),e.item.temp_id=0,LP.Request({type:"remove-section-item",section_id:e.section_id,item_id:n}).then(function(){t.commit("REMOVE_SECTION_ITEM",e)})},deleteSectionItem:function(t,e){var n=e.item.id;t.commit("REMOVE_SECTION_ITEM",e),e.item.temp_id=0,LP.Request({type:"delete-section-item",section_id:e.section_id,item_id:n}).then(function(){t.commit("REMOVE_SECTION_ITEM",e)})},newSectionItem:function(t,e){t.commit("APPEND_EMPTY_ITEM_TO_SECTION",e),LP.Request({type:"new-section-item",section_id:e.section_id,item:JSON.stringify(e.item)}).then(function(n){var i=n.body;if(i.success){var o={};$.each(i.data,function(t,e){o[e.old_id?e.old_id:e.id]=e}),t.commit("UPDATE_ITEM_SECTION_BY_ID",{section_id:e.section_id,items:o})}},function(t){console.error(t)})},updateSectionItems:function(t,e){LP.Request({type:"update-section-items",section_id:e.section_id,items:JSON.stringify(e.items),last_section:state.sections[state.sections.length-1]===e.section_id}).then(function(t){t.body.success},function(t){console.error(t)})}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={SORT_SECTION:function(t,e){t.sections=t.sections.map(function(t){return t.order=e[t.id],t})},SET_SECTIONS:function(t,e){t.sections=e},ADD_NEW_SECTION:function(t,e){void 0===e.open&&(e.open=!0);var n;e.temp_id&&t.sections.map(function(t,i){if(e.temp_id==t.id)return n=i,!1}),void 0!==n?$Vue.set(t.sections,n,e):t.sections.push(e)},ADD_EMPTY_SECTION:function(t,e){e.open=!0,t.sections.push(e)},REMOVE_SECTION:function(t,e){t.sections.splice(e,1)},REMOVE_SECTION_ITEM:function(t,e){var n=t.sections.find(function(t){return t.id===e.section_id}),i=n.items||[],o=e.item,s=-1;i.forEach(function(t,e){t.id===o.id&&(s=e)}),-1!==s&&(o.temp_id?i[s].id=o.temp_id:i.splice(s,1))},UPDATE_SECTION_ITEMS:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});n&&(n.items=e.items)},UPDATE_SECTION_ITEM:function(t,e){},CLOSE_SECTION:function(t,e){t.sections.forEach(function(n,i){e.id===n.id&&(t.sections[i].open=!1)})},OPEN_SECTION:function(t,e){t.sections.forEach(function(n,i){e.id===n.id&&(t.sections[i].open=!0)})},OPEN_ALL_SECTIONS:function(t){t.sections=t.sections.map(function(t){return t.open=!0,t})},CLOSE_ALL_SECTIONS:function(t){t.sections=t.sections.map(function(t){return t.open=!1,t})},UPDATE_SECTION_REQUEST:function(t,e){$Vue.set(t.statusUpdateSection,e,"updating")},UPDATE_SECTION_SUCCESS:function(t,e){$Vue.set(t.statusUpdateSection,e,"successful")},UPDATE_SECTION_FAILURE:function(t,e){$Vue.set(t.statusUpdateSection,e,"failed")},UPDATE_SECTION_ITEM_REQUEST:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"updating")},UPDATE_SECTION_ITEM_SUCCESS:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"successful")},UPDATE_SECTION_ITEM_FAILURE:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"failed")},APPEND_EMPTY_ITEM_TO_SECTION:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});n&&n.items.push({id:e.item.id,title:e.item.title,type:"empty-item"})},UPDATE_ITEM_SECTION_BY_ID:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});if(n)for(var i=0;i<n.items.length;i++)try{if(!n.items[i])continue;var o=n.items[i].id;o&&e.items[o]&&$Vue.set(n.items,i,e.items[o])}catch(t){console.log(t)}}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={sections:function(t){return t.sections||[]},urlEdit:function(t){return t.urlEdit},hiddenSections:function(t){return t.sections.filter(function(t){return!t.open}).map(function(t){return parseInt(t.id)})},isHiddenAllSections:function(t,e){var n=e.sections;return e.hiddenSections.length===n.length},statusUpdateSection:function(t){return t.statusUpdateSection},statusUpdateSectionItem:function(t){return t.statusUpdateSectionItem}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={heartbeat:function(t){return t.heartbeat},action:function(t){return t.action},id:function(t){return t.course_id},autoDraft:function(t){return t.auto_draft},disable_curriculum:function(t){return t.disable_curriculum},status:function(t){return t.status||"error"},currentRequest:function(t){return t.countCurrentRequest||0},urlAjax:function(t){return t.ajax},nonce:function(t){return t.nonce}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={UPDATE_HEART_BEAT:function(t,e){t.heartbeat=!!e},UPDATE_AUTO_DRAFT_STATUS:function(t,e){t.auto_draft=e},UPDATE_STATUS:function(t,e){t.status=e},INCREASE_NUMBER_REQUEST:function(t){t.countCurrentRequest++},DECREASE_NUMBER_REQUEST:function(t){t.countCurrentRequest--}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={heartbeat:function(t){LP.Request({type:"heartbeat"}).then(function(e){var n=e.body;t.commit("UPDATE_HEART_BEAT",!!n.success)},function(e){t.commit("UPDATE_HEART_BEAT",!1)})},draftCourse:function(t,e){t.getters.autoDraft&&LP.Request({type:"draft-course",course:JSON.stringify(e)}).then(function(e){e.body.success&&t.commit("UPDATE_AUTO_DRAFT_STATUS",!1)})},newRequest:function(t){t.commit("INCREASE_NUMBER_REQUEST"),t.commit("UPDATE_STATUS","loading"),window.onbeforeunload=function(){return""}},requestCompleted:function(t,e){t.commit("DECREASE_NUMBER_REQUEST"),0===t.getters.currentRequest&&(t.commit("UPDATE_STATUS",e),window.onbeforeunload=null)}};e.default=i}]);
1
+ !function(t){var e={};function n(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=48)}([,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=window.jQuery,n=Vue.http;t=e.extend({ns:"LPRequest",store:!1},t||{});var i=null;LP.Request=function(o){return i=e("#publishing-action"),o.id=t.store.getters.id,o.nonce=t.store.getters.nonce,o["lp-ajax"]=t.store.getters.action,o.code=t.store.getters.code,i.find("#publish").addClass("disabled"),i.find(".spinner").addClass("is-active"),i.addClass("code-"+o.code),n.post(t.store.getters.urlAjax,o,{emulateJSON:!0,params:{namespace:t.ns,code:o.code}})},n.interceptors.push(function(e,n){e.params.namespace===t.ns?(t.store.dispatch("newRequest"),n(function(n){jQuery.isPlainObject(n.body)||(n.body=LP.parseJSON(n.body));var o=n.body,s=o.success||!1;s?t.store.dispatch("requestCompleted","successful"):t.store.dispatch("requestCompleted","failed"),i.removeClass("code-"+e.params.code),i.attr("class")||(i.find("#publish").removeClass("disabled"),i.find(".spinner").removeClass("is-active"))})):n()})}},,,,,,,,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=window.jQuery;e.default=function(t){return{namespaced:!0,state:i.extend({},t),getters:{all:function(t){return t}}}}},,,,,,,,,,,,,,,,,,,,,,,,,,,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={heartbeat:function(t){LP.Request({type:"heartbeat"}).then(function(e){var n=e.body;t.commit("UPDATE_HEART_BEAT",!!n.success)},function(e){t.commit("UPDATE_HEART_BEAT",!1)})},draftCourse:function(t,e){t.getters.autoDraft&&LP.Request({type:"draft-course",course:JSON.stringify(e)}).then(function(e){e.body.success&&t.commit("UPDATE_AUTO_DRAFT_STATUS",!1)})},newRequest:function(t){t.commit("INCREASE_NUMBER_REQUEST"),t.commit("UPDATE_STATUS","loading"),window.onbeforeunload=function(){return""}},requestCompleted:function(t,e){t.commit("DECREASE_NUMBER_REQUEST"),0===t.getters.currentRequest&&(t.commit("UPDATE_STATUS",e),window.onbeforeunload=null)}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={UPDATE_HEART_BEAT:function(t,e){t.heartbeat=!!e},UPDATE_AUTO_DRAFT_STATUS:function(t,e){t.auto_draft=e},UPDATE_STATUS:function(t,e){t.status=e},INCREASE_NUMBER_REQUEST:function(t){t.countCurrentRequest++},DECREASE_NUMBER_REQUEST:function(t){t.countCurrentRequest--}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={heartbeat:function(t){return t.heartbeat},action:function(t){return t.action},id:function(t){return t.course_id},autoDraft:function(t){return t.auto_draft},disable_curriculum:function(t){return t.disable_curriculum},status:function(t){return t.status||"error"},currentRequest:function(t){return t.countCurrentRequest||0},urlAjax:function(t){return t.ajax},nonce:function(t){return t.nonce}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={sections:function(t){return t.sections||[]},urlEdit:function(t){return t.urlEdit},hiddenSections:function(t){return t.sections.filter(function(t){return!t.open}).map(function(t){return parseInt(t.id)})},isHiddenAllSections:function(t,e){var n=e.sections;return e.hiddenSections.length===n.length},statusUpdateSection:function(t){return t.statusUpdateSection},statusUpdateSectionItem:function(t){return t.statusUpdateSectionItem}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={SORT_SECTION:function(t,e){t.sections=t.sections.map(function(t){return t.order=e[t.id],t})},SET_SECTIONS:function(t,e){t.sections=e},ADD_NEW_SECTION:function(t,e){var n;void 0===e.open&&(e.open=!0),e.temp_id&&t.sections.map(function(t,i){if(e.temp_id==t.id)return n=i,!1}),void 0!==n?$Vue.set(t.sections,n,e):t.sections.push(e)},ADD_EMPTY_SECTION:function(t,e){e.open=!0,t.sections.push(e)},REMOVE_SECTION:function(t,e){t.sections.splice(e,1)},REMOVE_SECTION_ITEM:function(t,e){var n=t.sections.find(function(t){return t.id===e.section_id}).items||[],i=e.item,o=-1;n.forEach(function(t,e){t.id===i.id&&(o=e)}),-1!==o&&(i.temp_id?n[o].id=i.temp_id:n.splice(o,1))},UPDATE_SECTION_ITEMS:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});n&&(n.items=e.items)},UPDATE_SECTION_ITEM:function(t,e){},CLOSE_SECTION:function(t,e){t.sections.forEach(function(n,i){e.id===n.id&&(t.sections[i].open=!1)})},OPEN_SECTION:function(t,e){t.sections.forEach(function(n,i){e.id===n.id&&(t.sections[i].open=!0)})},OPEN_ALL_SECTIONS:function(t){t.sections=t.sections.map(function(t){return t.open=!0,t})},CLOSE_ALL_SECTIONS:function(t){t.sections=t.sections.map(function(t){return t.open=!1,t})},UPDATE_SECTION_REQUEST:function(t,e){$Vue.set(t.statusUpdateSection,e,"updating")},UPDATE_SECTION_SUCCESS:function(t,e){$Vue.set(t.statusUpdateSection,e,"successful")},UPDATE_SECTION_FAILURE:function(t,e){$Vue.set(t.statusUpdateSection,e,"failed")},UPDATE_SECTION_ITEM_REQUEST:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"updating")},UPDATE_SECTION_ITEM_SUCCESS:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"successful")},UPDATE_SECTION_ITEM_FAILURE:function(t,e){$Vue.set(t.statusUpdateSectionItem,e,"failed")},APPEND_EMPTY_ITEM_TO_SECTION:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});n&&n.items.push({id:e.item.id,title:e.item.title,type:"empty-item"})},UPDATE_ITEM_SECTION_BY_ID:function(t,e){var n=t.sections.find(function(t){return parseInt(t.id)===parseInt(e.section_id)});if(n)for(var i=0;i<n.items.length;i++)try{if(!n.items[i])continue;var o=n.items[i].id;o&&e.items[o]&&$Vue.set(n.items,i,e.items[o])}catch(t){console.log(t)}}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={toggleAllSections:function(t){t.getters.isHiddenAllSections?t.commit("OPEN_ALL_SECTIONS"):t.commit("CLOSE_ALL_SECTIONS"),LP.Request({type:"hidden-sections",hidden:t.getters.hiddenSections})},updateSectionsOrder:function(t,e){LP.Request({type:"sort-sections",order:JSON.stringify(e)}).then(function(e){var n=e.body.data;t.commit("SORT_SECTION",n)},function(t){console.error(t)})},toggleSection:function(t,e){e.open?t.commit("CLOSE_SECTION",e):t.commit("OPEN_SECTION",e),LP.Request({type:"hidden-sections",hidden:t.getters.hiddenSections})},updateSection:function(t,e){t.commit("UPDATE_SECTION_REQUEST",e.id),LP.Request({type:"update-section",section:JSON.stringify(e)}).then(function(){t.commit("UPDATE_SECTION_SUCCESS",e.id)}).catch(function(){t.commit("UPDATE_SECTION_FAILURE",e.id)})},removeSection:function(t,e){t.commit("REMOVE_SECTION",e.index),LP.Request({type:"remove-section",section_id:e.section.id}).then(function(t){t.body},function(t){console.error(t)})},newSection:function(t,e){var n={type:"new-section",section_name:e,temp_id:LP.uniqueId()};t.commit("ADD_NEW_SECTION",{id:n.temp_id,items:[],open:!1,title:n.section_name}),LP.Request(n).then(function(e){var n=e.body;if(n.success){var i=$.extend({},n.data,{open:!0});t.commit("ADD_NEW_SECTION",i)}},function(t){console.error(t)})},updateSectionItem:function(t,e){t.commit("UPDATE_SECTION_ITEM_REQUEST",e.item.id),LP.Request({type:"update-section-item",section_id:e.section_id,item:JSON.stringify(e.item)}).then(function(n){t.commit("UPDATE_SECTION_ITEM_SUCCESS",e.item.id);var i=n.body;if(i.success){var o=i.data;t.commit("UPDATE_SECTION_ITEM",{section_id:e.section_id,item:o})}},function(n){t.commit("UPDATE_SECTION_ITEM_FAILURE",e.item.id),console.error(n)})},removeSectionItem:function(t,e){var n=e.item.id;t.commit("REMOVE_SECTION_ITEM",e),e.item.temp_id=0,LP.Request({type:"remove-section-item",section_id:e.section_id,item_id:n}).then(function(){t.commit("REMOVE_SECTION_ITEM",e)})},deleteSectionItem:function(t,e){var n=e.item.id;t.commit("REMOVE_SECTION_ITEM",e),e.item.temp_id=0,LP.Request({type:"delete-section-item",section_id:e.section_id,item_id:n}).then(function(){t.commit("REMOVE_SECTION_ITEM",e)})},newSectionItem:function(t,e){t.commit("APPEND_EMPTY_ITEM_TO_SECTION",e),LP.Request({type:"new-section-item",section_id:e.section_id,item:JSON.stringify(e.item)}).then(function(n){var i=n.body;if(i.success){var o={};$.each(i.data,function(t,e){o[e.old_id?e.old_id:e.id]=e}),t.commit("UPDATE_ITEM_SECTION_BY_ID",{section_id:e.section_id,items:o})}},function(t){console.error(t)})},updateSectionItems:function(t,e){var n=t.state;LP.Request({type:"update-section-items",section_id:e.section_id,items:JSON.stringify(e.items),last_section:n.sections[n.sections.length-1]===e.section_id}).then(function(t){t.body.success},function(t){console.error(t)})}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=c.extend({},t.sections);return e.statusUpdateSection={},e.statusUpdateSectionItem={},e.sections=e.sections.map(function(t){var n=e.hidden_sections.find(function(e){return parseInt(t.id)===parseInt(e)});return t.open=!n,t}),{namespaced:!0,state:e,getters:s.default,mutations:o.default,actions:i.default}};var i=u(n(41)),o=u(n(40)),s=u(n(39));function u(t){return t&&t.__esModule?t:{default:t}}var c=jQuery},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={toggle:function(t){t.commit("TOGGLE")},open:function(t,e){t.commit("SET_SECTION",e),t.commit("RESET"),t.commit("TOGGLE")},searchItems:function(t,e){t.commit("SEARCH_ITEMS_REQUEST"),LP.Request({type:"search-items",query:e.query,item_type:e.type,page:e.page,exclude:JSON.stringify([])}).then(function(e){var n=e.body;if(n.success){var i=n.data;t.commit("SET_LIST_ITEMS",i.items),t.commit("UPDATE_PAGINATION",i.pagination),t.commit("SEARCH_ITEMS_SUCCESS")}},function(e){t.commit("SEARCH_ITEMS_FAILURE"),console.error(e)})},addItem:function(t,e){t.commit("ADD_ITEM",e)},removeItem:function(t,e){t.commit("REMOVE_ADDED_ITEM",e)},addItemsToSection:function(t){var e=t.getters.addedItems;e.length>0&&LP.Request({type:"add-items-to-section",section_id:t.getters.section,items:JSON.stringify(e)}).then(function(e){var n=e.body;if(n.success){t.commit("TOGGLE");var i=n.data;t.commit("ss/UPDATE_SECTION_ITEMS",{section_id:t.getters.section,items:i},{root:!0})}},function(t){console.error(t)})}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={TOGGLE:function(t){t.open=!t.open},SET_SECTION:function(t,e){t.sectionId=e},SET_LIST_ITEMS:function(t,e){t.items=e},ADD_ITEM:function(t,e){t.addedItems.push(e)},REMOVE_ADDED_ITEM:function(t,e){t.addedItems.forEach(function(n,i){n.id===e.id&&t.addedItems.splice(i,1)})},RESET:function(t){t.addedItems=[],t.items=[]},UPDATE_PAGINATION:function(t,e){t.pagination=e},SEARCH_ITEMS_REQUEST:function(t){t.status="loading"},SEARCH_ITEMS_SUCCESS:function(t){t.status="successful"},SEARCH_ITEMS_FAILURE:function(t){t.status="failed"}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default={status:function(t){return t.status},pagination:function(t){return t.pagination},items:function(t,e){return t.items.map(function(t){var n=e.addedItems.find(function(e){return t.id===e.id});return t.added=!!n,t})},addedItems:function(t){return t.addedItems},isOpen:function(t){return t.open},types:function(t){return t.types},section:function(t){return t.sectionId}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=c.extend({},t.chooseItems);return e.sectionId=!1,e.pagination="",e.status="",{namespaced:!0,state:e,getters:i.default,mutations:o.default,actions:s.default}};var i=u(n(45)),o=u(n(44)),s=u(n(43));function u(t){return t&&t.__esModule?t:{default:t}}var c=jQuery},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=d(n(46)),o=d(n(42)),s=d(n(9)),u=d(n(38)),c=d(n(37)),r=d(n(36));function d(t){return t&&t.__esModule?t:{default:t}}var a=window.jQuery;e.default=function(t){var e=a.extend({},t.root);return e.status="success",e.heartbeat=!0,e.countCurrentRequest=0,{state:e,getters:u.default,mutations:c.default,actions:r.default,modules:{ci:(0,i.default)(t),i18n:(0,s.default)(t.i18n),ss:(0,o.default)(t)}}}},function(t,e,n){"use strict";var i=s(n(1)),o=s(n(47));function s(t){return t&&t.__esModule?t:{default:t}}window.$Vue=window.$Vue||Vue,window.$Vuex=window.$Vuex||Vuex,(0,window.jQuery)(document).ready(function(){window.LP_Curriculum_Store=new $Vuex.Store((0,o.default)(lpAdminCourseEditorSettings)),(0,i.default)({ns:"LPCurriculumRequest",store:LP_Curriculum_Store}),setTimeout(function(){window.LP_Course_Editor=new $Vue({el:"#admin-editor-lp_course",template:"<lp-course-editor></lp-course-editor>"})},100)})}]);
assets/js/admin/editor/question.js CHANGED