PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
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 / widgets.js

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

145 lines 5.0 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 /***/ "@wordpress/url":
6 /*!*****************************!*\
7 !*** external ["wp","url"] ***!
8 \*****************************/
9 /***/ (function(module) {
10
11 module.exports = window["wp"]["url"];
12
13 /***/ })
14
15 /******/ });
16 /************************************************************************/
17 /******/ // The module cache
18 /******/ var __webpack_module_cache__ = {};
19 /******/
20 /******/ // The require function
21 /******/ function __webpack_require__(moduleId) {
22 /******/ // Check if module is in cache
23 /******/ var cachedModule = __webpack_module_cache__[moduleId];
24 /******/ if (cachedModule !== undefined) {
25 /******/ return cachedModule.exports;
26 /******/ }
27 /******/ // Create a new module (and put it into the cache)
28 /******/ var module = __webpack_module_cache__[moduleId] = {
29 /******/ // no module.id needed
30 /******/ // no module.loaded needed
31 /******/ exports: {}
32 /******/ };
33 /******/
34 /******/ // Execute the module function
35 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
36 /******/
37 /******/ // Return the exports of the module
38 /******/ return module.exports;
39 /******/ }
40 /******/
41 /************************************************************************/
42 /******/ /* webpack/runtime/compat get default export */
43 /******/ !function() {
44 /******/ // getDefaultExport function for compatibility with non-harmony modules
45 /******/ __webpack_require__.n = function(module) {
46 /******/ var getter = module && module.__esModule ?
47 /******/ function() { return module['default']; } :
48 /******/ function() { return module; };
49 /******/ __webpack_require__.d(getter, { a: getter });
50 /******/ return getter;
51 /******/ };
52 /******/ }();
53 /******/
54 /******/ /* webpack/runtime/define property getters */
55 /******/ !function() {
56 /******/ // define getter functions for harmony exports
57 /******/ __webpack_require__.d = function(exports, definition) {
58 /******/ for(var key in definition) {
59 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
60 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
61 /******/ }
62 /******/ }
63 /******/ };
64 /******/ }();
65 /******/
66 /******/ /* webpack/runtime/hasOwnProperty shorthand */
67 /******/ !function() {
68 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
69 /******/ }();
70 /******/
71 /******/ /* webpack/runtime/make namespace object */
72 /******/ !function() {
73 /******/ // define __esModule on exports
74 /******/ __webpack_require__.r = function(exports) {
75 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
76 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
77 /******/ }
78 /******/ Object.defineProperty(exports, '__esModule', { value: true });
79 /******/ };
80 /******/ }();
81 /******/
82 /************************************************************************/
83 var __webpack_exports__ = {};
84 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
85 !function() {
86 /*!************************************************!*\
87 !*** ./assets/src/apps/js/frontend/widgets.js ***!
88 \************************************************/
89 __webpack_require__.r(__webpack_exports__);
90 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
91 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
92
93
94 function widgetRestAPI() {
95 const widgets = document.querySelectorAll('.learnpress-widget-wrapper');
96
97 if (!widgets.length) {
98 return;
99 }
100
101 const getResponse = async ele => {
102 const widget = ele.dataset.widget ? JSON.parse(ele.dataset.widget) : '';
103 const response = await wp.apiFetch({
104 path: 'lp/v1/widgets/api',
105 method: 'POST',
106 data: { ...widget
107 }
108 });
109 const {
110 data,
111 status,
112 message
113 } = response;
114
115 if (data && status === 'success') {
116 ele.insertAdjacentHTML('afterbegin', data);
117 } else if (message) {
118 ele.insertAdjacentHTML('afterbegin', `<div class="lp-ajax-message error" style="display:block">${message}</div>`);
119 }
120
121 delete ele.dataset.widget;
122 ele.querySelector('.lp-skeleton-animation').remove();
123 };
124
125 if ('IntersectionObserver' in window) {
126 const eleObserver = new IntersectionObserver((entries, observer) => {
127 entries.forEach(entry => {
128 if (entry.isIntersecting) {
129 const ele = entry.target;
130 getResponse(ele);
131 eleObserver.unobserve(ele);
132 }
133 });
134 });
135 [...widgets].map(ele => ele.classList.contains('learnpress-widget-wrapper__restapi') && eleObserver.observe(ele));
136 }
137 }
138
139 document.addEventListener('DOMContentLoaded', function (event) {
140 widgetRestAPI();
141 });
142 }();
143 /******/ })()
144 ;
145 //# sourceMappingURL=widgets.js.map