| 1 |
/******/ (function() { // webpackBootstrap |
| 2 |
/******/ var __webpack_modules__ = ({ |
| 3 |
|
| 4 |
/***/ "./assets/src/apps/js/frontend/profile/avatar.js": |
| 5 |
/*!*******************************************************!*\ |
| 6 |
!*** ./assets/src/apps/js/frontend/profile/avatar.js ***! |
| 7 |
\*******************************************************/ |
| 8 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 9 |
|
| 10 |
"use strict"; |
| 11 |
__webpack_require__.r(__webpack_exports__); |
| 12 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 13 |
/* harmony export */ "default": function() { return /* binding */ Avatar; } |
| 14 |
/* harmony export */ }); |
| 15 |
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 16 |
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
| 17 |
/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch"); |
| 18 |
/* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__); |
| 19 |
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); |
| 20 |
/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); |
| 21 |
/* harmony import */ var react_easy_crop__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-easy-crop */ "./node_modules/react-easy-crop/index.module.js"); |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
function Avatar() { |
| 28 |
const [file, setFile] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(); |
| 29 |
const [width, setWidth] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); |
| 30 |
const [height, setHeight] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); |
| 31 |
const [crop, setCrop] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)({ |
| 32 |
x: 0, |
| 33 |
y: 0 |
| 34 |
}); |
| 35 |
const [rotation, setRotation] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); |
| 36 |
const [croppedAreaPixels, setCroppedAreaPixels] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(null); |
| 37 |
const [naturalWidth, setNaturalWidth] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); |
| 38 |
const [naturalHeight, setNaturalHeight] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0); |
| 39 |
const [loading, setLoading] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(false); |
| 40 |
const [skeleton, setSkeleton] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(true); |
| 41 |
const [uploadError, setUploadError] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(''); |
| 42 |
const [notice, setNotice] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)({ |
| 43 |
type: '', |
| 44 |
message: '' |
| 45 |
}); |
| 46 |
const fileInput = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useRef)(); |
| 47 |
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => { |
| 48 |
async function getAvatar() { |
| 49 |
setSkeleton(true); |
| 50 |
|
| 51 |
try { |
| 52 |
var _response$data, _response$data2, _response$data3; |
| 53 |
|
| 54 |
const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ |
| 55 |
method: 'GET', |
| 56 |
path: 'lp/v1/profile/get-avatar' |
| 57 |
}); |
| 58 |
setWidth(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.width ? parseInt(response.data.width) : 0); |
| 59 |
setHeight(response !== null && response !== void 0 && (_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.height ? parseInt(response.data.height) : 0); |
| 60 |
setFile(response !== null && response !== void 0 && (_response$data3 = response.data) !== null && _response$data3 !== void 0 && _response$data3.url ? response.data.url : ''); |
| 61 |
} catch (error) { |
| 62 |
setNotice({ |
| 63 |
type: 'error', |
| 64 |
message: error.message |
| 65 |
}); |
| 66 |
} |
| 67 |
|
| 68 |
setSkeleton(false); |
| 69 |
} |
| 70 |
|
| 71 |
getAvatar(); |
| 72 |
}, []); |
| 73 |
|
| 74 |
function readFile(file) { |
| 75 |
return new Promise(resolve => { |
| 76 |
const reader = new FileReader(); |
| 77 |
reader.addEventListener('load', () => resolve(reader.result), false); |
| 78 |
reader.readAsDataURL(file); |
| 79 |
}); |
| 80 |
} |
| 81 |
|
| 82 |
const onCropComplete = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useCallback)((croppedArea, croppedAreaPixels) => { |
| 83 |
setCroppedAreaPixels(croppedAreaPixels); |
| 84 |
}, []); |
| 85 |
|
| 86 |
const base64Resize = (base64, width, height) => { |
| 87 |
return new Promise((resolve, reject) => { |
| 88 |
const canvas = document.createElement('canvas'); |
| 89 |
const img = document.createElement('img'); |
| 90 |
img.src = base64; |
| 91 |
img.setAttribute('crossOrigin', 'anonymous'); |
| 92 |
|
| 93 |
img.onload = () => { |
| 94 |
if (img.naturalWidth > width || img.naturalHeight > height) { |
| 95 |
canvas.width = width; |
| 96 |
canvas.height = height; |
| 97 |
const ctx = canvas.getContext('2d'); |
| 98 |
ctx.drawImage(img, 0, 0, width, height); |
| 99 |
resolve(canvas.toDataURL('image/jpeg')); |
| 100 |
} |
| 101 |
|
| 102 |
resolve(base64); |
| 103 |
}; |
| 104 |
|
| 105 |
img.onerror = err => reject(err); |
| 106 |
}); |
| 107 |
}; |
| 108 |
|
| 109 |
const updateAvatar = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => { |
| 110 |
setLoading({ |
| 111 |
save: true |
| 112 |
}); |
| 113 |
|
| 114 |
try { |
| 115 |
const croppedImage = await getCroppedImg(file, croppedAreaPixels, rotation); |
| 116 |
const imageResize = await base64Resize(croppedImage, width, height); |
| 117 |
const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ |
| 118 |
path: 'lp/v1/profile/upload-avatar', |
| 119 |
method: 'POST', |
| 120 |
data: { |
| 121 |
file: imageResize || '' |
| 122 |
} |
| 123 |
}); |
| 124 |
const { |
| 125 |
data, |
| 126 |
status, |
| 127 |
message |
| 128 |
} = await response; |
| 129 |
|
| 130 |
if (status === 'success') { |
| 131 |
window.location.reload(); |
| 132 |
} |
| 133 |
|
| 134 |
setNotice({ |
| 135 |
type: status, |
| 136 |
message |
| 137 |
}); |
| 138 |
} catch (e) { |
| 139 |
setNotice({ |
| 140 |
type: 'error', |
| 141 |
message: e.message || '' |
| 142 |
}); |
| 143 |
} |
| 144 |
|
| 145 |
setLoading({ |
| 146 |
save: false |
| 147 |
}); |
| 148 |
}, [croppedAreaPixels, rotation]); |
| 149 |
|
| 150 |
const setFileInput = async fileUpload => { |
| 151 |
const file = await readFile(fileUpload); |
| 152 |
const img = new Image(); |
| 153 |
img.src = await file; |
| 154 |
img.onload = await function () { |
| 155 |
setNaturalWidth(img.naturalWidth); |
| 156 |
setNaturalHeight(img.naturalHeight); |
| 157 |
let error = ''; |
| 158 |
|
| 159 |
if (parseInt(fileUpload.size) > 2097152) { |
| 160 |
error = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('File size too large. You need to upload a file < 2MB', 'learnpress'); |
| 161 |
} else if (img.naturalWidth < width || img.naturalHeight < height) { |
| 162 |
error = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Image size must be greater than or equal to %1$sx%2$spx', 'learnpress'), width, height); |
| 163 |
} |
| 164 |
|
| 165 |
if (error) { |
| 166 |
setUploadError(error); |
| 167 |
} else { |
| 168 |
setUploadError(''); |
| 169 |
setFile(file); |
| 170 |
} |
| 171 |
}; |
| 172 |
}; |
| 173 |
|
| 174 |
async function removeAvatar() { |
| 175 |
if (confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Are you sure you want to remove your avatar?', 'learnpress'))) { |
| 176 |
setLoading({ |
| 177 |
remove: true |
| 178 |
}); |
| 179 |
|
| 180 |
try { |
| 181 |
const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({ |
| 182 |
path: 'lp/v1/profile/remove-avatar', |
| 183 |
method: 'POST' |
| 184 |
}); |
| 185 |
const { |
| 186 |
data, |
| 187 |
status, |
| 188 |
message |
| 189 |
} = await response; |
| 190 |
setNotice({ |
| 191 |
type: status, |
| 192 |
message |
| 193 |
}); |
| 194 |
setFile(''); |
| 195 |
} catch (e) { |
| 196 |
setNotice({ |
| 197 |
type: 'error', |
| 198 |
message: e.message || '' |
| 199 |
}); |
| 200 |
} |
| 201 |
|
| 202 |
setLoading({ |
| 203 |
remove: false |
| 204 |
}); |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 209 |
className: "learnpress_avatar" |
| 210 |
}, !skeleton ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, file && !uploadError && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, naturalHeight && naturalWidth ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 211 |
className: "learnpress_avatar__cropper" |
| 212 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 213 |
style: { |
| 214 |
position: 'relative', |
| 215 |
width: naturalWidth, |
| 216 |
height: naturalHeight, |
| 217 |
zIndex: 9999, |
| 218 |
maxWidth: '100%', |
| 219 |
maxHeight: '800px' |
| 220 |
} |
| 221 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(react_easy_crop__WEBPACK_IMPORTED_MODULE_3__["default"], { |
| 222 |
image: file, |
| 223 |
crop: crop, |
| 224 |
zoom: "1", |
| 225 |
cropSize: { |
| 226 |
width, |
| 227 |
height |
| 228 |
}, |
| 229 |
onCropChange: setCrop, |
| 230 |
onCropComplete: onCropComplete |
| 231 |
})), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { |
| 232 |
className: `learnpress_avatar__button learnpress_avatar__button--save ${loading !== null && loading !== void 0 && loading.save ? 'learnpress_avatar__button--loading' : ''}`, |
| 233 |
onClick: updateAvatar |
| 234 |
}, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Save', 'learnpress')))) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 235 |
className: "learnpress_avatar__cropper" |
| 236 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", { |
| 237 |
src: file, |
| 238 |
alt: "" |
| 239 |
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { |
| 240 |
className: `learnpress_avatar__button learnpress_avatar__button--replace`, |
| 241 |
onClick: () => fileInput.current && fileInput.current.click() |
| 242 |
}, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Replace', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", { |
| 243 |
className: `learnpress_avatar__button learnpress_avatar__button--remove ${loading !== null && loading !== void 0 && loading.remove ? 'learnpress_avatar__button--loading' : ''}`, |
| 244 |
onClick: removeAvatar |
| 245 |
}, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Remove', 'learnpress'))))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("form", { |
| 246 |
style: { |
| 247 |
display: !file ? '' : 'none' |
| 248 |
} |
| 249 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 250 |
className: "learnpress_avatar__form" |
| 251 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 252 |
className: "learnpress_avatar__form-group" |
| 253 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", { |
| 254 |
htmlFor: "avatar-file" |
| 255 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 256 |
className: "learnpress_avatar__form__upload" |
| 257 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", { |
| 258 |
viewBox: "64 64 896 896", |
| 259 |
focusable: "false", |
| 260 |
"data-icon": "plus", |
| 261 |
width: "1em", |
| 262 |
height: "1em", |
| 263 |
fill: "currentColor", |
| 264 |
"aria-hidden": "true" |
| 265 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("defs", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("style", null)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", { |
| 266 |
d: "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z" |
| 267 |
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", { |
| 268 |
d: "M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z" |
| 269 |
}))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Upload', 'learnpress')))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", { |
| 270 |
ref: fileInput, |
| 271 |
type: "file", |
| 272 |
id: "avatar-file", |
| 273 |
accept: "image/*", |
| 274 |
onChange: e => setFileInput(e.target.files && e.target.files.length > 0 ? e.target.files[0] : '') |
| 275 |
}))))), uploadError && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 276 |
className: `lp-ajax-message error`, |
| 277 |
style: { |
| 278 |
display: 'block' |
| 279 |
} |
| 280 |
}, uploadError), !uploadError && notice && notice.type && notice.message && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", { |
| 281 |
className: `lp-ajax-message ${notice.type}`, |
| 282 |
style: { |
| 283 |
display: 'block' |
| 284 |
} |
| 285 |
}, notice.message)) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", { |
| 286 |
className: "lp-skeleton-animation" |
| 287 |
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { |
| 288 |
style: { |
| 289 |
width: 200, |
| 290 |
height: 200 |
| 291 |
} |
| 292 |
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { |
| 293 |
style: { |
| 294 |
width: 200, |
| 295 |
height: 20 |
| 296 |
} |
| 297 |
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", { |
| 298 |
style: { |
| 299 |
width: 200, |
| 300 |
height: 20 |
| 301 |
} |
| 302 |
}))); |
| 303 |
} // Link: https://codesandbox.io/s/q8q1mnr01w |
| 304 |
|
| 305 |
const createImage = url => new Promise((resolve, reject) => { |
| 306 |
const image = new Image(); |
| 307 |
image.addEventListener('load', () => resolve(image)); |
| 308 |
image.addEventListener('error', error => reject(error)); |
| 309 |
image.setAttribute('crossOrigin', 'anonymous'); // needed to avoid cross-origin issues on CodeSandbox |
| 310 |
|
| 311 |
image.src = url; |
| 312 |
}); |
| 313 |
|
| 314 |
function getRadianAngle(degreeValue) { |
| 315 |
return degreeValue * Math.PI / 180; |
| 316 |
} |
| 317 |
/** |
| 318 |
* Returns the new bounding area of a rotated rectangle. |
| 319 |
* |
| 320 |
* @param width |
| 321 |
* @param height |
| 322 |
* @param rotation |
| 323 |
*/ |
| 324 |
|
| 325 |
|
| 326 |
function rotateSize(width, height, rotation) { |
| 327 |
const rotRad = getRadianAngle(rotation); |
| 328 |
return { |
| 329 |
width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), |
| 330 |
height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height) |
| 331 |
}; |
| 332 |
} |
| 333 |
/** |
| 334 |
* This function was adapted from the one in the ReadMe of https://github.com/DominicTobias/react-image-crop |
| 335 |
* |
| 336 |
* @param imageSrc |
| 337 |
* @param pixelCrop |
| 338 |
* @param rotation |
| 339 |
* @param flip |
| 340 |
*/ |
| 341 |
|
| 342 |
|
| 343 |
async function getCroppedImg(imageSrc, pixelCrop) { |
| 344 |
let rotation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; |
| 345 |
let flip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { |
| 346 |
horizontal: false, |
| 347 |
vertical: false |
| 348 |
}; |
| 349 |
const image = await createImage(imageSrc); |
| 350 |
const canvas = document.createElement('canvas'); |
| 351 |
const ctx = canvas.getContext('2d'); |
| 352 |
|
| 353 |
if (!ctx) { |
| 354 |
return null; |
| 355 |
} |
| 356 |
|
| 357 |
const rotRad = getRadianAngle(rotation); // calculate bounding box of the rotated image |
| 358 |
|
| 359 |
const { |
| 360 |
width: bBoxWidth, |
| 361 |
height: bBoxHeight |
| 362 |
} = rotateSize(image.width, image.height, rotation); // set canvas size to match the bounding box |
| 363 |
|
| 364 |
canvas.width = bBoxWidth; |
| 365 |
canvas.height = bBoxHeight; // translate canvas context to a central location to allow rotating and flipping around the center |
| 366 |
|
| 367 |
ctx.translate(bBoxWidth / 2, bBoxHeight / 2); |
| 368 |
ctx.rotate(rotRad); |
| 369 |
ctx.scale(flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1); |
| 370 |
ctx.translate(-image.width / 2, -image.height / 2); // draw rotated image |
| 371 |
|
| 372 |
ctx.drawImage(image, 0, 0); // croppedAreaPixels values are bounding box relative |
| 373 |
// extract the cropped image using these values |
| 374 |
|
| 375 |
const data = ctx.getImageData(pixelCrop.x, pixelCrop.y, pixelCrop.width, pixelCrop.height); // set canvas width to final desired crop size - this will clear existing context |
| 376 |
|
| 377 |
canvas.width = pixelCrop.width; |
| 378 |
canvas.height = pixelCrop.height; // paste generated rotate image at the top left corner |
| 379 |
|
| 380 |
ctx.putImageData(data, 0, 0); // As Base64 string |
| 381 |
|
| 382 |
return canvas.toDataURL('image/jpeg'); |
| 383 |
} |
| 384 |
|
| 385 |
/***/ }), |
| 386 |
|
| 387 |
/***/ "./assets/src/apps/js/frontend/profile/course-tab.js": |
| 388 |
/*!***********************************************************!*\ |
| 389 |
!*** ./assets/src/apps/js/frontend/profile/course-tab.js ***! |
| 390 |
\***********************************************************/ |
| 391 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 392 |
|
| 393 |
"use strict"; |
| 394 |
__webpack_require__.r(__webpack_exports__); |
| 395 |
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); |
| 396 |
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__); |
| 397 |
// Rest API load content course enrolled, created - Nhamdv. |
| 398 |
|
| 399 |
const courseTab = () => { |
| 400 |
const elements = document.querySelectorAll('.learn-press-course-tab__filter__content'); |
| 401 |
|
| 402 |
const getResponse = function (ele, dataset) { |
| 403 |
let append = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
| 404 |
let viewMoreEle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
| 405 |
wp.apiFetch({ |
| 406 |
path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/profile/course-tab', dataset), |
| 407 |
method: 'GET' |
| 408 |
}).then(response => { |
| 409 |
const skeleton = ele.querySelector('.lp-skeleton-animation'); |
| 410 |
skeleton && skeleton.remove(); |
| 411 |
|
| 412 |
if (response.status === 'success' && response.data) { |
| 413 |
if (append) { |
| 414 |
ele.innerHTML += response.data; |
| 415 |
} else { |
| 416 |
ele.innerHTML = response.data; |
| 417 |
} |
| 418 |
} else if (append) { |
| 419 |
ele.innerHTML += `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`; |
| 420 |
} else { |
| 421 |
ele.innerHTML = `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`; |
| 422 |
} |
| 423 |
|
| 424 |
if (viewMoreEle) { |
| 425 |
viewMoreEle.classList.remove('loading'); |
| 426 |
const paged = viewMoreEle.dataset.paged; |
| 427 |
const numberPage = viewMoreEle.dataset.number; |
| 428 |
|
| 429 |
if (numberPage <= paged) { |
| 430 |
viewMoreEle.remove(); |
| 431 |
} |
| 432 |
|
| 433 |
viewMoreEle.dataset.paged = parseInt(paged) + 1; |
| 434 |
} |
| 435 |
|
| 436 |
viewMore(ele, dataset); |
| 437 |
}).catch(error => { |
| 438 |
if (append) { |
| 439 |
ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${error.message && error.message}</div>`; |
| 440 |
} else { |
| 441 |
ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${error.message && error.message}</div>`; |
| 442 |
} |
| 443 |
|
| 444 |
if (viewMoreEle) { |
| 445 |
viewMoreEle.classList.remove('loading'); |
| 446 |
const paged = viewMoreEle.dataset.paged; |
| 447 |
const numberPage = viewMoreEle.dataset.number; |
| 448 |
|
| 449 |
if (numberPage <= paged) { |
| 450 |
viewMoreEle.remove(); |
| 451 |
} |
| 452 |
|
| 453 |
viewMoreEle.dataset.paged = parseInt(paged) + 1; |
| 454 |
} |
| 455 |
}); |
| 456 |
}; |
| 457 |
|
| 458 |
if ('IntersectionObserver' in window) { |
| 459 |
const eleObserver = new IntersectionObserver((entries, observer) => { |
| 460 |
entries.forEach(entry => { |
| 461 |
if (entry.isIntersecting) { |
| 462 |
const ele = entry.target; |
| 463 |
const params = ele.parentNode.querySelector('.lp_profile_tab_input_param'); |
| 464 |
const data = { ...JSON.parse(params.value), |
| 465 |
status: ele.dataset.tab || '' |
| 466 |
}; |
| 467 |
getResponse(ele, data); |
| 468 |
eleObserver.unobserve(ele); |
| 469 |
} |
| 470 |
}); |
| 471 |
}); |
| 472 |
[...elements].map(ele => { |
| 473 |
if (ele.dataset.tab !== 'all') { |
| 474 |
eleObserver.observe(ele); |
| 475 |
} else { |
| 476 |
const params = ele.parentNode.querySelector('.lp_profile_tab_input_param'); |
| 477 |
const data = { ...JSON.parse(params.value), |
| 478 |
status: ele.dataset.tab === 'all' ? '' : ele.dataset.tab || '' |
| 479 |
}; |
| 480 |
getResponse(ele, data); |
| 481 |
} |
| 482 |
}); |
| 483 |
} |
| 484 |
|
| 485 |
const changeFilter = () => { |
| 486 |
const tabs = document.querySelectorAll('.learn-press-course-tab-filters'); |
| 487 |
tabs.forEach(tab => { |
| 488 |
const filters = tab.querySelectorAll('.learn-press-filters a'); |
| 489 |
filters.forEach(filter => { |
| 490 |
filter.addEventListener('click', e => { |
| 491 |
e.preventDefault(); |
| 492 |
const tabName = filter.dataset.tab; |
| 493 |
[...filters].map(ele => { |
| 494 |
ele.classList.remove('active'); |
| 495 |
}); |
| 496 |
filter.classList.add('active'); |
| 497 |
[...tab.querySelectorAll('.learn-press-course-tab__filter__content')].map(ele => { |
| 498 |
ele.style.display = 'none'; |
| 499 |
|
| 500 |
if (ele.dataset.tab === tabName) { |
| 501 |
ele.style.display = ''; |
| 502 |
} |
| 503 |
}); |
| 504 |
}); |
| 505 |
}); |
| 506 |
}); |
| 507 |
}; |
| 508 |
|
| 509 |
changeFilter(); |
| 510 |
|
| 511 |
const changeTab = () => { |
| 512 |
const tabUls = document.querySelectorAll('.learn-press-profile-course__tab__inner'); |
| 513 |
tabUls.forEach(tabUl => { |
| 514 |
const tabs = tabUl.querySelectorAll('li> a'); |
| 515 |
tabs.forEach(tab => { |
| 516 |
tab.addEventListener('click', e => { |
| 517 |
e.preventDefault(); |
| 518 |
const tabName = tab.dataset.tab; |
| 519 |
[...tabs].map(ele => { |
| 520 |
ele.classList.remove('active'); |
| 521 |
}); |
| 522 |
tab.classList.add('active'); |
| 523 |
[...document.querySelectorAll('.learn-press-course-tab-filters')].map(ele => { |
| 524 |
ele.style.display = 'none'; |
| 525 |
|
| 526 |
if (ele.dataset.tab === tabName) { |
| 527 |
ele.style.display = ''; |
| 528 |
} |
| 529 |
}); |
| 530 |
}); |
| 531 |
}); |
| 532 |
}); |
| 533 |
}; |
| 534 |
|
| 535 |
changeTab(); |
| 536 |
|
| 537 |
const viewMore = (ele, dataset) => { |
| 538 |
const viewMoreEle = ele.querySelector('button[data-paged]'); |
| 539 |
|
| 540 |
if (viewMoreEle) { |
| 541 |
viewMoreEle.addEventListener('click', e => { |
| 542 |
e.preventDefault(); |
| 543 |
const paged = viewMoreEle && viewMoreEle.dataset.paged; |
| 544 |
viewMoreEle.classList.add('loading'); |
| 545 |
const element = dataset.layout === 'list' ? '.lp_profile_course_progress' : '.learn-press-courses'; |
| 546 |
getResponse(ele.querySelector(element), { ...dataset, |
| 547 |
...{ |
| 548 |
paged |
| 549 |
} |
| 550 |
}, true, viewMoreEle); |
| 551 |
}); |
| 552 |
} |
| 553 |
}; |
| 554 |
}; |
| 555 |
|
| 556 |
/* harmony default export */ __webpack_exports__["default"] = (courseTab); |
| 557 |
|
| 558 |
/***/ }), |
| 559 |
|
| 560 |
/***/ "./assets/src/apps/js/frontend/profile/order-recover.js": |
| 561 |
/*!**************************************************************!*\ |
| 562 |
!*** ./assets/src/apps/js/frontend/profile/order-recover.js ***! |
| 563 |
\**************************************************************/ |
| 564 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 565 |
|
| 566 |
"use strict"; |
| 567 |
__webpack_require__.r(__webpack_exports__); |
| 568 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 569 |
/* harmony export */ "default": function() { return /* binding */ recoverOrder; } |
| 570 |
/* harmony export */ }); |
| 571 |
const $ = window.jQuery; |
| 572 |
function recoverOrder() { |
| 573 |
const wrap = $('.order-recover'), |
| 574 |
buttonRecoverOrder = wrap.find('.button-recover-order'); |
| 575 |
|
| 576 |
const ajaxRecover = () => { |
| 577 |
wrap.find('.learn-press-message').remove(); |
| 578 |
$('.profile-recover-order').find('.learn-press-message').remove(); |
| 579 |
$.post({ |
| 580 |
url: '', |
| 581 |
data: wrap.serializeJSON(), |
| 582 |
|
| 583 |
beforeSend() { |
| 584 |
buttonRecoverOrder.addClass('loading').attr('disabled', 'disabled'); |
| 585 |
}, |
| 586 |
|
| 587 |
success(response) { |
| 588 |
response = LP.parseJSON(response); |
| 589 |
|
| 590 |
if (response.message) { |
| 591 |
const $msg = $('<div class="learn-press-message icon"><i class="fa"></i> ' + response.message + '</div>'); |
| 592 |
|
| 593 |
if (response.result == 'error') { |
| 594 |
$msg.addClass('error'); |
| 595 |
} |
| 596 |
|
| 597 |
wrap.before($msg); |
| 598 |
} |
| 599 |
|
| 600 |
if (response.redirect) { |
| 601 |
window.location.href = response.redirect; |
| 602 |
} |
| 603 |
|
| 604 |
buttonRecoverOrder.removeClass('loading').removeAttr('disabled', ''); |
| 605 |
}, |
| 606 |
|
| 607 |
error() { |
| 608 |
buttonRecoverOrder.removeClass('loading').removeAttr('disabled', ''); |
| 609 |
} |
| 610 |
|
| 611 |
}); |
| 612 |
}; |
| 613 |
|
| 614 |
buttonRecoverOrder.on('click', ajaxRecover); |
| 615 |
} |
| 616 |
; |
| 617 |
|
| 618 |
/***/ }), |
| 619 |
|
| 620 |
/***/ "./assets/src/apps/js/frontend/profile/statistic.js": |
| 621 |
/*!**********************************************************!*\ |
| 622 |
!*** ./assets/src/apps/js/frontend/profile/statistic.js ***! |
| 623 |
\**********************************************************/ |
| 624 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 625 |
|
| 626 |
"use strict"; |
| 627 |
__webpack_require__.r(__webpack_exports__); |
| 628 |
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url"); |
| 629 |
/* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__); |
| 630 |
// Rest API load content course progress - Nhamdv. |
| 631 |
|
| 632 |
const courseStatistics = () => { |
| 633 |
const elements = document.querySelector('.learn-press-profile-course__statistic'); |
| 634 |
|
| 635 |
if (!elements) { |
| 636 |
return; |
| 637 |
} |
| 638 |
|
| 639 |
const getResponse = (ele, dataset) => { |
| 640 |
wp.apiFetch({ |
| 641 |
path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/profile/statistic', dataset), |
| 642 |
method: 'GET' |
| 643 |
}).then(response => { |
| 644 |
if (response.status === 'success' && response.data) { |
| 645 |
ele.innerHTML = response.data; |
| 646 |
} else { |
| 647 |
ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${response.message && response.message}</div>`; |
| 648 |
} |
| 649 |
}).catch(err => { |
| 650 |
console.log(err); //ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ err.message && err.message }</div>`; |
| 651 |
}); |
| 652 |
}; |
| 653 |
|
| 654 |
const elArgStatistic = document.querySelector('[name="args_query_user_courses_statistic"]'); |
| 655 |
|
| 656 |
if (!elArgStatistic) { |
| 657 |
return; |
| 658 |
} |
| 659 |
|
| 660 |
const data = JSON.parse(elArgStatistic.value); |
| 661 |
getResponse(elements, data); |
| 662 |
}; |
| 663 |
|
| 664 |
/* harmony default export */ __webpack_exports__["default"] = (courseStatistics); |
| 665 |
|
| 666 |
/***/ }), |
| 667 |
|
| 668 |
/***/ "./node_modules/normalize-wheel/index.js": |
| 669 |
/*!***********************************************!*\ |
| 670 |
!*** ./node_modules/normalize-wheel/index.js ***! |
| 671 |
\***********************************************/ |
| 672 |
/***/ (function(module, __unused_webpack_exports, __webpack_require__) { |
| 673 |
|
| 674 |
module.exports = __webpack_require__(/*! ./src/normalizeWheel.js */ "./node_modules/normalize-wheel/src/normalizeWheel.js"); |
| 675 |
|
| 676 |
|
| 677 |
/***/ }), |
| 678 |
|
| 679 |
/***/ "./node_modules/normalize-wheel/src/ExecutionEnvironment.js": |
| 680 |
/*!******************************************************************!*\ |
| 681 |
!*** ./node_modules/normalize-wheel/src/ExecutionEnvironment.js ***! |
| 682 |
\******************************************************************/ |
| 683 |
/***/ (function(module) { |
| 684 |
|
| 685 |
"use strict"; |
| 686 |
/** |
| 687 |
* Copyright (c) 2015, Facebook, Inc. |
| 688 |
* All rights reserved. |
| 689 |
* |
| 690 |
* This source code is licensed under the BSD-style license found in the |
| 691 |
* LICENSE file in the root directory of this source tree. An additional grant |
| 692 |
* of patent rights can be found in the PATENTS file in the same directory. |
| 693 |
* |
| 694 |
* @providesModule ExecutionEnvironment |
| 695 |
*/ |
| 696 |
|
| 697 |
/*jslint evil: true */ |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
var canUseDOM = !!( |
| 702 |
typeof window !== 'undefined' && |
| 703 |
window.document && |
| 704 |
window.document.createElement |
| 705 |
); |
| 706 |
|
| 707 |
/** |
| 708 |
* Simple, lightweight module assisting with the detection and context of |
| 709 |
* Worker. Helps avoid circular dependencies and allows code to reason about |
| 710 |
* whether or not they are in a Worker, even if they never include the main |
| 711 |
* `ReactWorker` dependency. |
| 712 |
*/ |
| 713 |
var ExecutionEnvironment = { |
| 714 |
|
| 715 |
canUseDOM: canUseDOM, |
| 716 |
|
| 717 |
canUseWorkers: typeof Worker !== 'undefined', |
| 718 |
|
| 719 |
canUseEventListeners: |
| 720 |
canUseDOM && !!(window.addEventListener || window.attachEvent), |
| 721 |
|
| 722 |
canUseViewport: canUseDOM && !!window.screen, |
| 723 |
|
| 724 |
isInWorker: !canUseDOM // For now, this is true - might change in the future. |
| 725 |
|
| 726 |
}; |
| 727 |
|
| 728 |
module.exports = ExecutionEnvironment; |
| 729 |
|
| 730 |
|
| 731 |
/***/ }), |
| 732 |
|
| 733 |
/***/ "./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js": |
| 734 |
/*!******************************************************************!*\ |
| 735 |
!*** ./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js ***! |
| 736 |
\******************************************************************/ |
| 737 |
/***/ (function(module) { |
| 738 |
|
| 739 |
/** |
| 740 |
* Copyright 2004-present Facebook. All Rights Reserved. |
| 741 |
* |
| 742 |
* @providesModule UserAgent_DEPRECATED |
| 743 |
*/ |
| 744 |
|
| 745 |
/** |
| 746 |
* Provides entirely client-side User Agent and OS detection. You should prefer |
| 747 |
* the non-deprecated UserAgent module when possible, which exposes our |
| 748 |
* authoritative server-side PHP-based detection to the client. |
| 749 |
* |
| 750 |
* Usage is straightforward: |
| 751 |
* |
| 752 |
* if (UserAgent_DEPRECATED.ie()) { |
| 753 |
* // IE |
| 754 |
* } |
| 755 |
* |
| 756 |
* You can also do version checks: |
| 757 |
* |
| 758 |
* if (UserAgent_DEPRECATED.ie() >= 7) { |
| 759 |
* // IE7 or better |
| 760 |
* } |
| 761 |
* |
| 762 |
* The browser functions will return NaN if the browser does not match, so |
| 763 |
* you can also do version compares the other way: |
| 764 |
* |
| 765 |
* if (UserAgent_DEPRECATED.ie() < 7) { |
| 766 |
* // IE6 or worse |
| 767 |
* } |
| 768 |
* |
| 769 |
* Note that the version is a float and may include a minor version number, |
| 770 |
* so you should always use range operators to perform comparisons, not |
| 771 |
* strict equality. |
| 772 |
* |
| 773 |
* **Note:** You should **strongly** prefer capability detection to browser |
| 774 |
* version detection where it's reasonable: |
| 775 |
* |
| 776 |
* http://www.quirksmode.org/js/support.html |
| 777 |
* |
| 778 |
* Further, we have a large number of mature wrapper functions and classes |
| 779 |
* which abstract away many browser irregularities. Check the documentation, |
| 780 |
* grep for things, or ask on javascript@lists.facebook.com before writing yet |
| 781 |
* another copy of "event || window.event". |
| 782 |
* |
| 783 |
*/ |
| 784 |
|
| 785 |
var _populated = false; |
| 786 |
|
| 787 |
// Browsers |
| 788 |
var _ie, _firefox, _opera, _webkit, _chrome; |
| 789 |
|
| 790 |
// Actual IE browser for compatibility mode |
| 791 |
var _ie_real_version; |
| 792 |
|
| 793 |
// Platforms |
| 794 |
var _osx, _windows, _linux, _android; |
| 795 |
|
| 796 |
// Architectures |
| 797 |
var _win64; |
| 798 |
|
| 799 |
// Devices |
| 800 |
var _iphone, _ipad, _native; |
| 801 |
|
| 802 |
var _mobile; |
| 803 |
|
| 804 |
function _populate() { |
| 805 |
if (_populated) { |
| 806 |
return; |
| 807 |
} |
| 808 |
|
| 809 |
_populated = true; |
| 810 |
|
| 811 |
// To work around buggy JS libraries that can't handle multi-digit |
| 812 |
// version numbers, Opera 10's user agent string claims it's Opera |
| 813 |
// 9, then later includes a Version/X.Y field: |
| 814 |
// |
| 815 |
// Opera/9.80 (foo) Presto/2.2.15 Version/10.10 |
| 816 |
var uas = navigator.userAgent; |
| 817 |
var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas); |
| 818 |
var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas); |
| 819 |
|
| 820 |
_iphone = /\b(iPhone|iP[ao]d)/.exec(uas); |
| 821 |
_ipad = /\b(iP[ao]d)/.exec(uas); |
| 822 |
_android = /Android/i.exec(uas); |
| 823 |
_native = /FBAN\/\w+;/i.exec(uas); |
| 824 |
_mobile = /Mobile/i.exec(uas); |
| 825 |
|
| 826 |
// Note that the IE team blog would have you believe you should be checking |
| 827 |
// for 'Win64; x64'. But MSDN then reveals that you can actually be coming |
| 828 |
// from either x64 or ia64; so ultimately, you should just check for Win64 |
| 829 |
// as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit |
| 830 |
// Windows will send 'WOW64' instead. |
| 831 |
_win64 = !!(/Win64/.exec(uas)); |
| 832 |
|
| 833 |
if (agent) { |
| 834 |
_ie = agent[1] ? parseFloat(agent[1]) : ( |
| 835 |
agent[5] ? parseFloat(agent[5]) : NaN); |
| 836 |
// IE compatibility mode |
| 837 |
if (_ie && document && document.documentMode) { |
| 838 |
_ie = document.documentMode; |
| 839 |
} |
| 840 |
// grab the "true" ie version from the trident token if available |
| 841 |
var trident = /(?:Trident\/(\d+.\d+))/.exec(uas); |
| 842 |
_ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie; |
| 843 |
|
| 844 |
_firefox = agent[2] ? parseFloat(agent[2]) : NaN; |
| 845 |
_opera = agent[3] ? parseFloat(agent[3]) : NaN; |
| 846 |
_webkit = agent[4] ? parseFloat(agent[4]) : NaN; |
| 847 |
if (_webkit) { |
| 848 |
// We do not add the regexp to the above test, because it will always |
| 849 |
// match 'safari' only since 'AppleWebKit' appears before 'Chrome' in |
| 850 |
// the userAgent string. |
| 851 |
agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas); |
| 852 |
_chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN; |
| 853 |
} else { |
| 854 |
_chrome = NaN; |
| 855 |
} |
| 856 |
} else { |
| 857 |
_ie = _firefox = _opera = _chrome = _webkit = NaN; |
| 858 |
} |
| 859 |
|
| 860 |
if (os) { |
| 861 |
if (os[1]) { |
| 862 |
// Detect OS X version. If no version number matches, set _osx to true. |
| 863 |
// Version examples: 10, 10_6_1, 10.7 |
| 864 |
// Parses version number as a float, taking only first two sets of |
| 865 |
// digits. If only one set of digits is found, returns just the major |
| 866 |
// version number. |
| 867 |
var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas); |
| 868 |
|
| 869 |
_osx = ver ? parseFloat(ver[1].replace('_', '.')) : true; |
| 870 |
} else { |
| 871 |
_osx = false; |
| 872 |
} |
| 873 |
_windows = !!os[2]; |
| 874 |
_linux = !!os[3]; |
| 875 |
} else { |
| 876 |
_osx = _windows = _linux = false; |
| 877 |
} |
| 878 |
} |
| 879 |
|
| 880 |
var UserAgent_DEPRECATED = { |
| 881 |
|
| 882 |
/** |
| 883 |
* Check if the UA is Internet Explorer. |
| 884 |
* |
| 885 |
* |
| 886 |
* @return float|NaN Version number (if match) or NaN. |
| 887 |
*/ |
| 888 |
ie: function() { |
| 889 |
return _populate() || _ie; |
| 890 |
}, |
| 891 |
|
| 892 |
/** |
| 893 |
* Check if we're in Internet Explorer compatibility mode. |
| 894 |
* |
| 895 |
* @return bool true if in compatibility mode, false if |
| 896 |
* not compatibility mode or not ie |
| 897 |
*/ |
| 898 |
ieCompatibilityMode: function() { |
| 899 |
return _populate() || (_ie_real_version > _ie); |
| 900 |
}, |
| 901 |
|
| 902 |
|
| 903 |
/** |
| 904 |
* Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we |
| 905 |
* only need this because Skype can't handle 64-bit IE yet. We need to remove |
| 906 |
* this when we don't need it -- tracked by #601957. |
| 907 |
*/ |
| 908 |
ie64: function() { |
| 909 |
return UserAgent_DEPRECATED.ie() && _win64; |
| 910 |
}, |
| 911 |
|
| 912 |
/** |
| 913 |
* Check if the UA is Firefox. |
| 914 |
* |
| 915 |
* |
| 916 |
* @return float|NaN Version number (if match) or NaN. |
| 917 |
*/ |
| 918 |
firefox: function() { |
| 919 |
return _populate() || _firefox; |
| 920 |
}, |
| 921 |
|
| 922 |
|
| 923 |
/** |
| 924 |
* Check if the UA is Opera. |
| 925 |
* |
| 926 |
* |
| 927 |
* @return float|NaN Version number (if match) or NaN. |
| 928 |
*/ |
| 929 |
opera: function() { |
| 930 |
return _populate() || _opera; |
| 931 |
}, |
| 932 |
|
| 933 |
|
| 934 |
/** |
| 935 |
* Check if the UA is WebKit. |
| 936 |
* |
| 937 |
* |
| 938 |
* @return float|NaN Version number (if match) or NaN. |
| 939 |
*/ |
| 940 |
webkit: function() { |
| 941 |
return _populate() || _webkit; |
| 942 |
}, |
| 943 |
|
| 944 |
/** |
| 945 |
* For Push |
| 946 |
* WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit |
| 947 |
*/ |
| 948 |
safari: function() { |
| 949 |
return UserAgent_DEPRECATED.webkit(); |
| 950 |
}, |
| 951 |
|
| 952 |
/** |
| 953 |
* Check if the UA is a Chrome browser. |
| 954 |
* |
| 955 |
* |
| 956 |
* @return float|NaN Version number (if match) or NaN. |
| 957 |
*/ |
| 958 |
chrome : function() { |
| 959 |
return _populate() || _chrome; |
| 960 |
}, |
| 961 |
|
| 962 |
|
| 963 |
/** |
| 964 |
* Check if the user is running Windows. |
| 965 |
* |
| 966 |
* @return bool `true' if the user's OS is Windows. |
| 967 |
*/ |
| 968 |
windows: function() { |
| 969 |
return _populate() || _windows; |
| 970 |
}, |
| 971 |
|
| 972 |
|
| 973 |
/** |
| 974 |
* Check if the user is running Mac OS X. |
| 975 |
* |
| 976 |
* @return float|bool Returns a float if a version number is detected, |
| 977 |
* otherwise true/false. |
| 978 |
*/ |
| 979 |
osx: function() { |
| 980 |
return _populate() || _osx; |
| 981 |
}, |
| 982 |
|
| 983 |
/** |
| 984 |
* Check if the user is running Linux. |
| 985 |
* |
| 986 |
* @return bool `true' if the user's OS is some flavor of Linux. |
| 987 |
*/ |
| 988 |
linux: function() { |
| 989 |
return _populate() || _linux; |
| 990 |
}, |
| 991 |
|
| 992 |
/** |
| 993 |
* Check if the user is running on an iPhone or iPod platform. |
| 994 |
* |
| 995 |
* @return bool `true' if the user is running some flavor of the |
| 996 |
* iPhone OS. |
| 997 |
*/ |
| 998 |
iphone: function() { |
| 999 |
return _populate() || _iphone; |
| 1000 |
}, |
| 1001 |
|
| 1002 |
mobile: function() { |
| 1003 |
return _populate() || (_iphone || _ipad || _android || _mobile); |
| 1004 |
}, |
| 1005 |
|
| 1006 |
nativeApp: function() { |
| 1007 |
// webviews inside of the native apps |
| 1008 |
return _populate() || _native; |
| 1009 |
}, |
| 1010 |
|
| 1011 |
android: function() { |
| 1012 |
return _populate() || _android; |
| 1013 |
}, |
| 1014 |
|
| 1015 |
ipad: function() { |
| 1016 |
return _populate() || _ipad; |
| 1017 |
} |
| 1018 |
}; |
| 1019 |
|
| 1020 |
module.exports = UserAgent_DEPRECATED; |
| 1021 |
|
| 1022 |
|
| 1023 |
/***/ }), |
| 1024 |
|
| 1025 |
/***/ "./node_modules/normalize-wheel/src/isEventSupported.js": |
| 1026 |
/*!**************************************************************!*\ |
| 1027 |
!*** ./node_modules/normalize-wheel/src/isEventSupported.js ***! |
| 1028 |
\**************************************************************/ |
| 1029 |
/***/ (function(module, __unused_webpack_exports, __webpack_require__) { |
| 1030 |
|
| 1031 |
"use strict"; |
| 1032 |
/** |
| 1033 |
* Copyright 2013-2015, Facebook, Inc. |
| 1034 |
* All rights reserved. |
| 1035 |
* |
| 1036 |
* This source code is licensed under the BSD-style license found in the |
| 1037 |
* LICENSE file in the root directory of this source tree. An additional grant |
| 1038 |
* of patent rights can be found in the PATENTS file in the same directory. |
| 1039 |
* |
| 1040 |
* @providesModule isEventSupported |
| 1041 |
*/ |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
var ExecutionEnvironment = __webpack_require__(/*! ./ExecutionEnvironment */ "./node_modules/normalize-wheel/src/ExecutionEnvironment.js"); |
| 1046 |
|
| 1047 |
var useHasFeature; |
| 1048 |
if (ExecutionEnvironment.canUseDOM) { |
| 1049 |
useHasFeature = |
| 1050 |
document.implementation && |
| 1051 |
document.implementation.hasFeature && |
| 1052 |
// always returns true in newer browsers as per the standard. |
| 1053 |
// @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature |
| 1054 |
document.implementation.hasFeature('', '') !== true; |
| 1055 |
} |
| 1056 |
|
| 1057 |
/** |
| 1058 |
* Checks if an event is supported in the current execution environment. |
| 1059 |
* |
| 1060 |
* NOTE: This will not work correctly for non-generic events such as `change`, |
| 1061 |
* `reset`, `load`, `error`, and `select`. |
| 1062 |
* |
| 1063 |
* Borrows from Modernizr. |
| 1064 |
* |
| 1065 |
* @param {string} eventNameSuffix Event name, e.g. "click". |
| 1066 |
* @param {?boolean} capture Check if the capture phase is supported. |
| 1067 |
* @return {boolean} True if the event is supported. |
| 1068 |
* @internal |
| 1069 |
* @license Modernizr 3.0.0pre (Custom Build) | MIT |
| 1070 |
*/ |
| 1071 |
function isEventSupported(eventNameSuffix, capture) { |
| 1072 |
if (!ExecutionEnvironment.canUseDOM || |
| 1073 |
capture && !('addEventListener' in document)) { |
| 1074 |
return false; |
| 1075 |
} |
| 1076 |
|
| 1077 |
var eventName = 'on' + eventNameSuffix; |
| 1078 |
var isSupported = eventName in document; |
| 1079 |
|
| 1080 |
if (!isSupported) { |
| 1081 |
var element = document.createElement('div'); |
| 1082 |
element.setAttribute(eventName, 'return;'); |
| 1083 |
isSupported = typeof element[eventName] === 'function'; |
| 1084 |
} |
| 1085 |
|
| 1086 |
if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') { |
| 1087 |
// This is the only way to test support for the `wheel` event in IE9+. |
| 1088 |
isSupported = document.implementation.hasFeature('Events.wheel', '3.0'); |
| 1089 |
} |
| 1090 |
|
| 1091 |
return isSupported; |
| 1092 |
} |
| 1093 |
|
| 1094 |
module.exports = isEventSupported; |
| 1095 |
|
| 1096 |
|
| 1097 |
/***/ }), |
| 1098 |
|
| 1099 |
/***/ "./node_modules/normalize-wheel/src/normalizeWheel.js": |
| 1100 |
/*!************************************************************!*\ |
| 1101 |
!*** ./node_modules/normalize-wheel/src/normalizeWheel.js ***! |
| 1102 |
\************************************************************/ |
| 1103 |
/***/ (function(module, __unused_webpack_exports, __webpack_require__) { |
| 1104 |
|
| 1105 |
"use strict"; |
| 1106 |
/** |
| 1107 |
* Copyright (c) 2015, Facebook, Inc. |
| 1108 |
* All rights reserved. |
| 1109 |
* |
| 1110 |
* This source code is licensed under the BSD-style license found in the |
| 1111 |
* LICENSE file in the root directory of this source tree. An additional grant |
| 1112 |
* of patent rights can be found in the PATENTS file in the same directory. |
| 1113 |
* |
| 1114 |
* @providesModule normalizeWheel |
| 1115 |
* @typechecks |
| 1116 |
*/ |
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
var UserAgent_DEPRECATED = __webpack_require__(/*! ./UserAgent_DEPRECATED */ "./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js"); |
| 1121 |
|
| 1122 |
var isEventSupported = __webpack_require__(/*! ./isEventSupported */ "./node_modules/normalize-wheel/src/isEventSupported.js"); |
| 1123 |
|
| 1124 |
|
| 1125 |
// Reasonable defaults |
| 1126 |
var PIXEL_STEP = 10; |
| 1127 |
var LINE_HEIGHT = 40; |
| 1128 |
var PAGE_HEIGHT = 800; |
| 1129 |
|
| 1130 |
/** |
| 1131 |
* Mouse wheel (and 2-finger trackpad) support on the web sucks. It is |
| 1132 |
* complicated, thus this doc is long and (hopefully) detailed enough to answer |
| 1133 |
* your questions. |
| 1134 |
* |
| 1135 |
* If you need to react to the mouse wheel in a predictable way, this code is |
| 1136 |
* like your bestest friend. * hugs * |
| 1137 |
* |
| 1138 |
* As of today, there are 4 DOM event types you can listen to: |
| 1139 |
* |
| 1140 |
* 'wheel' -- Chrome(31+), FF(17+), IE(9+) |
| 1141 |
* 'mousewheel' -- Chrome, IE(6+), Opera, Safari |
| 1142 |
* 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother! |
| 1143 |
* 'DOMMouseScroll' -- FF(0.9.7+) since 2003 |
| 1144 |
* |
| 1145 |
* So what to do? The is the best: |
| 1146 |
* |
| 1147 |
* normalizeWheel.getEventType(); |
| 1148 |
* |
| 1149 |
* In your event callback, use this code to get sane interpretation of the |
| 1150 |
* deltas. This code will return an object with properties: |
| 1151 |
* |
| 1152 |
* spinX -- normalized spin speed (use for zoom) - x plane |
| 1153 |
* spinY -- " - y plane |
| 1154 |
* pixelX -- normalized distance (to pixels) - x plane |
| 1155 |
* pixelY -- " - y plane |
| 1156 |
* |
| 1157 |
* Wheel values are provided by the browser assuming you are using the wheel to |
| 1158 |
* scroll a web page by a number of lines or pixels (or pages). Values can vary |
| 1159 |
* significantly on different platforms and browsers, forgetting that you can |
| 1160 |
* scroll at different speeds. Some devices (like trackpads) emit more events |
| 1161 |
* at smaller increments with fine granularity, and some emit massive jumps with |
| 1162 |
* linear speed or acceleration. |
| 1163 |
* |
| 1164 |
* This code does its best to normalize the deltas for you: |
| 1165 |
* |
| 1166 |
* - spin is trying to normalize how far the wheel was spun (or trackpad |
| 1167 |
* dragged). This is super useful for zoom support where you want to |
| 1168 |
* throw away the chunky scroll steps on the PC and make those equal to |
| 1169 |
* the slow and smooth tiny steps on the Mac. Key data: This code tries to |
| 1170 |
* resolve a single slow step on a wheel to 1. |
| 1171 |
* |
| 1172 |
* - pixel is normalizing the desired scroll delta in pixel units. You'll |
| 1173 |
* get the crazy differences between browsers, but at least it'll be in |
| 1174 |
* pixels! |
| 1175 |
* |
| 1176 |
* - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This |
| 1177 |
* should translate to positive value zooming IN, negative zooming OUT. |
| 1178 |
* This matches the newer 'wheel' event. |
| 1179 |
* |
| 1180 |
* Why are there spinX, spinY (or pixels)? |
| 1181 |
* |
| 1182 |
* - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn |
| 1183 |
* with a mouse. It results in side-scrolling in the browser by default. |
| 1184 |
* |
| 1185 |
* - spinY is what you expect -- it's the classic axis of a mouse wheel. |
| 1186 |
* |
| 1187 |
* - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and |
| 1188 |
* probably is by browsers in conjunction with fancy 3D controllers .. but |
| 1189 |
* you know. |
| 1190 |
* |
| 1191 |
* Implementation info: |
| 1192 |
* |
| 1193 |
* Examples of 'wheel' event if you scroll slowly (down) by one step with an |
| 1194 |
* average mouse: |
| 1195 |
* |
| 1196 |
* OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120) |
| 1197 |
* OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12) |
| 1198 |
* OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A) |
| 1199 |
* Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120) |
| 1200 |
* Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120) |
| 1201 |
* |
| 1202 |
* On the trackpad: |
| 1203 |
* |
| 1204 |
* OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6) |
| 1205 |
* OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A) |
| 1206 |
* |
| 1207 |
* On other/older browsers.. it's more complicated as there can be multiple and |
| 1208 |
* also missing delta values. |
| 1209 |
* |
| 1210 |
* The 'wheel' event is more standard: |
| 1211 |
* |
| 1212 |
* http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents |
| 1213 |
* |
| 1214 |
* The basics is that it includes a unit, deltaMode (pixels, lines, pages), and |
| 1215 |
* deltaX, deltaY and deltaZ. Some browsers provide other values to maintain |
| 1216 |
* backward compatibility with older events. Those other values help us |
| 1217 |
* better normalize spin speed. Example of what the browsers provide: |
| 1218 |
* |
| 1219 |
* | event.wheelDelta | event.detail |
| 1220 |
* ------------------+------------------+-------------- |
| 1221 |
* Safari v5/OS X | -120 | 0 |
| 1222 |
* Safari v5/Win7 | -120 | 0 |
| 1223 |
* Chrome v17/OS X | -120 | 0 |
| 1224 |
* Chrome v17/Win7 | -120 | 0 |
| 1225 |
* IE9/Win7 | -120 | undefined |
| 1226 |
* Firefox v4/OS X | undefined | 1 |
| 1227 |
* Firefox v4/Win7 | undefined | 3 |
| 1228 |
* |
| 1229 |
*/ |
| 1230 |
function normalizeWheel(/*object*/ event) /*object*/ { |
| 1231 |
var sX = 0, sY = 0, // spinX, spinY |
| 1232 |
pX = 0, pY = 0; // pixelX, pixelY |
| 1233 |
|
| 1234 |
// Legacy |
| 1235 |
if ('detail' in event) { sY = event.detail; } |
| 1236 |
if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; } |
| 1237 |
if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; } |
| 1238 |
if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; } |
| 1239 |
|
| 1240 |
// side scrolling on FF with DOMMouseScroll |
| 1241 |
if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) { |
| 1242 |
sX = sY; |
| 1243 |
sY = 0; |
| 1244 |
} |
| 1245 |
|
| 1246 |
pX = sX * PIXEL_STEP; |
| 1247 |
pY = sY * PIXEL_STEP; |
| 1248 |
|
| 1249 |
if ('deltaY' in event) { pY = event.deltaY; } |
| 1250 |
if ('deltaX' in event) { pX = event.deltaX; } |
| 1251 |
|
| 1252 |
if ((pX || pY) && event.deltaMode) { |
| 1253 |
if (event.deltaMode == 1) { // delta in LINE units |
| 1254 |
pX *= LINE_HEIGHT; |
| 1255 |
pY *= LINE_HEIGHT; |
| 1256 |
} else { // delta in PAGE units |
| 1257 |
pX *= PAGE_HEIGHT; |
| 1258 |
pY *= PAGE_HEIGHT; |
| 1259 |
} |
| 1260 |
} |
| 1261 |
|
| 1262 |
// Fall-back if spin cannot be determined |
| 1263 |
if (pX && !sX) { sX = (pX < 1) ? -1 : 1; } |
| 1264 |
if (pY && !sY) { sY = (pY < 1) ? -1 : 1; } |
| 1265 |
|
| 1266 |
return { spinX : sX, |
| 1267 |
spinY : sY, |
| 1268 |
pixelX : pX, |
| 1269 |
pixelY : pY }; |
| 1270 |
} |
| 1271 |
|
| 1272 |
|
| 1273 |
/** |
| 1274 |
* The best combination if you prefer spinX + spinY normalization. It favors |
| 1275 |
* the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with |
| 1276 |
* 'wheel' event, making spin speed determination impossible. |
| 1277 |
*/ |
| 1278 |
normalizeWheel.getEventType = function() /*string*/ { |
| 1279 |
return (UserAgent_DEPRECATED.firefox()) |
| 1280 |
? 'DOMMouseScroll' |
| 1281 |
: (isEventSupported('wheel')) |
| 1282 |
? 'wheel' |
| 1283 |
: 'mousewheel'; |
| 1284 |
}; |
| 1285 |
|
| 1286 |
module.exports = normalizeWheel; |
| 1287 |
|
| 1288 |
|
| 1289 |
/***/ }), |
| 1290 |
|
| 1291 |
/***/ "./node_modules/react-easy-crop/index.module.js": |
| 1292 |
/*!******************************************************!*\ |
| 1293 |
!*** ./node_modules/react-easy-crop/index.module.js ***! |
| 1294 |
\******************************************************/ |
| 1295 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 1296 |
|
| 1297 |
"use strict"; |
| 1298 |
__webpack_require__.r(__webpack_exports__); |
| 1299 |
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js"); |
| 1300 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); |
| 1301 |
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); |
| 1302 |
/* harmony import */ var normalize_wheel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! normalize-wheel */ "./node_modules/normalize-wheel/index.js"); |
| 1303 |
/* harmony import */ var normalize_wheel__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(normalize_wheel__WEBPACK_IMPORTED_MODULE_1__); |
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
/** |
| 1309 |
* Compute the dimension of the crop area based on media size, |
| 1310 |
* aspect ratio and optionally rotation |
| 1311 |
*/ |
| 1312 |
|
| 1313 |
function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) { |
| 1314 |
if (rotation === void 0) { |
| 1315 |
rotation = 0; |
| 1316 |
} |
| 1317 |
|
| 1318 |
var _a = rotateSize(mediaWidth, mediaHeight, rotation), |
| 1319 |
width = _a.width, |
| 1320 |
height = _a.height; |
| 1321 |
|
| 1322 |
var fittingWidth = Math.min(width, containerWidth); |
| 1323 |
var fittingHeight = Math.min(height, containerHeight); |
| 1324 |
|
| 1325 |
if (fittingWidth > fittingHeight * aspect) { |
| 1326 |
return { |
| 1327 |
width: fittingHeight * aspect, |
| 1328 |
height: fittingHeight |
| 1329 |
}; |
| 1330 |
} |
| 1331 |
|
| 1332 |
return { |
| 1333 |
width: fittingWidth, |
| 1334 |
height: fittingWidth / aspect |
| 1335 |
}; |
| 1336 |
} |
| 1337 |
/** |
| 1338 |
* Compute media zoom. |
| 1339 |
* We fit the media into the container with "max-width: 100%; max-height: 100%;" |
| 1340 |
*/ |
| 1341 |
|
| 1342 |
function getMediaZoom(mediaSize) { |
| 1343 |
// Take the axis with more pixels to improve accuracy |
| 1344 |
return mediaSize.width > mediaSize.height ? mediaSize.width / mediaSize.naturalWidth : mediaSize.height / mediaSize.naturalHeight; |
| 1345 |
} |
| 1346 |
/** |
| 1347 |
* Ensure a new media position stays in the crop area. |
| 1348 |
*/ |
| 1349 |
|
| 1350 |
function restrictPosition(position, mediaSize, cropSize, zoom, rotation) { |
| 1351 |
if (rotation === void 0) { |
| 1352 |
rotation = 0; |
| 1353 |
} |
| 1354 |
|
| 1355 |
var _a = rotateSize(mediaSize.width, mediaSize.height, rotation), |
| 1356 |
width = _a.width, |
| 1357 |
height = _a.height; |
| 1358 |
|
| 1359 |
return { |
| 1360 |
x: restrictPositionCoord(position.x, width, cropSize.width, zoom), |
| 1361 |
y: restrictPositionCoord(position.y, height, cropSize.height, zoom) |
| 1362 |
}; |
| 1363 |
} |
| 1364 |
|
| 1365 |
function restrictPositionCoord(position, mediaSize, cropSize, zoom) { |
| 1366 |
var maxPosition = mediaSize * zoom / 2 - cropSize / 2; |
| 1367 |
return clamp(position, -maxPosition, maxPosition); |
| 1368 |
} |
| 1369 |
|
| 1370 |
function getDistanceBetweenPoints(pointA, pointB) { |
| 1371 |
return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2)); |
| 1372 |
} |
| 1373 |
function getRotationBetweenPoints(pointA, pointB) { |
| 1374 |
return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI; |
| 1375 |
} |
| 1376 |
/** |
| 1377 |
* Compute the output cropped area of the media in percentages and pixels. |
| 1378 |
* x/y are the top-left coordinates on the src media |
| 1379 |
*/ |
| 1380 |
|
| 1381 |
function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition) { |
| 1382 |
if (rotation === void 0) { |
| 1383 |
rotation = 0; |
| 1384 |
} |
| 1385 |
|
| 1386 |
if (restrictPosition === void 0) { |
| 1387 |
restrictPosition = true; |
| 1388 |
} // if the media is rotated by the user, we cannot limit the position anymore |
| 1389 |
// as it might need to be negative. |
| 1390 |
|
| 1391 |
|
| 1392 |
var limitAreaFn = restrictPosition ? limitArea : noOp; |
| 1393 |
var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); |
| 1394 |
var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); // calculate the crop area in percentages |
| 1395 |
// in the rotated space |
| 1396 |
|
| 1397 |
var croppedAreaPercentages = { |
| 1398 |
x: limitAreaFn(100, ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100), |
| 1399 |
y: limitAreaFn(100, ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100), |
| 1400 |
width: limitAreaFn(100, cropSize.width / mediaBBoxSize.width * 100 / zoom), |
| 1401 |
height: limitAreaFn(100, cropSize.height / mediaBBoxSize.height * 100 / zoom) |
| 1402 |
}; // we compute the pixels size naively |
| 1403 |
|
| 1404 |
var widthInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.width, croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100)); |
| 1405 |
var heightInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.height, croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100)); |
| 1406 |
var isImgWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect; // then we ensure the width and height exactly match the aspect (to avoid rounding approximations) |
| 1407 |
// if the media is wider than high, when zoom is 0, the crop height will be equals to image height |
| 1408 |
// thus we want to compute the width from the height and aspect for accuracy. |
| 1409 |
// Otherwise, we compute the height from width and aspect. |
| 1410 |
|
| 1411 |
var sizePixels = isImgWiderThanHigh ? { |
| 1412 |
width: Math.round(heightInPixels * aspect), |
| 1413 |
height: heightInPixels |
| 1414 |
} : { |
| 1415 |
width: widthInPixels, |
| 1416 |
height: Math.round(widthInPixels / aspect) |
| 1417 |
}; |
| 1418 |
|
| 1419 |
var croppedAreaPixels = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, sizePixels), { |
| 1420 |
x: Math.round(limitAreaFn(mediaNaturalBBoxSize.width - sizePixels.width, croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100)), |
| 1421 |
y: Math.round(limitAreaFn(mediaNaturalBBoxSize.height - sizePixels.height, croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100)) |
| 1422 |
}); |
| 1423 |
|
| 1424 |
return { |
| 1425 |
croppedAreaPercentages: croppedAreaPercentages, |
| 1426 |
croppedAreaPixels: croppedAreaPixels |
| 1427 |
}; |
| 1428 |
} |
| 1429 |
/** |
| 1430 |
* Ensure the returned value is between 0 and max |
| 1431 |
*/ |
| 1432 |
|
| 1433 |
function limitArea(max, value) { |
| 1434 |
return Math.min(max, Math.max(0, value)); |
| 1435 |
} |
| 1436 |
|
| 1437 |
function noOp(_max, value) { |
| 1438 |
return value; |
| 1439 |
} |
| 1440 |
/** |
| 1441 |
* Compute crop and zoom from the croppedAreaPercentages. |
| 1442 |
*/ |
| 1443 |
|
| 1444 |
|
| 1445 |
function getInitialCropFromCroppedAreaPercentages(croppedAreaPercentages, mediaSize, rotation, cropSize, minZoom, maxZoom) { |
| 1446 |
var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); // This is the inverse process of computeCroppedArea |
| 1447 |
|
| 1448 |
var zoom = clamp(cropSize.width / mediaBBoxSize.width * (100 / croppedAreaPercentages.width), minZoom, maxZoom); |
| 1449 |
var crop = { |
| 1450 |
x: zoom * mediaBBoxSize.width / 2 - cropSize.width / 2 - mediaBBoxSize.width * zoom * (croppedAreaPercentages.x / 100), |
| 1451 |
y: zoom * mediaBBoxSize.height / 2 - cropSize.height / 2 - mediaBBoxSize.height * zoom * (croppedAreaPercentages.y / 100) |
| 1452 |
}; |
| 1453 |
return { |
| 1454 |
crop: crop, |
| 1455 |
zoom: zoom |
| 1456 |
}; |
| 1457 |
} |
| 1458 |
/** |
| 1459 |
* Compute zoom from the croppedAreaPixels |
| 1460 |
*/ |
| 1461 |
|
| 1462 |
function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) { |
| 1463 |
var mediaZoom = getMediaZoom(mediaSize); |
| 1464 |
return cropSize.height > cropSize.width ? cropSize.height / (croppedAreaPixels.height * mediaZoom) : cropSize.width / (croppedAreaPixels.width * mediaZoom); |
| 1465 |
} |
| 1466 |
/** |
| 1467 |
* Compute crop and zoom from the croppedAreaPixels |
| 1468 |
*/ |
| 1469 |
|
| 1470 |
|
| 1471 |
function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, rotation, cropSize, minZoom, maxZoom) { |
| 1472 |
if (rotation === void 0) { |
| 1473 |
rotation = 0; |
| 1474 |
} |
| 1475 |
|
| 1476 |
var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); |
| 1477 |
var zoom = clamp(getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize), minZoom, maxZoom); |
| 1478 |
var cropZoom = cropSize.height > cropSize.width ? cropSize.height / croppedAreaPixels.height : cropSize.width / croppedAreaPixels.width; |
| 1479 |
var crop = { |
| 1480 |
x: ((mediaNaturalBBoxSize.width - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom, |
| 1481 |
y: ((mediaNaturalBBoxSize.height - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom |
| 1482 |
}; |
| 1483 |
return { |
| 1484 |
crop: crop, |
| 1485 |
zoom: zoom |
| 1486 |
}; |
| 1487 |
} |
| 1488 |
/** |
| 1489 |
* Return the point that is the center of point a and b |
| 1490 |
*/ |
| 1491 |
|
| 1492 |
function getCenter(a, b) { |
| 1493 |
return { |
| 1494 |
x: (b.x + a.x) / 2, |
| 1495 |
y: (b.y + a.y) / 2 |
| 1496 |
}; |
| 1497 |
} |
| 1498 |
function getRadianAngle(degreeValue) { |
| 1499 |
return degreeValue * Math.PI / 180; |
| 1500 |
} |
| 1501 |
/** |
| 1502 |
* Returns the new bounding area of a rotated rectangle. |
| 1503 |
*/ |
| 1504 |
|
| 1505 |
function rotateSize(width, height, rotation) { |
| 1506 |
var rotRad = getRadianAngle(rotation); |
| 1507 |
return { |
| 1508 |
width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), |
| 1509 |
height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height) |
| 1510 |
}; |
| 1511 |
} |
| 1512 |
/** |
| 1513 |
* Clamp value between min and max |
| 1514 |
*/ |
| 1515 |
|
| 1516 |
function clamp(value, min, max) { |
| 1517 |
return Math.min(Math.max(value, min), max); |
| 1518 |
} |
| 1519 |
/** |
| 1520 |
* Combine multiple class names into a single string. |
| 1521 |
*/ |
| 1522 |
|
| 1523 |
function classNames() { |
| 1524 |
var args = []; |
| 1525 |
|
| 1526 |
for (var _i = 0; _i < arguments.length; _i++) { |
| 1527 |
args[_i] = arguments[_i]; |
| 1528 |
} |
| 1529 |
|
| 1530 |
return args.filter(function (value) { |
| 1531 |
if (typeof value === 'string' && value.length > 0) { |
| 1532 |
return true; |
| 1533 |
} |
| 1534 |
|
| 1535 |
return false; |
| 1536 |
}).join(' ').trim(); |
| 1537 |
} |
| 1538 |
|
| 1539 |
var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n"; |
| 1540 |
|
| 1541 |
var MIN_ZOOM = 1; |
| 1542 |
var MAX_ZOOM = 3; |
| 1543 |
|
| 1544 |
var Cropper = |
| 1545 |
/** @class */ |
| 1546 |
function (_super) { |
| 1547 |
(0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(Cropper, _super); |
| 1548 |
|
| 1549 |
function Cropper() { |
| 1550 |
var _this = _super !== null && _super.apply(this, arguments) || this; |
| 1551 |
|
| 1552 |
_this.imageRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createRef(); |
| 1553 |
_this.videoRef = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createRef(); |
| 1554 |
_this.containerRef = null; |
| 1555 |
_this.styleRef = null; |
| 1556 |
_this.containerRect = null; |
| 1557 |
_this.mediaSize = { |
| 1558 |
width: 0, |
| 1559 |
height: 0, |
| 1560 |
naturalWidth: 0, |
| 1561 |
naturalHeight: 0 |
| 1562 |
}; |
| 1563 |
_this.dragStartPosition = { |
| 1564 |
x: 0, |
| 1565 |
y: 0 |
| 1566 |
}; |
| 1567 |
_this.dragStartCrop = { |
| 1568 |
x: 0, |
| 1569 |
y: 0 |
| 1570 |
}; |
| 1571 |
_this.lastPinchDistance = 0; |
| 1572 |
_this.lastPinchRotation = 0; |
| 1573 |
_this.rafDragTimeout = null; |
| 1574 |
_this.rafPinchTimeout = null; |
| 1575 |
_this.wheelTimer = null; |
| 1576 |
_this.state = { |
| 1577 |
cropSize: null, |
| 1578 |
hasWheelJustStarted: false |
| 1579 |
}; // this is to prevent Safari on iOS >= 10 to zoom the page |
| 1580 |
|
| 1581 |
_this.preventZoomSafari = function (e) { |
| 1582 |
return e.preventDefault(); |
| 1583 |
}; |
| 1584 |
|
| 1585 |
_this.cleanEvents = function () { |
| 1586 |
document.removeEventListener('mousemove', _this.onMouseMove); |
| 1587 |
document.removeEventListener('mouseup', _this.onDragStopped); |
| 1588 |
document.removeEventListener('touchmove', _this.onTouchMove); |
| 1589 |
document.removeEventListener('touchend', _this.onDragStopped); |
| 1590 |
}; |
| 1591 |
|
| 1592 |
_this.clearScrollEvent = function () { |
| 1593 |
if (_this.containerRef) _this.containerRef.removeEventListener('wheel', _this.onWheel); |
| 1594 |
|
| 1595 |
if (_this.wheelTimer) { |
| 1596 |
clearTimeout(_this.wheelTimer); |
| 1597 |
} |
| 1598 |
}; |
| 1599 |
|
| 1600 |
_this.onMediaLoad = function () { |
| 1601 |
var cropSize = _this.computeSizes(); |
| 1602 |
|
| 1603 |
if (cropSize) { |
| 1604 |
_this.emitCropData(); |
| 1605 |
|
| 1606 |
_this.setInitialCrop(cropSize); |
| 1607 |
} |
| 1608 |
|
| 1609 |
if (_this.props.onMediaLoaded) { |
| 1610 |
_this.props.onMediaLoaded(_this.mediaSize); |
| 1611 |
} |
| 1612 |
}; |
| 1613 |
|
| 1614 |
_this.setInitialCrop = function (cropSize) { |
| 1615 |
if (_this.props.initialCroppedAreaPercentages) { |
| 1616 |
var _a = getInitialCropFromCroppedAreaPercentages(_this.props.initialCroppedAreaPercentages, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), |
| 1617 |
crop = _a.crop, |
| 1618 |
zoom = _a.zoom; |
| 1619 |
|
| 1620 |
_this.props.onCropChange(crop); |
| 1621 |
|
| 1622 |
_this.props.onZoomChange && _this.props.onZoomChange(zoom); |
| 1623 |
} else if (_this.props.initialCroppedAreaPixels) { |
| 1624 |
var _b = getInitialCropFromCroppedAreaPixels(_this.props.initialCroppedAreaPixels, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), |
| 1625 |
crop = _b.crop, |
| 1626 |
zoom = _b.zoom; |
| 1627 |
|
| 1628 |
_this.props.onCropChange(crop); |
| 1629 |
|
| 1630 |
_this.props.onZoomChange && _this.props.onZoomChange(zoom); |
| 1631 |
} |
| 1632 |
}; |
| 1633 |
|
| 1634 |
_this.computeSizes = function () { |
| 1635 |
var _a, _b, _c, _d, _e, _f; |
| 1636 |
|
| 1637 |
var mediaRef = _this.imageRef.current || _this.videoRef.current; |
| 1638 |
|
| 1639 |
if (mediaRef && _this.containerRef) { |
| 1640 |
_this.containerRect = _this.containerRef.getBoundingClientRect(); |
| 1641 |
var containerAspect = _this.containerRect.width / _this.containerRect.height; |
| 1642 |
var naturalWidth = ((_a = _this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0; |
| 1643 |
var naturalHeight = ((_c = _this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0; |
| 1644 |
var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight; |
| 1645 |
var mediaAspect = naturalWidth / naturalHeight; // We do not rely on the offsetWidth/offsetHeight if the media is scaled down |
| 1646 |
// as the values they report are rounded. That will result in precision losses |
| 1647 |
// when calculating zoom. We use the fact that the media is positionned relative |
| 1648 |
// to the container. That allows us to use the container's dimensions |
| 1649 |
// and natural aspect ratio of the media to calculate accurate media size. |
| 1650 |
// However, for this to work, the container should not be rotated |
| 1651 |
|
| 1652 |
var renderedMediaSize = void 0; |
| 1653 |
|
| 1654 |
if (isMediaScaledDown) { |
| 1655 |
switch (_this.props.objectFit) { |
| 1656 |
default: |
| 1657 |
case 'contain': |
| 1658 |
renderedMediaSize = containerAspect > mediaAspect ? { |
| 1659 |
width: _this.containerRect.height * mediaAspect, |
| 1660 |
height: _this.containerRect.height |
| 1661 |
} : { |
| 1662 |
width: _this.containerRect.width, |
| 1663 |
height: _this.containerRect.width / mediaAspect |
| 1664 |
}; |
| 1665 |
break; |
| 1666 |
|
| 1667 |
case 'horizontal-cover': |
| 1668 |
renderedMediaSize = { |
| 1669 |
width: _this.containerRect.width, |
| 1670 |
height: _this.containerRect.width / mediaAspect |
| 1671 |
}; |
| 1672 |
break; |
| 1673 |
|
| 1674 |
case 'vertical-cover': |
| 1675 |
renderedMediaSize = { |
| 1676 |
width: _this.containerRect.height * mediaAspect, |
| 1677 |
height: _this.containerRect.height |
| 1678 |
}; |
| 1679 |
break; |
| 1680 |
|
| 1681 |
case 'auto-cover': |
| 1682 |
renderedMediaSize = naturalWidth > naturalHeight ? { |
| 1683 |
width: _this.containerRect.width, |
| 1684 |
height: _this.containerRect.width / mediaAspect |
| 1685 |
} : { |
| 1686 |
width: _this.containerRect.height * mediaAspect, |
| 1687 |
height: _this.containerRect.height |
| 1688 |
}; |
| 1689 |
break; |
| 1690 |
} |
| 1691 |
} else { |
| 1692 |
renderedMediaSize = { |
| 1693 |
width: mediaRef.offsetWidth, |
| 1694 |
height: mediaRef.offsetHeight |
| 1695 |
}; |
| 1696 |
} |
| 1697 |
|
| 1698 |
_this.mediaSize = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, renderedMediaSize), { |
| 1699 |
naturalWidth: naturalWidth, |
| 1700 |
naturalHeight: naturalHeight |
| 1701 |
}); |
| 1702 |
var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(_this.mediaSize.width, _this.mediaSize.height, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation); |
| 1703 |
|
| 1704 |
if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) { |
| 1705 |
_this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize); |
| 1706 |
} |
| 1707 |
|
| 1708 |
_this.setState({ |
| 1709 |
cropSize: cropSize |
| 1710 |
}, _this.recomputeCropPosition); |
| 1711 |
|
| 1712 |
return cropSize; |
| 1713 |
} |
| 1714 |
}; |
| 1715 |
|
| 1716 |
_this.onMouseDown = function (e) { |
| 1717 |
e.preventDefault(); |
| 1718 |
document.addEventListener('mousemove', _this.onMouseMove); |
| 1719 |
document.addEventListener('mouseup', _this.onDragStopped); |
| 1720 |
|
| 1721 |
_this.onDragStart(Cropper.getMousePoint(e)); |
| 1722 |
}; |
| 1723 |
|
| 1724 |
_this.onMouseMove = function (e) { |
| 1725 |
return _this.onDrag(Cropper.getMousePoint(e)); |
| 1726 |
}; |
| 1727 |
|
| 1728 |
_this.onTouchStart = function (e) { |
| 1729 |
if (_this.props.onTouchRequest && !_this.props.onTouchRequest(e)) { |
| 1730 |
return; |
| 1731 |
} |
| 1732 |
|
| 1733 |
document.addEventListener('touchmove', _this.onTouchMove, { |
| 1734 |
passive: false |
| 1735 |
}); // iOS 11 now defaults to passive: true |
| 1736 |
|
| 1737 |
document.addEventListener('touchend', _this.onDragStopped); |
| 1738 |
|
| 1739 |
if (e.touches.length === 2) { |
| 1740 |
_this.onPinchStart(e); |
| 1741 |
} else if (e.touches.length === 1) { |
| 1742 |
_this.onDragStart(Cropper.getTouchPoint(e.touches[0])); |
| 1743 |
} |
| 1744 |
}; |
| 1745 |
|
| 1746 |
_this.onTouchMove = function (e) { |
| 1747 |
// Prevent whole page from scrolling on iOS. |
| 1748 |
e.preventDefault(); |
| 1749 |
|
| 1750 |
if (e.touches.length === 2) { |
| 1751 |
_this.onPinchMove(e); |
| 1752 |
} else if (e.touches.length === 1) { |
| 1753 |
_this.onDrag(Cropper.getTouchPoint(e.touches[0])); |
| 1754 |
} |
| 1755 |
}; |
| 1756 |
|
| 1757 |
_this.onDragStart = function (_a) { |
| 1758 |
var _b, _c; |
| 1759 |
|
| 1760 |
var x = _a.x, |
| 1761 |
y = _a.y; |
| 1762 |
_this.dragStartPosition = { |
| 1763 |
x: x, |
| 1764 |
y: y |
| 1765 |
}; |
| 1766 |
_this.dragStartCrop = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, _this.props.crop); |
| 1767 |
(_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b); |
| 1768 |
}; |
| 1769 |
|
| 1770 |
_this.onDrag = function (_a) { |
| 1771 |
var x = _a.x, |
| 1772 |
y = _a.y; |
| 1773 |
if (_this.rafDragTimeout) window.cancelAnimationFrame(_this.rafDragTimeout); |
| 1774 |
_this.rafDragTimeout = window.requestAnimationFrame(function () { |
| 1775 |
if (!_this.state.cropSize) return; |
| 1776 |
if (x === undefined || y === undefined) return; |
| 1777 |
var offsetX = x - _this.dragStartPosition.x; |
| 1778 |
var offsetY = y - _this.dragStartPosition.y; |
| 1779 |
var requestedPosition = { |
| 1780 |
x: _this.dragStartCrop.x + offsetX, |
| 1781 |
y: _this.dragStartCrop.y + offsetY |
| 1782 |
}; |
| 1783 |
var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition; |
| 1784 |
|
| 1785 |
_this.props.onCropChange(newPosition); |
| 1786 |
}); |
| 1787 |
}; |
| 1788 |
|
| 1789 |
_this.onDragStopped = function () { |
| 1790 |
var _a, _b; |
| 1791 |
|
| 1792 |
_this.cleanEvents(); |
| 1793 |
|
| 1794 |
_this.emitCropData(); |
| 1795 |
|
| 1796 |
(_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 1797 |
}; |
| 1798 |
|
| 1799 |
_this.onWheel = function (e) { |
| 1800 |
if (_this.props.onWheelRequest && !_this.props.onWheelRequest(e)) { |
| 1801 |
return; |
| 1802 |
} |
| 1803 |
|
| 1804 |
e.preventDefault(); |
| 1805 |
var point = Cropper.getMousePoint(e); |
| 1806 |
var pixelY = normalize_wheel__WEBPACK_IMPORTED_MODULE_1___default()(e).pixelY; |
| 1807 |
var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200; |
| 1808 |
|
| 1809 |
_this.setNewZoom(newZoom, point); |
| 1810 |
|
| 1811 |
if (!_this.state.hasWheelJustStarted) { |
| 1812 |
_this.setState({ |
| 1813 |
hasWheelJustStarted: true |
| 1814 |
}, function () { |
| 1815 |
var _a, _b; |
| 1816 |
|
| 1817 |
return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 1818 |
}); |
| 1819 |
} |
| 1820 |
|
| 1821 |
if (_this.wheelTimer) { |
| 1822 |
clearTimeout(_this.wheelTimer); |
| 1823 |
} |
| 1824 |
|
| 1825 |
_this.wheelTimer = window.setTimeout(function () { |
| 1826 |
return _this.setState({ |
| 1827 |
hasWheelJustStarted: false |
| 1828 |
}, function () { |
| 1829 |
var _a, _b; |
| 1830 |
|
| 1831 |
return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); |
| 1832 |
}); |
| 1833 |
}, 250); |
| 1834 |
}; |
| 1835 |
|
| 1836 |
_this.getPointOnContainer = function (_a) { |
| 1837 |
var x = _a.x, |
| 1838 |
y = _a.y; |
| 1839 |
|
| 1840 |
if (!_this.containerRect) { |
| 1841 |
throw new Error('The Cropper is not mounted'); |
| 1842 |
} |
| 1843 |
|
| 1844 |
return { |
| 1845 |
x: _this.containerRect.width / 2 - (x - _this.containerRect.left), |
| 1846 |
y: _this.containerRect.height / 2 - (y - _this.containerRect.top) |
| 1847 |
}; |
| 1848 |
}; |
| 1849 |
|
| 1850 |
_this.getPointOnMedia = function (_a) { |
| 1851 |
var x = _a.x, |
| 1852 |
y = _a.y; |
| 1853 |
var _b = _this.props, |
| 1854 |
crop = _b.crop, |
| 1855 |
zoom = _b.zoom; |
| 1856 |
return { |
| 1857 |
x: (x + crop.x) / zoom, |
| 1858 |
y: (y + crop.y) / zoom |
| 1859 |
}; |
| 1860 |
}; |
| 1861 |
|
| 1862 |
_this.setNewZoom = function (zoom, point) { |
| 1863 |
if (!_this.state.cropSize || !_this.props.onZoomChange) return; |
| 1864 |
|
| 1865 |
var zoomPoint = _this.getPointOnContainer(point); |
| 1866 |
|
| 1867 |
var zoomTarget = _this.getPointOnMedia(zoomPoint); |
| 1868 |
|
| 1869 |
var newZoom = clamp(zoom, _this.props.minZoom, _this.props.maxZoom); |
| 1870 |
var requestedPosition = { |
| 1871 |
x: zoomTarget.x * newZoom - zoomPoint.x, |
| 1872 |
y: zoomTarget.y * newZoom - zoomPoint.y |
| 1873 |
}; |
| 1874 |
var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition; |
| 1875 |
|
| 1876 |
_this.props.onCropChange(newPosition); |
| 1877 |
|
| 1878 |
_this.props.onZoomChange(newZoom); |
| 1879 |
}; |
| 1880 |
|
| 1881 |
_this.getCropData = function () { |
| 1882 |
if (!_this.state.cropSize) { |
| 1883 |
return null; |
| 1884 |
} // this is to ensure the crop is correctly restricted after a zoom back (https://github.com/ValentinH/react-easy-crop/issues/6) |
| 1885 |
|
| 1886 |
|
| 1887 |
var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop; |
| 1888 |
return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition); |
| 1889 |
}; |
| 1890 |
|
| 1891 |
_this.emitCropData = function () { |
| 1892 |
var cropData = _this.getCropData(); |
| 1893 |
|
| 1894 |
if (!cropData) return; |
| 1895 |
var croppedAreaPercentages = cropData.croppedAreaPercentages, |
| 1896 |
croppedAreaPixels = cropData.croppedAreaPixels; |
| 1897 |
|
| 1898 |
if (_this.props.onCropComplete) { |
| 1899 |
_this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels); |
| 1900 |
} |
| 1901 |
|
| 1902 |
if (_this.props.onCropAreaChange) { |
| 1903 |
_this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); |
| 1904 |
} |
| 1905 |
}; |
| 1906 |
|
| 1907 |
_this.emitCropAreaChange = function () { |
| 1908 |
var cropData = _this.getCropData(); |
| 1909 |
|
| 1910 |
if (!cropData) return; |
| 1911 |
var croppedAreaPercentages = cropData.croppedAreaPercentages, |
| 1912 |
croppedAreaPixels = cropData.croppedAreaPixels; |
| 1913 |
|
| 1914 |
if (_this.props.onCropAreaChange) { |
| 1915 |
_this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); |
| 1916 |
} |
| 1917 |
}; |
| 1918 |
|
| 1919 |
_this.recomputeCropPosition = function () { |
| 1920 |
if (!_this.state.cropSize) return; |
| 1921 |
var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop; |
| 1922 |
|
| 1923 |
_this.props.onCropChange(newPosition); |
| 1924 |
|
| 1925 |
_this.emitCropData(); |
| 1926 |
}; |
| 1927 |
|
| 1928 |
return _this; |
| 1929 |
} |
| 1930 |
|
| 1931 |
Cropper.prototype.componentDidMount = function () { |
| 1932 |
window.addEventListener('resize', this.computeSizes); |
| 1933 |
|
| 1934 |
if (this.containerRef) { |
| 1935 |
this.props.zoomWithScroll && this.containerRef.addEventListener('wheel', this.onWheel, { |
| 1936 |
passive: false |
| 1937 |
}); |
| 1938 |
this.containerRef.addEventListener('gesturestart', this.preventZoomSafari); |
| 1939 |
this.containerRef.addEventListener('gesturechange', this.preventZoomSafari); |
| 1940 |
} |
| 1941 |
|
| 1942 |
if (!this.props.disableAutomaticStylesInjection) { |
| 1943 |
this.styleRef = document.createElement('style'); |
| 1944 |
this.styleRef.setAttribute('type', 'text/css'); |
| 1945 |
|
| 1946 |
if (this.props.nonce) { |
| 1947 |
this.styleRef.setAttribute('nonce', this.props.nonce); |
| 1948 |
} |
| 1949 |
|
| 1950 |
this.styleRef.innerHTML = css_248z; |
| 1951 |
document.head.appendChild(this.styleRef); |
| 1952 |
} // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called |
| 1953 |
|
| 1954 |
|
| 1955 |
if (this.imageRef.current && this.imageRef.current.complete) { |
| 1956 |
this.onMediaLoad(); |
| 1957 |
} // set image and video refs in the parent if the callbacks exist |
| 1958 |
|
| 1959 |
|
| 1960 |
if (this.props.setImageRef) { |
| 1961 |
this.props.setImageRef(this.imageRef); |
| 1962 |
} |
| 1963 |
|
| 1964 |
if (this.props.setVideoRef) { |
| 1965 |
this.props.setVideoRef(this.videoRef); |
| 1966 |
} |
| 1967 |
}; |
| 1968 |
|
| 1969 |
Cropper.prototype.componentWillUnmount = function () { |
| 1970 |
var _a; |
| 1971 |
|
| 1972 |
window.removeEventListener('resize', this.computeSizes); |
| 1973 |
|
| 1974 |
if (this.containerRef) { |
| 1975 |
this.containerRef.removeEventListener('gesturestart', this.preventZoomSafari); |
| 1976 |
this.containerRef.removeEventListener('gesturechange', this.preventZoomSafari); |
| 1977 |
} |
| 1978 |
|
| 1979 |
if (this.styleRef) { |
| 1980 |
(_a = this.styleRef.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleRef); |
| 1981 |
} |
| 1982 |
|
| 1983 |
this.cleanEvents(); |
| 1984 |
this.props.zoomWithScroll && this.clearScrollEvent(); |
| 1985 |
}; |
| 1986 |
|
| 1987 |
Cropper.prototype.componentDidUpdate = function (prevProps) { |
| 1988 |
var _a, _b, _c, _d, _e, _f, _g, _h, _j; |
| 1989 |
|
| 1990 |
if (prevProps.rotation !== this.props.rotation) { |
| 1991 |
this.computeSizes(); |
| 1992 |
this.recomputeCropPosition(); |
| 1993 |
} else if (prevProps.aspect !== this.props.aspect) { |
| 1994 |
this.computeSizes(); |
| 1995 |
} else if (prevProps.zoom !== this.props.zoom) { |
| 1996 |
this.recomputeCropPosition(); |
| 1997 |
} else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) { |
| 1998 |
this.computeSizes(); |
| 1999 |
} else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) { |
| 2000 |
this.emitCropAreaChange(); |
| 2001 |
} |
| 2002 |
|
| 2003 |
if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) { |
| 2004 |
this.props.zoomWithScroll ? this.containerRef.addEventListener('wheel', this.onWheel, { |
| 2005 |
passive: false |
| 2006 |
}) : this.clearScrollEvent(); |
| 2007 |
} |
| 2008 |
|
| 2009 |
if (prevProps.video !== this.props.video) { |
| 2010 |
(_j = this.videoRef.current) === null || _j === void 0 ? void 0 : _j.load(); |
| 2011 |
} |
| 2012 |
}; |
| 2013 |
|
| 2014 |
Cropper.prototype.getAspect = function () { |
| 2015 |
var _a = this.props, |
| 2016 |
cropSize = _a.cropSize, |
| 2017 |
aspect = _a.aspect; |
| 2018 |
|
| 2019 |
if (cropSize) { |
| 2020 |
return cropSize.width / cropSize.height; |
| 2021 |
} |
| 2022 |
|
| 2023 |
return aspect; |
| 2024 |
}; |
| 2025 |
|
| 2026 |
Cropper.prototype.onPinchStart = function (e) { |
| 2027 |
var pointA = Cropper.getTouchPoint(e.touches[0]); |
| 2028 |
var pointB = Cropper.getTouchPoint(e.touches[1]); |
| 2029 |
this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB); |
| 2030 |
this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB); |
| 2031 |
this.onDragStart(getCenter(pointA, pointB)); |
| 2032 |
}; |
| 2033 |
|
| 2034 |
Cropper.prototype.onPinchMove = function (e) { |
| 2035 |
var _this = this; |
| 2036 |
|
| 2037 |
var pointA = Cropper.getTouchPoint(e.touches[0]); |
| 2038 |
var pointB = Cropper.getTouchPoint(e.touches[1]); |
| 2039 |
var center = getCenter(pointA, pointB); |
| 2040 |
this.onDrag(center); |
| 2041 |
if (this.rafPinchTimeout) window.cancelAnimationFrame(this.rafPinchTimeout); |
| 2042 |
this.rafPinchTimeout = window.requestAnimationFrame(function () { |
| 2043 |
var distance = getDistanceBetweenPoints(pointA, pointB); |
| 2044 |
var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance); |
| 2045 |
|
| 2046 |
_this.setNewZoom(newZoom, center); |
| 2047 |
|
| 2048 |
_this.lastPinchDistance = distance; |
| 2049 |
var rotation = getRotationBetweenPoints(pointA, pointB); |
| 2050 |
var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation); |
| 2051 |
_this.props.onRotationChange && _this.props.onRotationChange(newRotation); |
| 2052 |
_this.lastPinchRotation = rotation; |
| 2053 |
}); |
| 2054 |
}; |
| 2055 |
|
| 2056 |
Cropper.prototype.render = function () { |
| 2057 |
var _this = this; |
| 2058 |
|
| 2059 |
var _a = this.props, |
| 2060 |
image = _a.image, |
| 2061 |
video = _a.video, |
| 2062 |
mediaProps = _a.mediaProps, |
| 2063 |
transform = _a.transform, |
| 2064 |
_b = _a.crop, |
| 2065 |
x = _b.x, |
| 2066 |
y = _b.y, |
| 2067 |
rotation = _a.rotation, |
| 2068 |
zoom = _a.zoom, |
| 2069 |
cropShape = _a.cropShape, |
| 2070 |
showGrid = _a.showGrid, |
| 2071 |
_c = _a.style, |
| 2072 |
containerStyle = _c.containerStyle, |
| 2073 |
cropAreaStyle = _c.cropAreaStyle, |
| 2074 |
mediaStyle = _c.mediaStyle, |
| 2075 |
_d = _a.classes, |
| 2076 |
containerClassName = _d.containerClassName, |
| 2077 |
cropAreaClassName = _d.cropAreaClassName, |
| 2078 |
mediaClassName = _d.mediaClassName, |
| 2079 |
objectFit = _a.objectFit; |
| 2080 |
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { |
| 2081 |
onMouseDown: this.onMouseDown, |
| 2082 |
onTouchStart: this.onTouchStart, |
| 2083 |
ref: function ref(el) { |
| 2084 |
return _this.containerRef = el; |
| 2085 |
}, |
| 2086 |
"data-testid": "container", |
| 2087 |
style: containerStyle, |
| 2088 |
className: classNames('reactEasyCrop_Container', containerClassName) |
| 2089 |
}, image ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("img", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ |
| 2090 |
alt: "", |
| 2091 |
className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName) |
| 2092 |
}, mediaProps, { |
| 2093 |
src: image, |
| 2094 |
ref: this.imageRef, |
| 2095 |
style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), { |
| 2096 |
transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")" |
| 2097 |
}), |
| 2098 |
onLoad: this.onMediaLoad |
| 2099 |
})) : video && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("video", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ |
| 2100 |
autoPlay: true, |
| 2101 |
loop: true, |
| 2102 |
muted: true, |
| 2103 |
className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', objectFit === 'auto-cover' && (this.mediaSize.naturalWidth > this.mediaSize.naturalHeight ? 'reactEasyCrop_Cover_Horizontal' : 'reactEasyCrop_Cover_Vertical'), mediaClassName) |
| 2104 |
}, mediaProps, { |
| 2105 |
ref: this.videoRef, |
| 2106 |
onLoadedMetadata: this.onMediaLoad, |
| 2107 |
style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), { |
| 2108 |
transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")" |
| 2109 |
}), |
| 2110 |
controls: false |
| 2111 |
}), (Array.isArray(video) ? video : [{ |
| 2112 |
src: video |
| 2113 |
}]).map(function (item) { |
| 2114 |
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("source", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ |
| 2115 |
key: item.src |
| 2116 |
}, item)); |
| 2117 |
})), this.state.cropSize && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { |
| 2118 |
style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, cropAreaStyle), { |
| 2119 |
width: this.state.cropSize.width, |
| 2120 |
height: this.state.cropSize.height |
| 2121 |
}), |
| 2122 |
"data-testid": "cropper", |
| 2123 |
className: classNames('reactEasyCrop_CropArea', cropShape === 'round' && 'reactEasyCrop_CropAreaRound', showGrid && 'reactEasyCrop_CropAreaGrid', cropAreaClassName) |
| 2124 |
})); |
| 2125 |
}; |
| 2126 |
|
| 2127 |
Cropper.defaultProps = { |
| 2128 |
zoom: 1, |
| 2129 |
rotation: 0, |
| 2130 |
aspect: 4 / 3, |
| 2131 |
maxZoom: MAX_ZOOM, |
| 2132 |
minZoom: MIN_ZOOM, |
| 2133 |
cropShape: 'rect', |
| 2134 |
objectFit: 'contain', |
| 2135 |
showGrid: true, |
| 2136 |
style: {}, |
| 2137 |
classes: {}, |
| 2138 |
mediaProps: {}, |
| 2139 |
zoomSpeed: 1, |
| 2140 |
restrictPosition: true, |
| 2141 |
zoomWithScroll: true |
| 2142 |
}; |
| 2143 |
|
| 2144 |
Cropper.getMousePoint = function (e) { |
| 2145 |
return { |
| 2146 |
x: Number(e.clientX), |
| 2147 |
y: Number(e.clientY) |
| 2148 |
}; |
| 2149 |
}; |
| 2150 |
|
| 2151 |
Cropper.getTouchPoint = function (touch) { |
| 2152 |
return { |
| 2153 |
x: Number(touch.clientX), |
| 2154 |
y: Number(touch.clientY) |
| 2155 |
}; |
| 2156 |
}; |
| 2157 |
|
| 2158 |
return Cropper; |
| 2159 |
}((react__WEBPACK_IMPORTED_MODULE_0___default().Component)); |
| 2160 |
|
| 2161 |
/* harmony default export */ __webpack_exports__["default"] = (Cropper); |
| 2162 |
//# sourceMappingURL=index.module.js.map |
| 2163 |
|
| 2164 |
|
| 2165 |
/***/ }), |
| 2166 |
|
| 2167 |
/***/ "./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js": |
| 2168 |
/*!**********************************************************************!*\ |
| 2169 |
!*** ./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js ***! |
| 2170 |
\**********************************************************************/ |
| 2171 |
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { |
| 2172 |
|
| 2173 |
"use strict"; |
| 2174 |
__webpack_require__.r(__webpack_exports__); |
| 2175 |
/* harmony export */ __webpack_require__.d(__webpack_exports__, { |
| 2176 |
/* harmony export */ "__assign": function() { return /* binding */ __assign; }, |
| 2177 |
/* harmony export */ "__asyncDelegator": function() { return /* binding */ __asyncDelegator; }, |
| 2178 |
/* harmony export */ "__asyncGenerator": function() { return /* binding */ __asyncGenerator; }, |
| 2179 |
/* harmony export */ "__asyncValues": function() { return /* binding */ __asyncValues; }, |
| 2180 |
/* harmony export */ "__await": function() { return /* binding */ __await; }, |
| 2181 |
/* harmony export */ "__awaiter": function() { return /* binding */ __awaiter; }, |
| 2182 |
/* harmony export */ "__classPrivateFieldGet": function() { return /* binding */ __classPrivateFieldGet; }, |
| 2183 |
/* harmony export */ "__classPrivateFieldSet": function() { return /* binding */ __classPrivateFieldSet; }, |
| 2184 |
/* harmony export */ "__createBinding": function() { return /* binding */ __createBinding; }, |
| 2185 |
/* harmony export */ "__decorate": function() { return /* binding */ __decorate; }, |
| 2186 |
/* harmony export */ "__exportStar": function() { return /* binding */ __exportStar; }, |
| 2187 |
/* harmony export */ "__extends": function() { return /* binding */ __extends; }, |
| 2188 |
/* harmony export */ "__generator": function() { return /* binding */ __generator; }, |
| 2189 |
/* harmony export */ "__importDefault": function() { return /* binding */ __importDefault; }, |
| 2190 |
/* harmony export */ "__importStar": function() { return /* binding */ __importStar; }, |
| 2191 |
/* harmony export */ "__makeTemplateObject": function() { return /* binding */ __makeTemplateObject; }, |
| 2192 |
/* harmony export */ "__metadata": function() { return /* binding */ __metadata; }, |
| 2193 |
/* harmony export */ "__param": function() { return /* binding */ __param; }, |
| 2194 |
/* harmony export */ "__read": function() { return /* binding */ __read; }, |
| 2195 |
/* harmony export */ "__rest": function() { return /* binding */ __rest; }, |
| 2196 |
/* harmony export */ "__spread": function() { return /* binding */ __spread; }, |
| 2197 |
/* harmony export */ "__spreadArrays": function() { return /* binding */ __spreadArrays; }, |
| 2198 |
/* harmony export */ "__values": function() { return /* binding */ __values; } |
| 2199 |
/* harmony export */ }); |
| 2200 |
/*! ***************************************************************************** |
| 2201 |
Copyright (c) Microsoft Corporation. |
| 2202 |
|
| 2203 |
Permission to use, copy, modify, and/or distribute this software for any |
| 2204 |
purpose with or without fee is hereby granted. |
| 2205 |
|
| 2206 |
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH |
| 2207 |
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
| 2208 |
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, |
| 2209 |
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
| 2210 |
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR |
| 2211 |
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 2212 |
PERFORMANCE OF THIS SOFTWARE. |
| 2213 |
***************************************************************************** */ |
| 2214 |
/* global Reflect, Promise */ |
| 2215 |
|
| 2216 |
var extendStatics = function(d, b) { |
| 2217 |
extendStatics = Object.setPrototypeOf || |
| 2218 |
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
| 2219 |
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; |
| 2220 |
return extendStatics(d, b); |
| 2221 |
}; |
| 2222 |
|
| 2223 |
function __extends(d, b) { |
| 2224 |
extendStatics(d, b); |
| 2225 |
function __() { this.constructor = d; } |
| 2226 |
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
| 2227 |
} |
| 2228 |
|
| 2229 |
var __assign = function() { |
| 2230 |
__assign = Object.assign || function __assign(t) { |
| 2231 |
for (var s, i = 1, n = arguments.length; i < n; i++) { |
| 2232 |
s = arguments[i]; |
| 2233 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; |
| 2234 |
} |
| 2235 |
return t; |
| 2236 |
} |
| 2237 |
return __assign.apply(this, arguments); |
| 2238 |
} |
| 2239 |
|
| 2240 |
function __rest(s, e) { |
| 2241 |
var t = {}; |
| 2242 |
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
| 2243 |
t[p] = s[p]; |
| 2244 |
if (s != null && typeof Object.getOwnPropertySymbols === "function") |
| 2245 |
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { |
| 2246 |
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
| 2247 |
t[p[i]] = s[p[i]]; |
| 2248 |
} |
| 2249 |
return t; |
| 2250 |
} |
| 2251 |
|
| 2252 |
function __decorate(decorators, target, key, desc) { |
| 2253 |
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; |
| 2254 |
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); |
| 2255 |
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; |
| 2256 |
return c > 3 && r && Object.defineProperty(target, key, r), r; |
| 2257 |
} |
| 2258 |
|
| 2259 |
function __param(paramIndex, decorator) { |
| 2260 |
return function (target, key) { decorator(target, key, paramIndex); } |
| 2261 |
} |
| 2262 |
|
| 2263 |
function __metadata(metadataKey, metadataValue) { |
| 2264 |
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); |
| 2265 |
} |
| 2266 |
|
| 2267 |
function __awaiter(thisArg, _arguments, P, generator) { |
| 2268 |
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
| 2269 |
return new (P || (P = Promise))(function (resolve, reject) { |
| 2270 |
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
| 2271 |
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
| 2272 |
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
| 2273 |
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
| 2274 |
}); |
| 2275 |
} |
| 2276 |
|
| 2277 |
function __generator(thisArg, body) { |
| 2278 |
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
| 2279 |
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
| 2280 |
function verb(n) { return function (v) { return step([n, v]); }; } |
| 2281 |
function step(op) { |
| 2282 |
if (f) throw new TypeError("Generator is already executing."); |
| 2283 |
while (_) try { |
| 2284 |
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
| 2285 |
if (y = 0, t) op = [op[0] & 2, t.value]; |
| 2286 |
switch (op[0]) { |
| 2287 |
case 0: case 1: t = op; break; |
| 2288 |
case 4: _.label++; return { value: op[1], done: false }; |
| 2289 |
case 5: _.label++; y = op[1]; op = [0]; continue; |
| 2290 |
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
| 2291 |
default: |
| 2292 |
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
| 2293 |
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
| 2294 |
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
| 2295 |
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
| 2296 |
if (t[2]) _.ops.pop(); |
| 2297 |
_.trys.pop(); continue; |
| 2298 |
} |
| 2299 |
op = body.call(thisArg, _); |
| 2300 |
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
| 2301 |
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
| 2302 |
} |
| 2303 |
} |
| 2304 |
|
| 2305 |
var __createBinding = Object.create ? (function(o, m, k, k2) { |
| 2306 |
if (k2 === undefined) k2 = k; |
| 2307 |
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); |
| 2308 |
}) : (function(o, m, k, k2) { |
| 2309 |
if (k2 === undefined) k2 = k; |
| 2310 |
o[k2] = m[k]; |
| 2311 |
}); |
| 2312 |
|
| 2313 |
function __exportStar(m, o) { |
| 2314 |
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); |
| 2315 |
} |
| 2316 |
|
| 2317 |
function __values(o) { |
| 2318 |
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; |
| 2319 |
if (m) return m.call(o); |
| 2320 |
if (o && typeof o.length === "number") return { |
| 2321 |
next: function () { |
| 2322 |
if (o && i >= o.length) o = void 0; |
| 2323 |
return { value: o && o[i++], done: !o }; |
| 2324 |
} |
| 2325 |
}; |
| 2326 |
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); |
| 2327 |
} |
| 2328 |
|
| 2329 |
function __read(o, n) { |
| 2330 |
var m = typeof Symbol === "function" && o[Symbol.iterator]; |
| 2331 |
if (!m) return o; |
| 2332 |
var i = m.call(o), r, ar = [], e; |
| 2333 |
try { |
| 2334 |
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); |
| 2335 |
} |
| 2336 |
catch (error) { e = { error: error }; } |
| 2337 |
finally { |
| 2338 |
try { |
| 2339 |
if (r && !r.done && (m = i["return"])) m.call(i); |
| 2340 |
} |
| 2341 |
finally { if (e) throw e.error; } |
| 2342 |
} |
| 2343 |
return ar; |
| 2344 |
} |
| 2345 |
|
| 2346 |
function __spread() { |
| 2347 |
for (var ar = [], i = 0; i < arguments.length; i++) |
| 2348 |
ar = ar.concat(__read(arguments[i])); |
| 2349 |
return ar; |
| 2350 |
} |
| 2351 |
|
| 2352 |
function __spreadArrays() { |
| 2353 |
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; |
| 2354 |
for (var r = Array(s), k = 0, i = 0; i < il; i++) |
| 2355 |
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) |
| 2356 |
r[k] = a[j]; |
| 2357 |
return r; |
| 2358 |
}; |
| 2359 |
|
| 2360 |
function __await(v) { |
| 2361 |
return this instanceof __await ? (this.v = v, this) : new __await(v); |
| 2362 |
} |
| 2363 |
|
| 2364 |
function __asyncGenerator(thisArg, _arguments, generator) { |
| 2365 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 2366 |
var g = generator.apply(thisArg, _arguments || []), i, q = []; |
| 2367 |
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; |
| 2368 |
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } |
| 2369 |
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } |
| 2370 |
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } |
| 2371 |
function fulfill(value) { resume("next", value); } |
| 2372 |
function reject(value) { resume("throw", value); } |
| 2373 |
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } |
| 2374 |
} |
| 2375 |
|
| 2376 |
function __asyncDelegator(o) { |
| 2377 |
var i, p; |
| 2378 |
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; |
| 2379 |
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } |
| 2380 |
} |
| 2381 |
|
| 2382 |
function __asyncValues(o) { |
| 2383 |
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); |
| 2384 |
var m = o[Symbol.asyncIterator], i; |
| 2385 |
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); |
| 2386 |
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } |
| 2387 |
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } |
| 2388 |
} |
| 2389 |
|
| 2390 |
function __makeTemplateObject(cooked, raw) { |
| 2391 |
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } |
| 2392 |
return cooked; |
| 2393 |
}; |
| 2394 |
|
| 2395 |
var __setModuleDefault = Object.create ? (function(o, v) { |
| 2396 |
Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 2397 |
}) : function(o, v) { |
| 2398 |
o["default"] = v; |
| 2399 |
}; |
| 2400 |
|
| 2401 |
function __importStar(mod) { |
| 2402 |
if (mod && mod.__esModule) return mod; |
| 2403 |
var result = {}; |
| 2404 |
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); |
| 2405 |
__setModuleDefault(result, mod); |
| 2406 |
return result; |
| 2407 |
} |
| 2408 |
|
| 2409 |
function __importDefault(mod) { |
| 2410 |
return (mod && mod.__esModule) ? mod : { default: mod }; |
| 2411 |
} |
| 2412 |
|
| 2413 |
function __classPrivateFieldGet(receiver, privateMap) { |
| 2414 |
if (!privateMap.has(receiver)) { |
| 2415 |
throw new TypeError("attempted to get private field on non-instance"); |
| 2416 |
} |
| 2417 |
return privateMap.get(receiver); |
| 2418 |
} |
| 2419 |
|
| 2420 |
function __classPrivateFieldSet(receiver, privateMap, value) { |
| 2421 |
if (!privateMap.has(receiver)) { |
| 2422 |
throw new TypeError("attempted to set private field on non-instance"); |
| 2423 |
} |
| 2424 |
privateMap.set(receiver, value); |
| 2425 |
return value; |
| 2426 |
} |
| 2427 |
|
| 2428 |
|
| 2429 |
/***/ }), |
| 2430 |
|
| 2431 |
/***/ "react": |
| 2432 |
/*!************************!*\ |
| 2433 |
!*** external "React" ***! |
| 2434 |
\************************/ |
| 2435 |
/***/ (function(module) { |
| 2436 |
|
| 2437 |
"use strict"; |
| 2438 |
module.exports = window["React"]; |
| 2439 |
|
| 2440 |
/***/ }), |
| 2441 |
|
| 2442 |
/***/ "@wordpress/api-fetch": |
| 2443 |
/*!**********************************!*\ |
| 2444 |
!*** external ["wp","apiFetch"] ***! |
| 2445 |
\**********************************/ |
| 2446 |
/***/ (function(module) { |
| 2447 |
|
| 2448 |
"use strict"; |
| 2449 |
module.exports = window["wp"]["apiFetch"]; |
| 2450 |
|
| 2451 |
/***/ }), |
| 2452 |
|
| 2453 |
/***/ "@wordpress/element": |
| 2454 |
/*!*********************************!*\ |
| 2455 |
!*** external ["wp","element"] ***! |
| 2456 |
\*********************************/ |
| 2457 |
/***/ (function(module) { |
| 2458 |
|
| 2459 |
"use strict"; |
| 2460 |
module.exports = window["wp"]["element"]; |
| 2461 |
|
| 2462 |
/***/ }), |
| 2463 |
|
| 2464 |
/***/ "@wordpress/i18n": |
| 2465 |
/*!******************************!*\ |
| 2466 |
!*** external ["wp","i18n"] ***! |
| 2467 |
\******************************/ |
| 2468 |
/***/ (function(module) { |
| 2469 |
|
| 2470 |
"use strict"; |
| 2471 |
module.exports = window["wp"]["i18n"]; |
| 2472 |
|
| 2473 |
/***/ }), |
| 2474 |
|
| 2475 |
/***/ "@wordpress/url": |
| 2476 |
/*!*****************************!*\ |
| 2477 |
!*** external ["wp","url"] ***! |
| 2478 |
\*****************************/ |
| 2479 |
/***/ (function(module) { |
| 2480 |
|
| 2481 |
"use strict"; |
| 2482 |
module.exports = window["wp"]["url"]; |
| 2483 |
|
| 2484 |
/***/ }) |
| 2485 |
|
| 2486 |
/******/ }); |
| 2487 |
/************************************************************************/ |
| 2488 |
/******/ // The module cache |
| 2489 |
/******/ var __webpack_module_cache__ = {}; |
| 2490 |
/******/ |
| 2491 |
/******/ // The require function |
| 2492 |
/******/ function __webpack_require__(moduleId) { |
| 2493 |
/******/ // Check if module is in cache |
| 2494 |
/******/ var cachedModule = __webpack_module_cache__[moduleId]; |
| 2495 |
/******/ if (cachedModule !== undefined) { |
| 2496 |
/******/ return cachedModule.exports; |
| 2497 |
/******/ } |
| 2498 |
/******/ // Create a new module (and put it into the cache) |
| 2499 |
/******/ var module = __webpack_module_cache__[moduleId] = { |
| 2500 |
/******/ // no module.id needed |
| 2501 |
/******/ // no module.loaded needed |
| 2502 |
/******/ exports: {} |
| 2503 |
/******/ }; |
| 2504 |
/******/ |
| 2505 |
/******/ // Execute the module function |
| 2506 |
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); |
| 2507 |
/******/ |
| 2508 |
/******/ // Return the exports of the module |
| 2509 |
/******/ return module.exports; |
| 2510 |
/******/ } |
| 2511 |
/******/ |
| 2512 |
/************************************************************************/ |
| 2513 |
/******/ /* webpack/runtime/compat get default export */ |
| 2514 |
/******/ !function() { |
| 2515 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
| 2516 |
/******/ __webpack_require__.n = function(module) { |
| 2517 |
/******/ var getter = module && module.__esModule ? |
| 2518 |
/******/ function() { return module['default']; } : |
| 2519 |
/******/ function() { return module; }; |
| 2520 |
/******/ __webpack_require__.d(getter, { a: getter }); |
| 2521 |
/******/ return getter; |
| 2522 |
/******/ }; |
| 2523 |
/******/ }(); |
| 2524 |
/******/ |
| 2525 |
/******/ /* webpack/runtime/define property getters */ |
| 2526 |
/******/ !function() { |
| 2527 |
/******/ // define getter functions for harmony exports |
| 2528 |
/******/ __webpack_require__.d = function(exports, definition) { |
| 2529 |
/******/ for(var key in definition) { |
| 2530 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
| 2531 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
| 2532 |
/******/ } |
| 2533 |
/******/ } |
| 2534 |
/******/ }; |
| 2535 |
/******/ }(); |
| 2536 |
/******/ |
| 2537 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
| 2538 |
/******/ !function() { |
| 2539 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
| 2540 |
/******/ }(); |
| 2541 |
/******/ |
| 2542 |
/******/ /* webpack/runtime/make namespace object */ |
| 2543 |
/******/ !function() { |
| 2544 |
/******/ // define __esModule on exports |
| 2545 |
/******/ __webpack_require__.r = function(exports) { |
| 2546 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
| 2547 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
| 2548 |
/******/ } |
| 2549 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
| 2550 |
/******/ }; |
| 2551 |
/******/ }(); |
| 2552 |
/******/ |
| 2553 |
/************************************************************************/ |
| 2554 |
var __webpack_exports__ = {}; |
| 2555 |
// This entry need to be wrapped in an IIFE because it need to be in strict mode. |
| 2556 |
!function() { |
| 2557 |
"use strict"; |
| 2558 |
/*!************************************************!*\ |
| 2559 |
!*** ./assets/src/apps/js/frontend/profile.js ***! |
| 2560 |
\************************************************/ |
| 2561 |
__webpack_require__.r(__webpack_exports__); |
| 2562 |
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); |
| 2563 |
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__); |
| 2564 |
/* harmony import */ var _profile_course_tab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./profile/course-tab */ "./assets/src/apps/js/frontend/profile/course-tab.js"); |
| 2565 |
/* harmony import */ var _profile_statistic__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./profile/statistic */ "./assets/src/apps/js/frontend/profile/statistic.js"); |
| 2566 |
/* harmony import */ var _profile_order_recover__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./profile/order-recover */ "./assets/src/apps/js/frontend/profile/order-recover.js"); |
| 2567 |
/* harmony import */ var _profile_avatar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./profile/avatar */ "./assets/src/apps/js/frontend/profile/avatar.js"); |
| 2568 |
|
| 2569 |
|
| 2570 |
|
| 2571 |
|
| 2572 |
|
| 2573 |
document.addEventListener('DOMContentLoaded', function (event) { |
| 2574 |
(0,_profile_course_tab__WEBPACK_IMPORTED_MODULE_1__["default"])(); |
| 2575 |
(0,_profile_statistic__WEBPACK_IMPORTED_MODULE_2__["default"])(); |
| 2576 |
(0,_profile_order_recover__WEBPACK_IMPORTED_MODULE_3__["default"])(); |
| 2577 |
}); |
| 2578 |
|
| 2579 |
if (document.getElementById('learnpress-avatar-upload')) { |
| 2580 |
wp.element.render((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_profile_avatar__WEBPACK_IMPORTED_MODULE_4__["default"], null), document.getElementById('learnpress-avatar-upload')); |
| 2581 |
} |
| 2582 |
}(); |
| 2583 |
/******/ })() |
| 2584 |
; |
| 2585 |
//# sourceMappingURL=profile.js.map |