Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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
import Modal from 'core/modal';
17
import Policy from './policy';
18
import CustomEvents from 'core/custom_interaction_events';
19
 
20
/**
21
 * The Javascript module to handle the policy modal.
22
 *
23
 * @module     core_ai/policymodal
24
 * @copyright  Andrew Lyons <andrew@nicols.co.uk>
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
27
export default class PolicyModal extends Modal {
28
    static TYPE = 'core_ai/policymodal';
29
    static TEMPLATE = 'core_ai/policymodal';
30
 
31
    /**
32
     * Configure the modal.
33
     *
34
     * @param {object} modalConfig The modal configuration.
35
     */
36
    configure(modalConfig) {
37
        super.configure({
38
            ...modalConfig,
39
            show: true,
40
            removeOnClose: true,
41
        });
42
 
43
        this.context = modalConfig.context;
44
        this.setXlarge();
45
    }
46
 
47
    /**
48
     * Set the modal to be extra large.
49
     */
50
    setXlarge() {
51
        this.getModal().addClass('modal-xl');
52
    }
53
 
54
    /**
55
     * Handle click events within the policy modal.
56
     */
57
    registerEventListeners() {
58
        super.registerEventListeners();
59
        this.registerCloseOnSave();
60
        this.registerCloseOnCancel();
61
 
62
        this.getModal().on(CustomEvents.events.activate, this.getActionSelector('save'), (e) => {
63
            e.preventDefault();
64
            Policy.acceptPolicy();
65
        });
66
    }
67
}