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'),
f152b71d 39 getSectionChooserOptions: containerid => `${containerid} ${getDataSelector('region', 'chooser-options-container')}`,
05b27f21
MM
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'),
486abbcb 48 header: getDataSelector('region', 'summary-header'),
05b27f21
MM
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'),
f152b71d
MG
60 getModuleSelector: modname => `[role="menuitem"][data-modname="${modname}"]`,
61 searchResults: getDataSelector('region', 'search-results-container'),
62 searchResultItems: getDataSelector('region', 'search-result-items-container'),
05b27f21
MM
63 },
64 actions: {
65 optionActions: {
66 showSummary: getDataSelector('action', 'show-option-summary'),
6e1a4477 67 manageFavourite: getDataSelector('action', 'manage-module-favourite'),
05b27f21
MM
68 },
69 addChooser: getDataSelector('action', 'add-chooser-option'),
70 closeOption: getDataSelector('action', 'close-chooser-option-summary'),
f152b71d
MG
71 hide: getDataSelector('action', 'hide'),
72 search: getDataSelector('action', 'search'),
73 clearSearch: getDataSelector('action', 'clearsearch'),
05b27f21 74 },
6e1a4477
MM
75 render: {
76 favourites: getDataSelector('render', 'favourites-area'),
77 },
05b27f21
MM
78 elements: {
79 section: '.section',
80 sectionmodchooser: 'button.section-modchooser-link',
81 sitemenu: '.block_site_main_menu',
82 sitetopic: 'div.sitetopic',
f152b71d
MG
83 tab: 'a[data-toggle="tab"]',
84 activetab: 'a[data-toggle="tab"][aria-selected="true"]',
9f1bfca2 85 visibletabs: 'a[data-toggle="tab"]:not(.d-none)',
95dceedd
PD
86 searchicon: '.input-group-append .search-icon',
87 clearsearch: '.input-group-append .clear'
05b27f21
MM
88 },
89};