PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / frontend / modal.js

modal.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7, at assets/js/dist/frontend/modal.js

452 lines 15.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "./assets/src/apps/js/frontend/modal/index.js":
6 /*!****************************************************!*\
7 !*** ./assets/src/apps/js/frontend/modal/index.js ***!
8 \****************************************************/
9 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
13 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
14 /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "./assets/src/apps/js/frontend/modal/store/index.js");
15 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
16 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
17 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
18 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__);
19
20
21 /**
22 * Create Modal popup.
23 * Edit: Use React Hook.
24 *
25 * @author Nhamdv - ThimPress.
26 */
27
28
29
30
31 const Modal = _ref => {
32 let {
33 children
34 } = _ref;
35 const {
36 show,
37 hide,
38 confirm
39 } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.dispatch)('learnpress/modal');
40 const isShow = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
41 const isOpen = select('learnpress/modal').isOpen();
42 return isOpen;
43 });
44 const message = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
45 const getMessage = select('learnpress/modal').getMessage();
46 return getMessage;
47 });
48
49 const dataConfirm = c => event => {
50 confirm(c);
51 };
52
53 const styles = {
54 display: isShow ? 'block' : 'none'
55 };
56 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
57 id: "lp-modal-overlay",
58 style: styles
59 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
60 id: "lp-modal-window",
61 style: styles
62 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
63 id: "lp-modal-content",
64 dangerouslySetInnerHTML: {
65 __html: message
66 }
67 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
68 id: "lp-modal-buttons"
69 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", {
70 className: "lp-button modal-button-ok",
71 onClick: dataConfirm('yes')
72 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('OK', 'learnpress'))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", {
73 className: "lp-button modal-button-cancel",
74 onClick: dataConfirm('no')
75 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Cancel', 'learnpress')))))), children);
76 };
77
78 /* harmony default export */ __webpack_exports__["default"] = (Modal);
79
80 /***/ }),
81
82 /***/ "./assets/src/apps/js/frontend/modal/store/actions.js":
83 /*!************************************************************!*\
84 !*** ./assets/src/apps/js/frontend/modal/store/actions.js ***!
85 \************************************************************/
86 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
87
88 __webpack_require__.r(__webpack_exports__);
89 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
90 /* harmony export */ "confirm": function() { return /* binding */ confirm; },
91 /* harmony export */ "hide": function() { return /* binding */ hide; },
92 /* harmony export */ "show": function() { return /* binding */ show; }
93 /* harmony export */ });
94 function show(message, cb) {
95 return {
96 type: 'SHOW_MODAL',
97 message,
98 cb
99 };
100 }
101 function hide() {
102 return {
103 type: 'HIDE_MODAL'
104 };
105 }
106 function confirm(value) {
107 return {
108 type: 'CONFIRM',
109 value
110 };
111 }
112
113 /***/ }),
114
115 /***/ "./assets/src/apps/js/frontend/modal/store/index.js":
116 /*!**********************************************************!*\
117 !*** ./assets/src/apps/js/frontend/modal/store/index.js ***!
118 \**********************************************************/
119 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
120
121 __webpack_require__.r(__webpack_exports__);
122 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
123 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__);
124 /* harmony import */ var _reducer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reducer */ "./assets/src/apps/js/frontend/modal/store/reducer.js");
125 /* harmony import */ var _actions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actions */ "./assets/src/apps/js/frontend/modal/store/actions.js");
126 /* harmony import */ var _selectors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./selectors */ "./assets/src/apps/js/frontend/modal/store/selectors.js");
127 /* harmony import */ var _middlewares__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./middlewares */ "./assets/src/apps/js/frontend/modal/store/middlewares.js");
128
129
130
131
132
133 const {
134 controls: dataControls
135 } = LP.dataControls;
136 const store = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.registerStore)('learnpress/modal', {
137 reducer: _reducer__WEBPACK_IMPORTED_MODULE_1__["default"],
138 selectors: _selectors__WEBPACK_IMPORTED_MODULE_3__,
139 actions: _actions__WEBPACK_IMPORTED_MODULE_2__,
140 controls: { ...dataControls
141 }
142 });
143 (0,_middlewares__WEBPACK_IMPORTED_MODULE_4__["default"])(store);
144 /* harmony default export */ __webpack_exports__["default"] = (store);
145
146 /***/ }),
147
148 /***/ "./assets/src/apps/js/frontend/modal/store/middlewares.js":
149 /*!****************************************************************!*\
150 !*** ./assets/src/apps/js/frontend/modal/store/middlewares.js ***!
151 \****************************************************************/
152 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
153
154 __webpack_require__.r(__webpack_exports__);
155 /* harmony import */ var refx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! refx */ "./node_modules/refx/refx.js");
156 /* harmony import */ var refx__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(refx__WEBPACK_IMPORTED_MODULE_0__);
157 /**
158 * External dependencies
159 */
160
161 const effects = {
162 ENROLL_COURSE_X: (action, store) => {
163 enrollCourse: (action, store) => {
164 const {
165 dispatch
166 } = store; //dispatch()
167 };
168 }
169 };
170 /**
171 * Applies the custom middlewares used specifically in the editor module.
172 *
173 * @param {Object} store Store Object.
174 *
175 * @return {Object} Update Store Object.
176 */
177
178 function applyMiddlewares(store) {
179 let enhancedDispatch = () => {
180 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
181 };
182
183 const middlewareAPI = {
184 getState: store.getState,
185 dispatch: function () {
186 return enhancedDispatch(...arguments);
187 }
188 };
189 enhancedDispatch = refx__WEBPACK_IMPORTED_MODULE_0___default()(effects)(middlewareAPI)(store.dispatch);
190 store.dispatch = enhancedDispatch;
191 return store;
192 }
193
194 /* harmony default export */ __webpack_exports__["default"] = (applyMiddlewares);
195
196 /***/ }),
197
198 /***/ "./assets/src/apps/js/frontend/modal/store/reducer.js":
199 /*!************************************************************!*\
200 !*** ./assets/src/apps/js/frontend/modal/store/reducer.js ***!
201 \************************************************************/
202 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
203
204 __webpack_require__.r(__webpack_exports__);
205 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
206 /* harmony export */ "Modal": function() { return /* binding */ Modal; }
207 /* harmony export */ });
208 const STORE_DATA = {};
209 const Modal = function () {
210 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : STORE_DATA;
211 let action = arguments.length > 1 ? arguments[1] : undefined;
212
213 switch (action.type) {
214 case 'SHOW_MODAL':
215 return { ...state,
216 isOpen: true,
217 message: action.message,
218 cb: action.cb
219 };
220
221 case 'HIDE_MODAL':
222 return { ...state,
223 isOpen: false,
224 message: false,
225 cb: null
226 };
227
228 case 'CONFIRM':
229 state.cb && setTimeout(() => {
230 state.cb();
231 }, 10);
232 return { ...state,
233 confirm: action.value
234 };
235 }
236
237 return state;
238 };
239 /* harmony default export */ __webpack_exports__["default"] = (Modal);
240
241 /***/ }),
242
243 /***/ "./assets/src/apps/js/frontend/modal/store/selectors.js":
244 /*!**************************************************************!*\
245 !*** ./assets/src/apps/js/frontend/modal/store/selectors.js ***!
246 \**************************************************************/
247 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
248
249 __webpack_require__.r(__webpack_exports__);
250 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
251 /* harmony export */ "confirm": function() { return /* binding */ confirm; },
252 /* harmony export */ "getMessage": function() { return /* binding */ getMessage; },
253 /* harmony export */ "isOpen": function() { return /* binding */ isOpen; }
254 /* harmony export */ });
255 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data");
256 /* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_0__);
257
258 function isOpen(state) {
259 return state.isOpen;
260 }
261 function getMessage(state) {
262 return state.message;
263 }
264 function confirm(state, message, cb) {
265 const {
266 show,
267 hide
268 } = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_0__.dispatch)('learnpress/modal');
269
270 if (!state.message) {
271 show(message, cb);
272 } else {
273 hide();
274 return state.confirm;
275 }
276
277 return 'no';
278 }
279
280 /***/ }),
281
282 /***/ "./node_modules/refx/refx.js":
283 /*!***********************************!*\
284 !*** ./node_modules/refx/refx.js ***!
285 \***********************************/
286 /***/ (function(module) {
287
288
289
290 function flattenIntoMap( map, effects ) {
291 var i;
292 if ( Array.isArray( effects ) ) {
293 for ( i = 0; i < effects.length; i++ ) {
294 flattenIntoMap( map, effects[ i ] );
295 }
296 } else {
297 for ( i in effects ) {
298 map[ i ] = ( map[ i ] || [] ).concat( effects[ i ] );
299 }
300 }
301 }
302
303 function refx( effects ) {
304 var map = {},
305 middleware;
306
307 flattenIntoMap( map, effects );
308
309 middleware = function( store ) {
310 return function( next ) {
311 return function( action ) {
312 var handlers = map[ action.type ],
313 result = next( action ),
314 i, handlerAction;
315
316 if ( handlers ) {
317 for ( i = 0; i < handlers.length; i++ ) {
318 handlerAction = handlers[ i ]( action, store );
319 if ( handlerAction ) {
320 store.dispatch( handlerAction );
321 }
322 }
323 }
324
325 return result;
326 };
327 };
328 };
329
330 middleware.effects = map;
331
332 return middleware;
333 }
334
335 module.exports = refx;
336
337
338 /***/ }),
339
340 /***/ "@wordpress/data":
341 /*!******************************!*\
342 !*** external ["wp","data"] ***!
343 \******************************/
344 /***/ (function(module) {
345
346 module.exports = window["wp"]["data"];
347
348 /***/ }),
349
350 /***/ "@wordpress/element":
351 /*!*********************************!*\
352 !*** external ["wp","element"] ***!
353 \*********************************/
354 /***/ (function(module) {
355
356 module.exports = window["wp"]["element"];
357
358 /***/ }),
359
360 /***/ "@wordpress/i18n":
361 /*!******************************!*\
362 !*** external ["wp","i18n"] ***!
363 \******************************/
364 /***/ (function(module) {
365
366 module.exports = window["wp"]["i18n"];
367
368 /***/ })
369
370 /******/ });
371 /************************************************************************/
372 /******/ // The module cache
373 /******/ var __webpack_module_cache__ = {};
374 /******/
375 /******/ // The require function
376 /******/ function __webpack_require__(moduleId) {
377 /******/ // Check if module is in cache
378 /******/ var cachedModule = __webpack_module_cache__[moduleId];
379 /******/ if (cachedModule !== undefined) {
380 /******/ return cachedModule.exports;
381 /******/ }
382 /******/ // Create a new module (and put it into the cache)
383 /******/ var module = __webpack_module_cache__[moduleId] = {
384 /******/ // no module.id needed
385 /******/ // no module.loaded needed
386 /******/ exports: {}
387 /******/ };
388 /******/
389 /******/ // Execute the module function
390 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
391 /******/
392 /******/ // Return the exports of the module
393 /******/ return module.exports;
394 /******/ }
395 /******/
396 /************************************************************************/
397 /******/ /* webpack/runtime/compat get default export */
398 /******/ !function() {
399 /******/ // getDefaultExport function for compatibility with non-harmony modules
400 /******/ __webpack_require__.n = function(module) {
401 /******/ var getter = module && module.__esModule ?
402 /******/ function() { return module['default']; } :
403 /******/ function() { return module; };
404 /******/ __webpack_require__.d(getter, { a: getter });
405 /******/ return getter;
406 /******/ };
407 /******/ }();
408 /******/
409 /******/ /* webpack/runtime/define property getters */
410 /******/ !function() {
411 /******/ // define getter functions for harmony exports
412 /******/ __webpack_require__.d = function(exports, definition) {
413 /******/ for(var key in definition) {
414 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
415 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
416 /******/ }
417 /******/ }
418 /******/ };
419 /******/ }();
420 /******/
421 /******/ /* webpack/runtime/hasOwnProperty shorthand */
422 /******/ !function() {
423 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
424 /******/ }();
425 /******/
426 /******/ /* webpack/runtime/make namespace object */
427 /******/ !function() {
428 /******/ // define __esModule on exports
429 /******/ __webpack_require__.r = function(exports) {
430 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
431 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
432 /******/ }
433 /******/ Object.defineProperty(exports, '__esModule', { value: true });
434 /******/ };
435 /******/ }();
436 /******/
437 /************************************************************************/
438 var __webpack_exports__ = {};
439 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
440 !function() {
441 /*!**********************************************!*\
442 !*** ./assets/src/apps/js/frontend/modal.js ***!
443 \**********************************************/
444 __webpack_require__.r(__webpack_exports__);
445 /* harmony import */ var _modal_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./modal/index */ "./assets/src/apps/js/frontend/modal/index.js");
446
447 /* harmony default export */ __webpack_exports__["default"] = (_modal_index__WEBPACK_IMPORTED_MODULE_0__["default"]);
448 }();
449 (window.LP = window.LP || {}).modal = __webpack_exports__;
450 /******/ })()
451 ;
452 //# sourceMappingURL=modal.js.map