weekly release 3.9dev
[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'),
c58c23d6
MM
54 favouriteTabNav: getDataSelector('region', 'favourite-tab-nav'),
55 recommendedTabNav: getDataSelector('region', 'recommended-tab-nav'),
56 defaultTabNav: getDataSelector('region', 'default-tab-nav'),
57 favouriteTab: getDataSelector('region', 'favourites'),
58 recommendedTab: getDataSelector('region', 'recommended'),
59 defaultTab: getDataSelector('region', 'default'),
05b27f21
MM
60 getModuleSelector: modname => `[role="menuitem"][data-modname="${modname}"]`
61 },
62 actions: {
63 optionActions: {
64 showSummary: getDataSelector('action', 'show-option-summary'),
6e1a4477 65 manageFavourite: getDataSelector('action', 'manage-module-favourite'),
05b27f21
MM
66 },
67 addChooser: getDataSelector('action', 'add-chooser-option'),
68 closeOption: getDataSelector('action', 'close-chooser-option-summary'),
69 hide: getDataSelector('action', 'hide')
70 },
6e1a4477
MM
71 render: {
72 favourites: getDataSelector('render', 'favourites-area'),
73 },
05b27f21
MM
74 elements: {
75 section: '.section',
76 sectionmodchooser: 'button.section-modchooser-link',
77 sitemenu: '.block_site_main_menu',
78 sitetopic: 'div.sitetopic',
79 },
80};