Advertisement
stronk7

Untitled

Oct 21st, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.60 KB | None | 0 0
  1. $ git diff master FETCH_HEAD course/format/amd/src/local/content.js
  2. diff --git a/course/format/amd/src/local/content.js b/course/format/amd/src/local/content.js
  3. index 81a3ec04544..f6497345535 100644
  4. --- a/course/format/amd/src/local/content.js
  5. +++ b/course/format/amd/src/local/content.js
  6. @@ -48,16 +48,14 @@ export default class Component extends BaseComponent {
  7. CM: `[data-for='cmitem']`,
  8. TOGGLER: `[data-action="togglecoursecontentsection"]`,
  9. COLLAPSE: `[data-toggle="collapse"]`,
  10. + // Formats can override the activity tag but a default one is needed to create new elements.
  11. + ACTIVITYTAG: 'li',
  12. };
  13. // Default classes to toggle on refresh.
  14. this.classes = {
  15. COLLAPSED: `collapsed`,
  16. - // Formats can override the activity tag but a default one is needed to create new elements.
  17. - ACTIVITYTAG: 'li',
  18. -
  19. - // Course content classes.
  20. - ACTIVITY: `activity`,
  21. STATEDREADY: `stateready`,
  22. + ACTIVITY: `activity`,
  23. };
  24. // Array to save dettached elements during element resorting.
  25. this.dettachedCms = {};
  26. @@ -89,6 +87,16 @@ export default class Component extends BaseComponent {
  27. this._indexContents();
  28. // Activate section togglers.
  29. this.addEventListener(this.element, 'click', this._sectionTogglers);
  30. +
  31. + if (this.reactive.supportComponents) {
  32. + // Actions are only available in edit mode.
  33. + if (this.reactive.isEditing) {
  34. + new DispatchActions(this);
  35. + }
  36. +
  37. + // Mark content as state ready.
  38. + this.element.classList.add(this.classes.STATEDREADY);
  39. + }
  40. }
  41.  
  42. /**
  43. @@ -123,30 +131,6 @@ export default class Component extends BaseComponent {
  44. }
  45. }
  46.  
  47. - /**
  48. - *
  49. - * Course content elements could not provide JS Components because the elements HTML is applied
  50. - * directly from the course actions. To keep internal components updated this module keeps
  51. - * a list of the active components and mark them as "indexed". This way when any action replace
  52. - * the HTML this component will recreate the components an add any necessary event listener.
  53. - *
  54. - * Format plugins can override this method to provide extra logic to the course frontend.
  55. - *
  56. - */
  57. - stateReady() {
  58. - this._indexContents();
  59. -
  60. - if (this.reactive.supportComponents) {
  61. - // Actions are only available in edit mode.
  62. - if (this.reactive.isEditing) {
  63. - new DispatchActions(this);
  64. - }
  65. -
  66. - // Mark content as state ready.
  67. - this.element.classList.add(this.classes.STATEDREADY);
  68. - }
  69. - }
  70. -
  71. /**
  72. * Return the component watchers.
  73. *
  74. @@ -182,8 +166,7 @@ export default class Component extends BaseComponent {
  75. * Most course module HTML is still strongly backend dependant.
  76. * Some changes require to get a new version af the module.
  77. *
  78. - * @param {Object} param
  79. - * @param {Object} param.element update the state update data
  80. + * @param {Object} update the state update data
  81. */
  82. _reloadCm({element}) {
  83. const cmitem = this.getElement(this.selectors.CM, element.id);
  84. @@ -195,8 +178,7 @@ export default class Component extends BaseComponent {
  85. /**
  86. * Update section collapsed.
  87. *
  88. - * @param {object} args
  89. - * @param {Object} args.element The element to update
  90. + * @param {Object} details the update details.
  91. */
  92. _refreshSectionCollapsed({element}) {
  93. const target = this.getElement(this.selectors.SECTION, element.id);
  94. @@ -236,8 +218,7 @@ export default class Component extends BaseComponent {
  95. * Course formats can override the section title rendering so the frontend depends heavily on backend
  96. * rendering. Luckily in edit mode we can trigger a title update using the inplace_editable module.
  97. *
  98. - * @param {Object} param
  99. - * @param {Object} param.element details the update details.
  100. + * @param {Object} details the update details.
  101. */
  102. _refreshSectionNumber({element}) {
  103. // Find the element.
  104. @@ -275,8 +256,8 @@ export default class Component extends BaseComponent {
  105. /**
  106. * Refresh a section cm list.
  107. *
  108. - * @param {Object} param
  109. - * @param {Object} param.element details the update details.
  110. + * @param {details} details the update details
  111. + * @property {object} details.element the state object
  112. */
  113. _refreshSectionCmlist({element}) {
  114. const cmlist = element.cmlist ?? [];
  115. @@ -292,8 +273,7 @@ export default class Component extends BaseComponent {
  116. /**
  117. * Refresh the section list.
  118. *
  119. - * @param {Object} param
  120. - * @param {Object} param.element details the update details.
  121. + * @param {Object} details the update details.
  122. */
  123. _refreshCourseSectionlist({element}) {
  124. const sectionlist = element.sectionlist ?? [];
  125. @@ -365,8 +345,8 @@ export default class Component extends BaseComponent {
  126. * Most course module HTML is still strongly backend dependant.
  127. * Some changes require to get a new version of the module.
  128. *
  129. - * @param {object} param0 the watcher details
  130. - * @param {object} param0.element the state object
  131. + * @param {details} param0 the watcher details
  132. + * @property {object} param0.element the state object
  133. */
  134. _reloadCm({element}) {
  135. const cmitem = this.getElement(this.selectors.CM, element.id);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement