| 1 |
/******/ (() => { // webpackBootstrap |
| 2 |
/******/ "use strict"; |
| 3 |
/******/ var __webpack_modules__ = ({ |
| 4 |
|
| 5 |
/***/ "./assets/src/apps/js/blocks/course-elements/course-button/edit.js" |
| 6 |
/*!*************************************************************************!*\ |
| 7 |
!*** ./assets/src/apps/js/blocks/course-elements/course-button/edit.js ***! |
| 8 |
\*************************************************************************/ |
| 9 |
(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 10 |
|
| 11 |
__webpack_require__.r(__webpack_exports__); |
| 12 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 |
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) |
| 14 |
/* harmony export */ }); |
| 15 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 16 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); |
| 17 |
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); |
| 18 |
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__); |
| 19 |
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); |
| 20 |
/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); |
| 21 |
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); |
| 22 |
/* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__); |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
const Edit = props => { |
| 28 |
const { |
| 29 |
attributes = {}, |
| 30 |
setAttributes |
| 31 |
} = props; |
| 32 |
const blockProps = (0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.useBlockProps)({ |
| 33 |
style: { |
| 34 |
textAlign: attributes.textAlign, |
| 35 |
width: '100%' |
| 36 |
} |
| 37 |
}); |
| 38 |
const mapAlignItems = { |
| 39 |
top: 'flex-start', |
| 40 |
center: 'center', |
| 41 |
bottom: 'flex-end' |
| 42 |
}; |
| 43 |
|
| 44 |
// classOfDiv to fix align. |
| 45 |
let classOfDiv = blockProps.className; |
| 46 |
classOfDiv = classOfDiv.split(' ').filter(cls => cls.startsWith('align')).join(' '); |
| 47 |
return (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.BlockControls, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.AlignmentToolbar, { |
| 48 |
value: attributes.textAlign, |
| 49 |
onChange: newAlign => setAttributes({ |
| 50 |
textAlign: newAlign |
| 51 |
}) |
| 52 |
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.JustifyToolbar, { |
| 53 |
value: attributes.justifyContent, |
| 54 |
onChange: newJustify => setAttributes({ |
| 55 |
justifyContent: newJustify |
| 56 |
}) |
| 57 |
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.BlockVerticalAlignmentToolbar, { |
| 58 |
value: attributes.alignItems, |
| 59 |
onChange: newAlign => setAttributes({ |
| 60 |
alignItems: newAlign |
| 61 |
}) |
| 62 |
})), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_3__.InspectorControls, null, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, { |
| 63 |
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Settings', 'learnpress') |
| 64 |
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControl, { |
| 65 |
label: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Width', 'learnpress'), |
| 66 |
value: attributes.width || '100', |
| 67 |
onChange: value => { |
| 68 |
setAttributes({ |
| 69 |
width: value || '100' |
| 70 |
}); |
| 71 |
}, |
| 72 |
isBlock: true |
| 73 |
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { |
| 74 |
value: "25", |
| 75 |
label: "25%" |
| 76 |
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { |
| 77 |
value: "50", |
| 78 |
label: "50%" |
| 79 |
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { |
| 80 |
value: "75", |
| 81 |
label: "75%" |
| 82 |
}), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { |
| 83 |
value: "100", |
| 84 |
label: "100%" |
| 85 |
})))), (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 86 |
className: classOfDiv, |
| 87 |
style: { |
| 88 |
display: 'flex', |
| 89 |
textAlign: attributes.textAlign, |
| 90 |
alignItems: mapAlignItems[attributes.alignItems] || 'flex-start', |
| 91 |
justifyContent: attributes.justifyContent |
| 92 |
} |
| 93 |
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("a", { |
| 94 |
style: { |
| 95 |
width: attributes.width ? `${attributes.width}%` : undefined |
| 96 |
} |
| 97 |
}, (0,react__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { |
| 98 |
...blockProps |
| 99 |
}, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)('Buy Now', 'learnpress'))))); |
| 100 |
}; |
| 101 |
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Edit); |
| 102 |
|
| 103 |
/***/ }, |
| 104 |
|
| 105 |
/***/ "./assets/src/apps/js/blocks/course-elements/course-button/save.js" |
| 106 |
/*!*************************************************************************!*\ |
| 107 |
!*** ./assets/src/apps/js/blocks/course-elements/course-button/save.js ***! |
| 108 |
\*************************************************************************/ |
| 109 |
(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 110 |
|
| 111 |
__webpack_require__.r(__webpack_exports__); |
| 112 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 113 |
/* harmony export */ save: () => (/* binding */ save) |
| 114 |
/* harmony export */ }); |
| 115 |
const save = props => null; |
| 116 |
|
| 117 |
/***/ }, |
| 118 |
|
| 119 |
/***/ "./assets/src/apps/js/blocks/utilBlock.js" |
| 120 |
/*!************************************************!*\ |
| 121 |
!*** ./assets/src/apps/js/blocks/utilBlock.js ***! |
| 122 |
\************************************************/ |
| 123 |
(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 124 |
|
| 125 |
__webpack_require__.r(__webpack_exports__); |
| 126 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 127 |
/* harmony export */ checkTemplatesCanLoadBlock: () => (/* binding */ checkTemplatesCanLoadBlock) |
| 128 |
/* harmony export */ }); |
| 129 |
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); |
| 130 |
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__); |
| 131 |
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); |
| 132 |
/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_1__); |
| 133 |
/** |
| 134 |
* Check if the block can be loaded in the current template. |
| 135 |
* |
| 136 |
* @since 4.2.8.4 |
| 137 |
* @version 1.0.0 |
| 138 |
*/ |
| 139 |
|
| 140 |
|
| 141 |
let currentPostIdOld = null; |
| 142 |
const checkTemplatesCanLoadBlock = (templates, metadata, callBack) => { |
| 143 |
(0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.subscribe)(() => { |
| 144 |
const metaDataNew = { |
| 145 |
...metadata |
| 146 |
}; |
| 147 |
const store = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_1__.select)('core/editor') || null; |
| 148 |
if (!store || typeof store.getCurrentPostId !== 'function' || !store.getCurrentPostId()) { |
| 149 |
return; |
| 150 |
} |
| 151 |
const currentPostId = store.getCurrentPostId(); |
| 152 |
if (currentPostId === null) { |
| 153 |
return; |
| 154 |
} |
| 155 |
if (currentPostIdOld === currentPostId) { |
| 156 |
return; |
| 157 |
} |
| 158 |
currentPostIdOld = currentPostId; |
| 159 |
if ((0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__.getBlockType)(metaDataNew.name)) { |
| 160 |
(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_0__.unregisterBlockType)(metaDataNew.name); |
| 161 |
if (templates.includes(currentPostId)) { |
| 162 |
metaDataNew.ancestor = null; |
| 163 |
callBack(metaDataNew); |
| 164 |
} else { |
| 165 |
if (!metaDataNew.ancestor) { |
| 166 |
metaDataNew.ancestor = []; |
| 167 |
} |
| 168 |
callBack(metaDataNew); |
| 169 |
} |
| 170 |
} |
| 171 |
}); |
| 172 |
}; |
| 173 |
|
| 174 |
|
| 175 |
/***/ }, |
| 176 |
|
| 177 |
/***/ "react" |
| 178 |
/*!************************!*\ |
| 179 |
!*** external "React" ***! |
| 180 |
\************************/ |
| 181 |
(module) { |
| 182 |
|
| 183 |
module.exports = window["React"]; |
| 184 |
|
| 185 |
/***/ }, |
| 186 |
|
| 187 |
/***/ "@wordpress/block-editor" |
| 188 |
/*!*************************************!*\ |
| 189 |
!*** external ["wp","blockEditor"] ***! |
| 190 |
\*************************************/ |
| 191 |
(module) { |
| 192 |
|
| 193 |
module.exports = window["wp"]["blockEditor"]; |
| 194 |
|
| 195 |
/***/ }, |
| 196 |
|
| 197 |
/***/ "@wordpress/blocks" |
| 198 |
/*!********************************!*\ |
| 199 |
!*** external ["wp","blocks"] ***! |
| 200 |
\********************************/ |
| 201 |
(module) { |
| 202 |
|
| 203 |
module.exports = window["wp"]["blocks"]; |
| 204 |
|
| 205 |
/***/ }, |
| 206 |
|
| 207 |
/***/ "@wordpress/components" |
| 208 |
/*!************************************!*\ |
| 209 |
!*** external ["wp","components"] ***! |
| 210 |
\************************************/ |
| 211 |
(module) { |
| 212 |
|
| 213 |
module.exports = window["wp"]["components"]; |
| 214 |
|
| 215 |
/***/ }, |
| 216 |
|
| 217 |
/***/ "@wordpress/data" |
| 218 |
/*!******************************!*\ |
| 219 |
!*** external ["wp","data"] ***! |
| 220 |
\******************************/ |
| 221 |
(module) { |
| 222 |
|
| 223 |
module.exports = window["wp"]["data"]; |
| 224 |
|
| 225 |
/***/ }, |
| 226 |
|
| 227 |
/***/ "@wordpress/i18n" |
| 228 |
/*!******************************!*\ |
| 229 |
!*** external ["wp","i18n"] ***! |
| 230 |
\******************************/ |
| 231 |
(module) { |
| 232 |
|
| 233 |
module.exports = window["wp"]["i18n"]; |
| 234 |
|
| 235 |
/***/ }, |
| 236 |
|
| 237 |
/***/ "./assets/src/apps/js/blocks/course-elements/course-button/block.json" |
| 238 |
/*!****************************************************************************!*\ |
| 239 |
!*** ./assets/src/apps/js/blocks/course-elements/course-button/block.json ***! |
| 240 |
\****************************************************************************/ |
| 241 |
(module) { |
| 242 |
|
| 243 |
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"learnpress/course-button","title":"Course Button","category":"learnpress-course-elements","icon":"button","description":"Renders template Button Course PHP templates.","textdomain":"learnpress","keywords":["button single course","learnpress"],"ancestor":["learnpress/single-course"],"usesContext":["lpCourseData"],"attributes":{"textAlign":{"type":"string","default":"center"},"justifyContent":{"type":"string","default":"center"},"alignItems":{"type":"string","default":"top"},"width":{"type":"string","default":"100"}},"supports":{"multiple":true,"align":["wide","full"],"html":false,"typography":{"fontSize":true,"__experimentalDefaultControls":{"fontSize":true}},"color":{"background":true,"text":true,"__experimentalDefaultControls":{"background":true,"text":true}},"__experimentalBorder":{"color":true,"radius":true,"width":true,"__experimentalDefaultControls":{"width":false,"color":false,"radius":false}},"spacing":{"margin":true,"padding":true,"content":true,"__experimentalDefaultControls":{"margin":false,"padding":false,"content":true}}}}'); |
| 244 |
|
| 245 |
/***/ } |
| 246 |
|
| 247 |
/******/ }); |
| 248 |
/************************************************************************/ |
| 249 |
/******/ // The module cache |
| 250 |
/******/ var __webpack_module_cache__ = {}; |
| 251 |
/******/ |
| 252 |
/******/ // The require function |
| 253 |
/******/ function __webpack_require__(moduleId) { |
| 254 |
/******/ // Check if module is in cache |
| 255 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 256 |
/******/ if (cachedModule !== undefined) { |
| 257 |
/******/ return cachedModule.exports; |
| 258 |
/******/ } |
| 259 |
/******/ // Create a new module (and put it into the cache) |
| 260 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 261 |
/******/ // no module.id needed |
| 262 |
/******/ // no module.loaded needed |
| 263 |
/******/ exports: {} |
| 264 |
/******/ }; |
| 265 |
/******/ |
| 266 |
/******/ // Execute the module function |
| 267 |
/******/ if (!(moduleId in __webpack_modules__)) { |
| 268 |
/******/ delete __webpack_module_cache__[moduleId]; |
| 269 |
/******/ var e = new Error("Cannot find module '" + moduleId + "'"); |
| 270 |
/******/ e.code = 'MODULE_NOT_FOUND'; |
| 271 |
/******/ throw e; |
| 272 |
/******/ } |
| 273 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 274 |
/******/ |
| 275 |
/******/ // Return the exports of the module |
| 276 |
/******/ return module.exports; |
| 277 |
/******/ } |
| 278 |
/******/ |
| 279 |
/************************************************************************/ |
| 280 |
/******/ /* webpack/runtime/compat get default export */ |
| 281 |
/******/ (() => { |
| 282 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 283 |
/******/ __webpack_require__.n = (module) => { |
| 284 |
/******/ var getter = module && module.__esModule ? |
| 285 |
/******/ () => (module['default']) : |
| 286 |
/******/ () => (module); |
| 287 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 288 |
/******/ return getter; |
| 289 |
/******/ }; |
| 290 |
/******/ })(); |
| 291 |
/******/ |
| 292 |
/******/ /* webpack/runtime/define property getters */ |
| 293 |
/******/ (() => { |
| 294 |
/******/ // define getter functions for harmony exports |
| 295 |
/******/ __webpack_require__.d = (exports, definition) => { |
| 296 |
/******/ for(var key in definition) { |
| 297 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 298 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 299 |
/******/ } |
| 300 |
/******/ } |
| 301 |
/******/ }; |
| 302 |
/******/ })(); |
| 303 |
/******/ |
| 304 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 305 |
/******/ (() => { |
| 306 |
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
| 307 |
/******/ })(); |
| 308 |
/******/ |
| 309 |
/******/ /* webpack/runtime/make namespace object */ |
| 310 |
/******/ (() => { |
| 311 |
/******/ // define __esModule on exports |
| 312 |
/******/ __webpack_require__.r = (exports) => { |
| 313 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 314 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 315 |
/******/ } |
| 316 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 317 |
/******/ }; |
| 318 |
/******/ })(); |
| 319 |
/******/ |
| 320 |
/************************************************************************/ |
| 321 |
var __webpack_exports__ = {}; |
| 322 |
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk. |
| 323 |
(() => { |
| 324 |
/*!**************************************************************************!*\ |
| 325 |
!*** ./assets/src/apps/js/blocks/course-elements/course-button/index.js ***! |
| 326 |
\**************************************************************************/ |
| 327 |
__webpack_require__.r(__webpack_exports__); |
| 328 |
/* harmony import */ var _edit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./edit */ "./assets/src/apps/js/blocks/course-elements/course-button/edit.js"); |
| 329 |
/* harmony import */ var _save__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./save */ "./assets/src/apps/js/blocks/course-elements/course-button/save.js"); |
| 330 |
/* harmony import */ var _block_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./block.json */ "./assets/src/apps/js/blocks/course-elements/course-button/block.json"); |
| 331 |
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/blocks */ "@wordpress/blocks"); |
| 332 |
/* harmony import */ var _wordpress_blocks__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__); |
| 333 |
/* harmony import */ var _utilBlock_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../utilBlock.js */ "./assets/src/apps/js/blocks/utilBlock.js"); |
| 334 |
/** |
| 335 |
* Register block course button. |
| 336 |
*/ |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
const templatesName = ['learnpress/learnpress//single-lp_course', 'learnpress/learnpress//single-lp_course-offline']; |
| 344 |
(0,_utilBlock_js__WEBPACK_IMPORTED_MODULE_4__.checkTemplatesCanLoadBlock)(templatesName, _block_json__WEBPACK_IMPORTED_MODULE_2__, metadataNew => { |
| 345 |
(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__.registerBlockType)(metadataNew.name, { |
| 346 |
...metadataNew, |
| 347 |
edit: _edit__WEBPACK_IMPORTED_MODULE_0__["default"], |
| 348 |
save: _save__WEBPACK_IMPORTED_MODULE_1__.save |
| 349 |
}); |
| 350 |
}); |
| 351 |
(0,_wordpress_blocks__WEBPACK_IMPORTED_MODULE_3__.registerBlockType)(_block_json__WEBPACK_IMPORTED_MODULE_2__.name, { |
| 352 |
..._block_json__WEBPACK_IMPORTED_MODULE_2__, |
| 353 |
edit: _edit__WEBPACK_IMPORTED_MODULE_0__["default"], |
| 354 |
save: _save__WEBPACK_IMPORTED_MODULE_1__.save |
| 355 |
}); |
| 356 |
})(); |
| 357 |
|
| 358 |
/******/ })() |
| 359 |
; |
| 360 |
//# sourceMappingURL=course-button.js.map |