MDL-67264 core_course: Activity chooser new feature
[moodle.git] / course / amd / src / local / activitychooser / selectors.js
CommitLineData
05b27f21
MM
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 * Define all of the selectors we will be using on the grading interface.
18 *
19 * @module core_course/local/chooser/selectors
20 * @package core_course
21 * @copyright 2019 Mathew May <mathew.solutions>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25/**
26 * A small helper function to build queryable data selectors.
27 * @method getDataSelector
28 * @param {String} name
29 * @param {String} value
30 * @return {string}
31 */
32const getDataSelector = (name, value) => {
33 return `[data-${name}="${value}"]`;
34};
35
36export default {
37 regions: {
38 chooser: getDataSelector('region', 'chooser-container'),
39 chooserOptions: getDataSelector('region', 'chooser-options-container'),
40 chooserOption: {
41 container: getDataSelector('region', 'chooser-option-container'),
42 actions: getDataSelector('region', 'chooser-option-actions-container'),
43 info: getDataSelector('region', 'chooser-option-info-container'),
44 },
45 chooserSummary: {
46 container: getDataSelector('region', 'chooser-option-summary-container'),
47 content: getDataSelector('region', 'chooser-option-summary-content-container'),
48 description: getDataSelector('region', 'summary-description'),
49 actions: getDataSelector('region', 'chooser-option-summary-actions-container'),
50 },
51 carousel: getDataSelector('region', 'carousel'),
52 help: getDataSelector('region', 'help'),
53 modules: getDataSelector('region', 'modules'),
54 getModuleSelector: modname => `[role="menuitem"][data-modname="${modname}"]`
55 },
56 actions: {
57 optionActions: {
58 showSummary: getDataSelector('action', 'show-option-summary'),
59 },
60 addChooser: getDataSelector('action', 'add-chooser-option'),
61 closeOption: getDataSelector('action', 'close-chooser-option-summary'),
62 hide: getDataSelector('action', 'hide')
63 },
64 elements: {
65 section: '.section',
66 sectionmodchooser: 'button.section-modchooser-link',
67 sitemenu: '.block_site_main_menu',
68 sitetopic: 'div.sitetopic',
69 },
70};