Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Course index drawer wrap.
18
 *
19
 * This component is mostly used to ensure all subcomponents find a parent
20
 * compoment with a reactive instance defined.
21
 *
22
 * @module     core_courseformat/local/courseindex/drawer
23
 * @class     core_courseformat/local/courseindex/drawer
24
 * @copyright  2021 Ferran Recio <ferran@moodle.com>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
 
28
import {BaseComponent} from 'core/reactive';
29
import {getCurrentCourseEditor} from 'core_courseformat/courseeditor';
30
 
31
export default class Component extends BaseComponent {
32
 
33
    /**
34
     * Constructor hook.
35
     */
36
    create() {
37
        // Optional component name for debugging.
38
        this.name = 'courseindex-drawer';
39
    }
40
 
41
    /**
42
     * Static method to create a component instance form the mustache template.
43
     *
44
     * @param {element|string} target the DOM main element or its ID
45
     * @param {object} selectors optional css selector overrides
46
     * @return {Component}
47
     */
48
    static init(target, selectors) {
49
        return new this({
50
            element: document.getElementById(target),
51
            reactive: getCurrentCourseEditor(),
52
            selectors,
53
        });
54
    }
55
}