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 |
* Javascript events for the `tool_usertours` subsystem.
|
|
|
18 |
*
|
|
|
19 |
* @module tool_usertours/events
|
|
|
20 |
* @copyright 2021 Andrew Lyons <andrew@nicols.co.uk>
|
|
|
21 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
22 |
*
|
|
|
23 |
* @example <caption>Example of listening to a step rendering event and cancelling it.</caption>
|
|
|
24 |
* import {eventTypes as userTourEvents} from 'tool_usertours/events';
|
|
|
25 |
*
|
|
|
26 |
* document.addEventListener(userTourEvents.stepRender, e => {
|
|
|
27 |
* console.log(e.detail.tour); // The Tour instance
|
|
|
28 |
* e.preventDefault();
|
|
|
29 |
* });
|
|
|
30 |
*/
|
|
|
31 |
|
|
|
32 |
/**
|
|
|
33 |
* Events for the component.
|
|
|
34 |
*
|
|
|
35 |
* @constant
|
|
|
36 |
* @property {object} eventTypes
|
|
|
37 |
* @property {String} eventTypes.stepRender See {@link event:tool_usertours/stepRender}
|
|
|
38 |
* @property {String} eventTypes.stepRendered See {@link event:tool_usertours/stepRendered}
|
|
|
39 |
* @property {String} eventTypes.tourStart See {@link event:tool_usertours/tourStart}
|
|
|
40 |
* @property {String} eventTypes.tourStarted See {@link event:tool_usertours/tourStarted}
|
|
|
41 |
* @property {String} eventTypes.tourEnd See {@link event:tool_usertours/tourEnd}
|
|
|
42 |
* @property {String} eventTypes.tourEnded See {@link event:tool_usertours/tourEnded}
|
|
|
43 |
* @property {String} eventTypes.stepHide See {@link event:tool_usertours/stepHide}
|
|
|
44 |
* @property {String} eventTypes.stepHidden See {@link event:tool_usertours/stepHidden}
|
|
|
45 |
*/
|
|
|
46 |
export const eventTypes = {
|
|
|
47 |
/**
|
|
|
48 |
* An event triggered before a user tour step is rendered.
|
|
|
49 |
*
|
|
|
50 |
* This event is cancellable.
|
|
|
51 |
*
|
|
|
52 |
* @event tool_usertours/stepRender
|
|
|
53 |
* @type {CustomEvent}
|
|
|
54 |
* @property {object} detail
|
|
|
55 |
* @property {tool_usertours/tour} detail.tour
|
|
|
56 |
* @property {object} detail.stepConfig
|
|
|
57 |
*/
|
|
|
58 |
stepRender: 'tool_usertours/stepRender',
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* An event triggered after a user tour step has been rendered.
|
|
|
62 |
*
|
|
|
63 |
* @event tool_usertours/stepRendered
|
|
|
64 |
* @type {CustomEvent}
|
|
|
65 |
* @property {object} detail
|
|
|
66 |
* @property {tool_usertours/tour} detail.tour
|
|
|
67 |
* @property {object} detail.stepConfig
|
|
|
68 |
*/
|
|
|
69 |
stepRendered: 'tool_usertours/stepRendered',
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
* An event triggered before a user tour starts.
|
|
|
73 |
*
|
|
|
74 |
* This event is cancellable.
|
|
|
75 |
*
|
|
|
76 |
* @event tool_usertours/tourStart
|
|
|
77 |
* @type {CustomEvent}
|
|
|
78 |
* @property {object} detail
|
|
|
79 |
* @property {tool_usertours/tour} detail.tour
|
|
|
80 |
* @property {Number} detail.startAt
|
|
|
81 |
*/
|
|
|
82 |
tourStart: 'tool_usertours/tourStart',
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* An event triggered after a user tour has started.
|
|
|
86 |
*
|
|
|
87 |
* @event tool_usertours/tourStarted
|
|
|
88 |
* @property {object} detail
|
|
|
89 |
* @property {tool_usertours/tour} detail.tour
|
|
|
90 |
* @type {CustomEvent}
|
|
|
91 |
*/
|
|
|
92 |
tourStarted: 'tool_usertours/tourStarted',
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* An event triggered before a tour ends.
|
|
|
96 |
*
|
|
|
97 |
* This event is cancellable.
|
|
|
98 |
*
|
|
|
99 |
* @event tool_usertours/tourEnd
|
|
|
100 |
* @property {object} detail
|
|
|
101 |
* @property {tool_usertours/tour} detail.tour
|
|
|
102 |
* @type {CustomEvent}
|
|
|
103 |
*/
|
|
|
104 |
tourEnd: 'tool_usertours/tourEnd',
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* An event triggered after a tour has ended.
|
|
|
108 |
*
|
|
|
109 |
* @event tool_usertours/tourEnded
|
|
|
110 |
* @property {object} detail
|
|
|
111 |
* @property {tool_usertours/tour} detail.tour
|
|
|
112 |
* @type {CustomEvent}
|
|
|
113 |
*/
|
|
|
114 |
tourEnded: 'tool_usertours/tourEnded',
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
* An event triggered before a step is hidden.
|
|
|
118 |
*
|
|
|
119 |
* This event is cancellable.
|
|
|
120 |
*
|
|
|
121 |
* @event tool_usertours/stepHide
|
|
|
122 |
* @property {object} detail
|
|
|
123 |
* @property {tool_usertours/tour} detail.tour
|
|
|
124 |
* @type {CustomEvent}
|
|
|
125 |
*/
|
|
|
126 |
stepHide: 'tool_usertours/stepHide',
|
|
|
127 |
|
|
|
128 |
/**
|
|
|
129 |
* An event triggered after a step has been hidden.
|
|
|
130 |
*
|
|
|
131 |
* @event tool_usertours/stepHidden
|
|
|
132 |
* @property {object} detail
|
|
|
133 |
* @property {tool_usertours/tour} detail.tour
|
|
|
134 |
* @type {CustomEvent}
|
|
|
135 |
*/
|
|
|
136 |
stepHidden: 'tool_usertours/stepHidden',
|
|
|
137 |
};
|