PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.10
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.10
4.4.10 4.4.9.1 4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 All 142 releases
← All changes | assets/dist/js/admin/list-students-enrolled.js +184 -48 4.4.2 → 4.4.10 View file →
@@ -11,8 +11,9 @@
11 11 __webpack_require__.r(__webpack_exports__);
12 12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 13 /* harmony export */ debounce: () => (/* binding */ debounce),
14 14 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
15 +/* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
15 16 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
16 17 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
17 18 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
18 19 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
@@ -24,9 +25,10 @@
24 25 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
25 26 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
26 27 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
27 28 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
28 -/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
29 +/* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
30 +/* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
29 31 /* harmony export */ });
30 32 /**
31 33 * Utils functions
32 34 *
@@ -33,9 +35,9 @@
33 35 * @param url
34 36 * @param data
35 37 * @param functions
36 38 * @since 4.2.5.1
37 - * @version 1.0.6
39 + * @version 1.0.7
38 40 */
39 41 const lpClassName = {
40 42 hidden: 'lp-hidden',
41 43 loading: 'loading',
@@ -40,9 +42,12 @@
40 42 hidden: 'lp-hidden',
41 43 loading: 'loading',
42 44 elCollapse: 'lp-collapse',
43 45 elSectionToggle: '.lp-section-toggle',
44 - elTriggerToggle: '.lp-trigger-toggle'
46 + elTriggerToggle: '.lp-trigger-toggle',
47 + elBtnFullScreen: '.lp-btn-full-screen-view',
48 + elFullScreen: 'lp-full-screen-view',
49 + elBtnFullScreenClose: 'lp-full-screen-view__close'
45 50 };
46 51 const lpFetchAPI = (url, data = {}, functions = {}) => {
47 52 if ('function' === typeof functions.before) {
48 53 functions.before();
@@ -360,24 +365,157 @@
360 365 timer = setTimeout(() => func(args), wait);
361 366 };
362 367 };
363 368
369 +/**
370 + * Initialize lp-toggle-enable components.
371 + *
372 + * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
373 + * Reads initial state from `data-enabled` attribute ("true"/"false").
374 + * Calls `data-on-toggle` callback (if provided via options) on state change.
375 + *
376 + * HTML structure:
377 + * <label class="lp-toggle-enable" data-enabled="true">
378 + * <input type="checkbox" class="lp-toggle-enable__input" />
379 + * <span class="lp-toggle-enable__track"></span>
380 + * </label>
381 + *
382 + * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
383 + * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
384 + * @since 4.4.5
385 + * @version 1.0.0
386 + */
387 +window.lpToggleEnableInit = 0;
388 +const toggleEnable = (onToggle = null) => {
389 + if (window.lpToggleEnableInit) {
390 + return;
391 + }
392 + window.lpToggleEnableInit = 1;
393 + const selector = '.lp-toggle-enable';
394 + const updateUI = (toggle, isEnabled) => {
395 + toggle.classList.toggle('is-enabled', isEnabled);
396 + const input = toggle.querySelector('.lp-toggle-enable__input');
397 + if (input) {
398 + input.checked = isEnabled;
399 + input.value = isEnabled ? '1' : '0';
400 + }
401 + };
402 +
403 + // Delegate click handling via eventHandlers.
404 + eventHandlers('click', [{
405 + selector,
406 + callBack: args => {
407 + const {
408 + e,
409 + target
410 + } = args;
411 + const toggle = target.closest(selector);
412 + if (!toggle || toggle.classList.contains('is-disabled')) {
413 + return;
414 + }
415 + e.preventDefault();
416 + const isEnabled = !toggle.classList.contains('is-enabled');
417 + updateUI(toggle, isEnabled);
418 + if ('function' === typeof onToggle) {
419 + onToggle(toggle, isEnabled);
420 + }
421 + }
422 + }]);
423 +};
424 +
425 +/**
426 + * Initialize custom fullscreen view buttons.
427 + *
428 + * Delegates clicks on `.lp-btn-full-screen-view` buttons to
429 + * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
430 + * target element. Falls back to the button's parent element when
431 + * `data-target` is not provided.
432 + *
433 + * @since 4.4.5
434 + * @version 1.0.0
435 + */
436 +window.lpFullScreenViewInit = 0;
437 +const fullScreenView = () => {
438 + if (window.lpFullScreenViewInit) {
439 + return;
440 + }
441 + window.lpFullScreenViewInit = 1;
442 + let lastScrollY = 0;
443 + const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
444 + const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
445 + if (isFullscreen) {
446 + elTarget.classList.remove(lpClassName.elFullScreen);
447 + document.documentElement.classList.remove('lp-full-screen-active');
448 + window.scrollTo(0, lastScrollY);
449 + } else {
450 + lastScrollY = window.scrollY;
451 + elTarget.classList.add(lpClassName.elFullScreen);
452 + document.documentElement.classList.add('lp-full-screen-active');
453 + }
454 + if (!isFullscreen) {
455 + if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
456 + const closeButton = document.createElement('button');
457 + closeButton.type = 'button';
458 + closeButton.className = lpClassName.elBtnFullScreenClose;
459 + closeButton.setAttribute('aria-label', 'Close');
460 + closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
461 + closeButton.addEventListener('click', e => {
462 + e.preventDefault();
463 + lpToggleFullscreenView(elTarget);
464 + });
465 + elTarget.appendChild(closeButton);
466 + }
467 + } else {
468 + const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
469 + if (closeButton) {
470 + closeButton.remove();
471 + }
472 + }
473 + };
474 + eventHandlers('click', [{
475 + selector: lpClassName.elBtnFullScreen,
476 + callBack: args => {
477 + const {
478 + e,
479 + target
480 + } = args;
481 + const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
482 + if (!elBtnFullScreen) {
483 + console.log('No full screen button found');
484 + return;
485 + }
486 + e.preventDefault();
487 + let elTarget = null;
488 + const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
489 + console.log(targetSelector);
490 + if (targetSelector) {
491 + elTarget = document.querySelector(targetSelector);
492 + }
493 + if (!elTarget) {
494 + console.log('No target element found');
495 + return;
496 + }
497 + lpToggleFullscreenView(elTarget, elBtnFullScreen);
498 + }
499 + }]);
500 +};
501 +
364 502 /***/ }
365 503
366 504 /******/ });
367 505 /************************************************************************/
368 506 /******/ // The module cache
369 -/******/ var __webpack_module_cache__ = {};
507 +/******/ const __webpack_module_cache__ = {};
370 508 /******/
371 509 /******/ // The require function
372 510 /******/ function __webpack_require__(moduleId) {
373 511 /******/ // Check if module is in cache
374 -/******/ var cachedModule = __webpack_module_cache__[moduleId];
512 +/******/ const cachedModule = __webpack_module_cache__[moduleId];
375 513 /******/ if (cachedModule !== undefined) {
376 514 /******/ return cachedModule.exports;
377 515 /******/ }
378 516 /******/ // Create a new module (and put it into the cache)
379 -/******/ var module = __webpack_module_cache__[moduleId] = {
517 +/******/ const module = __webpack_module_cache__[moduleId] = {
380 518 /******/ // no module.id needed
381 519 /******/ // no module.loaded needed
382 520 /******/ exports: {}
383 521 /******/ };
@@ -384,9 +522,9 @@
384 522 /******/
385 523 /******/ // Execute the module function
386 524 /******/ if (!(moduleId in __webpack_modules__)) {
387 525 /******/ delete __webpack_module_cache__[moduleId];
388 -/******/ var e = new Error("Cannot find module '" + moduleId + "'");
526 +/******/ const e = new Error("Cannot find module '" + moduleId + "'");
389 527 /******/ e.code = 'MODULE_NOT_FOUND';
390 528 /******/ throw e;
391 529 /******/ }
392 530 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
@@ -397,14 +535,29 @@
397 535 /******/
398 536 /************************************************************************/
399 537 /******/ /* webpack/runtime/define property getters */
400 538 /******/ (() => {
401 -/******/ // define getter functions for harmony exports
539 +/******/ // define getter/value functions for harmony exports
402 540 /******/ __webpack_require__.d = (exports, definition) => {
403 -/******/ for(var key in definition) {
404 -/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
405 -/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
541 +/******/ if(Array.isArray(definition)) {
542 +/******/ var i = 0;
543 +/******/ while(i < definition.length) {
544 +/******/ var key = definition[i++];
545 +/******/ var binding = definition[i++];
546 +/******/ if(!__webpack_require__.o(exports, key)) {
547 +/******/ if(binding === 0) {
548 +/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
549 +/******/ } else {
550 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
551 +/******/ }
552 +/******/ } else if(binding === 0) { i++; }
406 553 /******/ }
554 +/******/ } else {
555 +/******/ for(var key in definition) {
556 +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
557 +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
558 +/******/ }
559 +/******/ }
407 560 /******/ }
408 561 /******/ };
409 562 /******/ })();
410 563 /******/
@@ -409,9 +562,9 @@
409 562 /******/ })();
410 563 /******/
411 564 /******/ /* webpack/runtime/hasOwnProperty shorthand */
412 565 /******/ (() => {
413 -/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
566 +/******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
414 567 /******/ })();
415 568 /******/
416 569 /******/ /* webpack/runtime/make namespace object */
417 570 /******/ (() => {
@@ -416,9 +569,9 @@
416 569 /******/ /* webpack/runtime/make namespace object */
417 570 /******/ (() => {
418 571 /******/ // define __esModule on exports
419 572 /******/ __webpack_require__.r = (exports) => {
420 -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
573 +/******/ if(Symbol.toStringTag) {
421 574 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
422 575 /******/ }
423 576 /******/ Object.defineProperty(exports, '__esModule', { value: true });
424 577 /******/ };
@@ -424,9 +577,9 @@
424 577 /******/ };
425 578 /******/ })();
426 579 /******/
427 580 /************************************************************************/
428 -var __webpack_exports__ = {};
581 +let __webpack_exports__ = {};
429 582 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
430 583 (() => {
431 584 /*!*******************************************************!*\
432 585 !*** ./assets/src/js/admin/list-students-enrolled.js ***!
@@ -449,12 +602,12 @@
449 602 class ListStudentsEnrolled {
450 603 constructor() {
451 604 this.instructorId = null;
452 605 this.elContainer = null;
453 - this.isRequesting = false;
454 606 }
455 607 static selectors = {
456 - elContainer: '#lp-enrolled-students',
608 + elContainer: '.lp-enrolled-students',
609 + elLayout: '.lp-students-enrolled-layout',
457 610 elForm: '.lp-enrolled-students-form',
458 611 elLPTarget: '.lp-target',
459 612 elCourseNameInput: '.lp-enrolled-filter-course-name',
460 613 elCourseIdInput: '#lp-enrolled-filter-course-id',
@@ -488,46 +641,38 @@
488 641
489 642 // Search/Clear button click.
490 643 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
491 644 selector: ListStudentsEnrolled.selectors.elBtnSearch,
492 - class: this,
493 - callBack: this.searchStudents.name
645 + callBack: this.searchStudents.bind(this)
494 646 }, {
495 647 selector: ListStudentsEnrolled.selectors.elBtnClear,
496 - class: this,
497 - callBack: this.clearFilters.name
648 + callBack: this.clearFilters.bind(this)
498 649 }]);
499 650
500 651 // Search on Enter key.
501 652 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keydown', [{
502 653 selector: ListStudentsEnrolled.selectors.elSearchInput,
503 - class: this,
504 - callBack: this.triggerBtnSearch.name,
654 + callBack: this.triggerBtnSearch.bind(this),
505 655 checkIsEventEnter: true
506 656 }, {
507 657 selector: ListStudentsEnrolled.selectors.elCourseNameInput,
508 - class: this,
509 - callBack: this.triggerBtnSearch.name,
658 + callBack: this.triggerBtnSearch.bind(this),
510 659 checkIsEventEnter: true
511 660 }, {
512 661 selector: ListStudentsEnrolled.selectors.elStartDateInput,
513 - class: this,
514 - callBack: this.triggerBtnSearch.name,
662 + callBack: this.triggerBtnSearch.bind(this),
515 663 checkIsEventEnter: true
516 664 }, {
517 665 selector: ListStudentsEnrolled.selectors.elEndDateInput,
518 - class: this,
519 - callBack: this.triggerBtnSearch.name,
666 + callBack: this.triggerBtnSearch.bind(this),
520 667 checkIsEventEnter: true
521 668 }]);
522 669 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('change', [{
523 670 selector: ListStudentsEnrolled.selectors.elStartDateInput,
524 - class: this,
525 - callBack: this.checkDatesRange.name
671 + callBack: this.checkDatesRange.bind(this)
526 672 }, {
527 673 selector: ListStudentsEnrolled.selectors.elEndDateInput,
528 - class: this,
529 - callBack: this.checkDatesRange.name
674 + callBack: this.checkDatesRange.bind(this)
530 675 }]);
531 676 }
532 677
533 678 // Click button search.
@@ -577,9 +722,9 @@
577 722 if (!btn) {
578 723 return;
579 724 }
580 725 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(btn, isLoading ? 1 : 0);
581 - btn.disabled = !!isLoading;
726 + //btn.disabled = !! isLoading;
582 727 }
583 728 getAjaxHandle() {
584 729 const ajaxHandle = window.lpAJAXG;
585 730 if (!ajaxHandle || typeof ajaxHandle.getDataSetCurrent !== 'function' || typeof ajaxHandle.setDataSetCurrent !== 'function' || typeof ajaxHandle.showHideLoading !== 'function' || typeof ajaxHandle.fetchAJAX !== 'function') {
@@ -620,17 +765,14 @@
620 765 if (e) {
621 766 e.preventDefault();
622 767 }
623 768 const btn = args?.target?.closest(ListStudentsEnrolled.selectors.elBtnSearch);
624 - if (btn) {
625 - if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
626 - return;
627 - }
628 - } else if (this.isRequesting) {
769 + if (!btn) {
629 770 return;
630 771 }
631 772 const elForm = btn.closest(ListStudentsEnrolled.selectors.elForm);
632 - const elLPTarget = this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget);
773 + const elLayout = elForm.closest(ListStudentsEnrolled.selectors.elLayout);
774 + const elLPTarget = elLayout.querySelector(ListStudentsEnrolled.selectors.elLPTarget);
633 775 if (!elLPTarget || !elForm) {
634 776 return;
635 777 }
636 778 const ajaxHandle = this.getAjaxHandle();
@@ -656,17 +798,14 @@
656 798 if (e) {
657 799 e.preventDefault();
658 800 }
659 801 const btn = args?.target?.closest(ListStudentsEnrolled.selectors.elBtnClear);
660 - if (btn) {
661 - if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
662 - return;
663 - }
664 - } else if (this.isRequesting) {
802 + if (!btn) {
665 803 return;
666 804 }
667 805 const elForm = btn.closest(ListStudentsEnrolled.selectors.elForm);
668 - const elLPTarget = this.elContainer.querySelector(ListStudentsEnrolled.selectors.elLPTarget);
806 + const elLayout = elForm.closest(ListStudentsEnrolled.selectors.elLayout);
807 + const elLPTarget = elLayout.querySelector(ListStudentsEnrolled.selectors.elLPTarget);
669 808 if (!elLPTarget || !elForm) {
670 809 return;
671 810 }
672 811 const ajaxHandle = this.getAjaxHandle();
@@ -691,13 +830,11 @@
691 830 */
692 831 reloadContent(elLPTarget, dataSend, btn = null) {
693 832 const ajaxHandle = this.getAjaxHandle();
694 833 if (!ajaxHandle) {
695 - this.isRequesting = false;
696 834 this.setButtonLoadingState(btn, false);
697 835 return;
698 836 }
699 - this.isRequesting = true;
700 837 ajaxHandle.showHideLoading(elLPTarget, 1);
701 838 const callBack = {
702 839 success: response => {
703 840 const {
@@ -709,9 +846,8 @@
709 846 }
710 847 },
711 848 error: error => console.error(error),
712 849 completed: () => {
713 - this.isRequesting = false;
714 850 ajaxHandle.showHideLoading(elLPTarget, 0);
715 851 this.setButtonLoadingState(btn, false);
716 852 }
717 853 };