Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 18... Línea 18...
18
 *
18
 *
19
 * @module     theme_universe/courseindexdrawercontrols
19
 * @module     theme_universe/courseindexdrawercontrols
20
 * @copyright  2023 Stefan Topfstedt
20
 * @copyright  2023 Stefan Topfstedt
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
22
 */
-
 
23
import {BaseComponent} from 'core/reactive';
-
 
24
import {getCurrentCourseEditor} from 'core_courseformat/courseeditor';
Línea 23... Línea -...
23
 
-
 
24
define(function (require) {
-
 
25
  const { BaseComponent } = require("core/reactive");
-
 
26
  const { getCurrentCourseEditor } = require("core_courseformat/courseeditor");
-
 
27
 
25
 
28
  class Component extends BaseComponent {
-
 
29
    create() {
-
 
30
      this.name = "courseindexdrawercontrols";
-
 
31
      this.selectors = {
-
 
32
        COLLAPSEALL: `[data-action="collapseallcourseindexsections"]`,
-
 
33
        EXPANDALL: `[data-action="expandallcourseindexsections"]`,
-
 
34
      };
-
 
Línea 35... Línea 26...
35
    }
26
export default class Component extends BaseComponent {
36
 
-
 
37
    /**
27
 
38
     * @param {element|string} target the DOM main element or its ID
-
 
39
     * @param {object} selectors optional css selector overrides
-
 
40
     * @return {Component}
28
  create() {
41
     */
-
 
42
    static init(target, selectors) {
29
    this.name = 'courseindexdrawercontrols';
43
      return new Component({
30
    this.selectors = {
44
        element: document.getElementById(target),
-
 
45
        reactive: getCurrentCourseEditor(),
31
      COLLAPSEALL: `[data-action="collapseallcourseindexsections"]`,
46
        selectors,
32
      EXPANDALL: `[data-action="expandallcourseindexsections"]`,
Línea 47... Línea 33...
47
      });
33
    };
48
    }
-
 
49
 
-
 
50
    /**
-
 
51
     * Initial state ready method.
34
  }
52
     */
35
 
53
    stateReady() {
36
  /**
54
      // Attach the on-click event handlers to the expand-all and collapse-all buttons, if present.
-
 
55
      const expandAllBtn = this.getElement(this.selectors.EXPANDALL);
37
   * @param {element|string} target the DOM main element or its ID
56
      if (expandAllBtn) {
-
 
57
        this.addEventListener(expandAllBtn, "click", this._expandAllSections);
38
   * @param {object} selectors optional css selector overrides
58
      }
39
   * @return {Component}
59
      const collapseAllBtn = this.getElement(this.selectors.COLLAPSEALL);
40
   */
60
      if (collapseAllBtn) {
-
 
61
        this.addEventListener(
41
  static init(target, selectors) {
62
          collapseAllBtn,
42
    return new Component({
63
          "click",
43
      element: document.getElementById(target),
64
          this._collapseAllSections
44
      reactive: getCurrentCourseEditor(),
Línea 65... Línea 45...
65
        );
45
      selectors,
66
      }
46
    });
67
    }
-
 
68
 
47
  }
69
    /**
48
 
-
 
49
  /**
70
     * On-click event handler for the collapse-all button.
50
   * Initial state ready method.
71
     * @private
51
   */
-
 
52
  stateReady() {
Línea 72... Línea -...
72
     */
-
 
73
    _collapseAllSections() {
-
 
74
      this._toggleAllSections(true);
-
 
75
    }
-
 
76
 
-
 
77
    /**
-
 
78
     * On-click event handler for the expand-all button.
53
    // Attach the on-click event handlers to the expand-all and collapse-all buttons, if present.
79
     * @private
-
 
80
     */
-
 
81
    _expandAllSections() {
54
    const expandAllBtn = this.getElement(this.selectors.EXPANDALL);
82
      this._toggleAllSections(false);
-
 
83
    }
-
 
84
 
-
 
85
    /**
55
    if (expandAllBtn) {
86
     * Collapses or expands all sections in the course index.
56
      this.addEventListener(expandAllBtn, 'click', this._expandAllSections);
87
     * @param {boolean} expandOrCollapse set to TRUE to collapse all, and FALSE to expand all.
57
 
88
     * @private
58
    }
Línea -... Línea 59...
-
 
59
    const collapseAllBtn = this.getElement(this.selectors.COLLAPSEALL);
-
 
60
    if (collapseAllBtn) {
-
 
61
      this.addEventListener(collapseAllBtn, 'click', this._collapseAllSections);
-
 
62
    }
-
 
63
  }
-
 
64
 
-
 
65
  /**
-
 
66
   * On-click event handler for the collapse-all button.
-
 
67
   * @private
-
 
68
   */
-
 
69
  _collapseAllSections() {
-
 
70
    this._toggleAllSections(true);
89
     */
71
  }
-
 
72
 
-
 
73
  /**
-
 
74
   * On-click event handler for the expand-all button.
-
 
75
   * @private
-
 
76
   */
-
 
77
  _expandAllSections() {
-
 
78
    this._toggleAllSections(false);
-
 
79
  }
-
 
80
 
-
 
81
  /**
-
 
82
   * Collapses or expands all sections in the course index.
90
    _toggleAllSections(expandOrCollapse) {
83
   * @param {boolean} expandOrCollapse set to TRUE to collapse all, and FALSE to expand all.