stronk7

Untitled

Oct 21st, 2021
789
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- a/course/format/amd/src/local/content.js
  2. +++ b/course/format/amd/src/local/content.js
  3. @@ -48,16 +48,14 @@ export default class Component extends BaseComponent {
  4.              CM: `[data-for='cmitem']`,
  5.              TOGGLER: `[data-action="togglecoursecontentsection"]`,
  6.              COLLAPSE: `[data-toggle="collapse"]`,
  7. +            // Formats can override the activity tag but a default one is needed to create new elements.
  8. +            ACTIVITYTAG: 'li',
  9.          };
  10.          // Default classes to toggle on refresh.
  11.          this.classes = {
  12.              COLLAPSED: `collapsed`,
  13. -            // Formats can override the activity tag but a default one is needed to create new elements.
  14. -            ACTIVITYTAG: 'li',
  15. -
  16. -            // Course content classes.
  17. -            ACTIVITY: `activity`,
  18.              STATEDREADY: `stateready`,
  19. +            ACTIVITY: `activity`,
  20.          };
  21.          // Array to save dettached elements during element resorting.
  22.          this.dettachedCms = {};
  23. @@ -89,6 +87,16 @@ export default class Component extends BaseComponent {
  24.          this._indexContents();
  25.          // Activate section togglers.
  26.          this.addEventListener(this.element, 'click', this._sectionTogglers);
  27. +
  28. +        if (this.reactive.supportComponents) {
  29. +            // Actions are only available in edit mode.
  30. +            if (this.reactive.isEditing) {
  31. +                new DispatchActions(this);
  32. +            }
  33. +
  34. +            // Mark content as state ready.
  35. +            this.element.classList.add(this.classes.STATEDREADY);
  36. +        }
  37.      }
  38.  
  39.      /**
  40. @@ -123,30 +131,6 @@ export default class Component extends BaseComponent {
  41.          }
  42.      }
  43.  
  44. -    /**
  45. -     *
  46. -     * Course content elements could not provide JS Components because the elements HTML is applied
  47. -     * directly from the course actions. To keep internal components updated this module keeps
  48. -     * a list of the active components and mark them as "indexed". This way when any action replace
  49. -     * the HTML this component will recreate the components an add any necessary event listener.
  50. -     *
  51. -     * Format plugins can override this method to provide extra logic to the course frontend.
  52. -     *
  53. -     */
  54. -    stateReady() {
  55. -        this._indexContents();
  56. -
  57. -        if (this.reactive.supportComponents) {
  58. -            // Actions are only available in edit mode.
  59. -            if (this.reactive.isEditing) {
  60. -                new DispatchActions(this);
  61. -            }
  62. -
  63. -            // Mark content as state ready.
  64. -            this.element.classList.add(this.classes.STATEDREADY);
  65. -        }
  66. -    }
  67. -
  68.      /**
  69.       * Return the component watchers.
  70.       *
RAW Paste Data