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
// Moodle is free software: you can redistribute it and/or modify
3
// it under the terms of the GNU General Public License as published by
4
// the Free Software Foundation, either version 3 of the License, or
5
// (at your option) any later version.
6
//
7
// Moodle is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
// GNU General Public License for more details.
11
//
12
// You should have received a copy of the GNU General Public License
13
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
14
 
15
/**
16
 * Javascript events for the `editor_atto` plugin.
17
 *
18
 * @module     editor_atto/events
19
 * @copyright  2021 Jun Pataleta <jun@moodle.com>
20
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21
 * @since      3.10.5
22
 */
23
 
24
import {dispatchEvent} from 'core/event_dispatcher';
25
 
26
/**
27
 * Events for the `editor_atto` plugin.
28
 *
29
 * @constant
30
 * @property {String} attoButtonHighlightToggled See {@link event:attoButtonHighlightToggled}
31
 */
32
export const eventTypes = {
33
    /**
34
     * An event triggered when a toolbar button's highlight gets toggled.
35
     *
36
     * @event attoButtonHighlightToggled
37
     * @type {CustomEvent}
38
     * @property {HTMLElement} target The button which had its highlight toggled.
39
     * @property {object} detail
40
     * @property {String} detail.buttonName The name of the Atto button that has had its highlight toggled.
41
     * @property {Boolean} detail.highlight True when the button was highlighted. False, otherwise.
42
     */
43
    attoButtonHighlightToggled: 'editor_atto/attoButtonHighlightToggled',
44
};
45
 
46
/**
47
 * Trigger an event to indicate that a button's highlight was toggled.
48
 *
49
 * @method  notifyButtonHighlightToggled
50
 * @returns {CustomEvent}
51
 * @fires   attoButtonHighlightToggled
52
 * @param {HTMLElement} attoButton The button object.
53
 * @param {String} buttonName The button name.
54
 * @param {Boolean} highlight True when the button was highlighted. False, otherwise.
55
 */
56
export const notifyButtonHighlightToggled = (attoButton, buttonName, highlight) => {
57
    return dispatchEvent(
58
        eventTypes.attoButtonHighlightToggled,
59
        {
60
            buttonName,
61
            highlight,
62
        },
63
        attoButton
64
    );
65
};