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 `process_monitor` module.
|
|
|
17 |
*
|
|
|
18 |
* @module core/local/process_monitor/events
|
|
|
19 |
* @copyright 2022 Ferran Recio <ferran@moodle.com>
|
|
|
20 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
21 |
* @since 4.2
|
|
|
22 |
*/
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Events for the `core_editor` subsystem.
|
|
|
26 |
*
|
|
|
27 |
* @constant
|
|
|
28 |
* @property {String} processMonitorStateChange See {@link event:processMonitorStateChange}
|
|
|
29 |
*/
|
|
|
30 |
export const eventTypes = {
|
|
|
31 |
/**
|
|
|
32 |
* An event triggered when the monitor state has changed.
|
|
|
33 |
*
|
|
|
34 |
* @event processMonitorStateChange
|
|
|
35 |
*/
|
|
|
36 |
processMonitorStateChange: 'core_editor/contentRestored',
|
|
|
37 |
};
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Trigger a state changed event.
|
|
|
41 |
*
|
|
|
42 |
* @method dispatchStateChangedEvent
|
|
|
43 |
* @param {Object} detail the full state
|
|
|
44 |
* @param {Object} target the custom event target (document if none provided)
|
|
|
45 |
* @param {Function} target.dispatchEvent the component dispatch event method.
|
|
|
46 |
*/
|
|
|
47 |
export function dispatchStateChangedEvent(detail, target) {
|
|
|
48 |
if (target === undefined) {
|
|
|
49 |
target = document;
|
|
|
50 |
}
|
|
|
51 |
target.dispatchEvent(new CustomEvent(
|
|
|
52 |
eventTypes.processMonitorStateChange,
|
|
|
53 |
{
|
|
|
54 |
bubbles: true,
|
|
|
55 |
detail: detail,
|
|
|
56 |
}
|
|
|
57 |
));
|
|
|
58 |
}
|