| 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 |  * Define all of the selectors we will be using on the grading interface.
 | 
        
           |  |  | 18 |  *
 | 
        
           |  |  | 19 |  * @module     core_course/local/activitychooser/selectors
 | 
        
           |  |  | 20 |  * @copyright  2019 Mathew May <mathew.solutions>
 | 
        
           |  |  | 21 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 22 |  */
 | 
        
           |  |  | 23 |   | 
        
           |  |  | 24 | /**
 | 
        
           |  |  | 25 |  * A small helper function to build queryable data selectors.
 | 
        
           |  |  | 26 |  * @method getDataSelector
 | 
        
           |  |  | 27 |  * @param {String} name
 | 
        
           |  |  | 28 |  * @param {String} value
 | 
        
           |  |  | 29 |  * @return {string}
 | 
        
           |  |  | 30 |  */
 | 
        
           |  |  | 31 | const getDataSelector = (name, value) => {
 | 
        
           |  |  | 32 |     return `[data-${name}="${value}"]`;
 | 
        
           |  |  | 33 | };
 | 
        
           |  |  | 34 |   | 
        
           |  |  | 35 | export default {
 | 
        
           |  |  | 36 |     regions: {
 | 
        
           |  |  | 37 |         chooser: getDataSelector('region', 'chooser-container'),
 | 
        
           |  |  | 38 |         getSectionChooserOptions: containerid => `${containerid} ${getDataSelector('region', 'chooser-options-container')}`,
 | 
        
           |  |  | 39 |         chooserOption: {
 | 
        
           |  |  | 40 |             container: getDataSelector('region', 'chooser-option-container'),
 | 
        
           |  |  | 41 |             actions: getDataSelector('region', 'chooser-option-actions-container'),
 | 
        
           |  |  | 42 |             info: getDataSelector('region', 'chooser-option-info-container'),
 | 
        
           |  |  | 43 |         },
 | 
        
           |  |  | 44 |         chooserSummary: {
 | 
        
           |  |  | 45 |             container: getDataSelector('region', 'chooser-option-summary-container'),
 | 
        
           |  |  | 46 |             content: getDataSelector('region', 'chooser-option-summary-content-container'),
 | 
        
           |  |  | 47 |             header: getDataSelector('region', 'summary-header'),
 | 
        
           |  |  | 48 |             actions: getDataSelector('region', 'chooser-option-summary-actions-container'),
 | 
        
           |  |  | 49 |         },
 | 
        
           |  |  | 50 |         carousel: getDataSelector('region', 'carousel'),
 | 
        
           |  |  | 51 |         help: getDataSelector('region', 'help'),
 | 
        
           |  |  | 52 |         modules: getDataSelector('region', 'modules'),
 | 
        
           |  |  | 53 |         favouriteTabNav: getDataSelector('region', 'favourite-tab-nav'),
 | 
        
           |  |  | 54 |         defaultTabNav: getDataSelector('region', 'default-tab-nav'),
 | 
        
           |  |  | 55 |         activityTabNav: getDataSelector('region', 'activity-tab-nav'),
 | 
        
           |  |  | 56 |         favouriteTab: getDataSelector('region', 'favourites'),
 | 
        
           |  |  | 57 |         recommendedTab: getDataSelector('region', 'recommended'),
 | 
        
           |  |  | 58 |         defaultTab: getDataSelector('region', 'default'),
 | 
        
           |  |  | 59 |         activityTab: getDataSelector('region', 'activity'),
 | 
        
           |  |  | 60 |         resourceTab: getDataSelector('region', 'resources'),
 | 
        
           |  |  | 61 |         getModuleSelector: modname => `[role="menuitem"][data-modname="${modname}"]`,
 | 
        
           |  |  | 62 |         searchResults: getDataSelector('region', 'search-results-container'),
 | 
        
           |  |  | 63 |         searchResultItems: getDataSelector('region', 'search-result-items-container'),
 | 
        
           |  |  | 64 |     },
 | 
        
           |  |  | 65 |     actions: {
 | 
        
           |  |  | 66 |         optionActions: {
 | 
        
           |  |  | 67 |             showSummary: getDataSelector('action', 'show-option-summary'),
 | 
        
           |  |  | 68 |             manageFavourite: getDataSelector('action', 'manage-module-favourite'),
 | 
        
           |  |  | 69 |         },
 | 
        
           |  |  | 70 |         addChooser: getDataSelector('action', 'add-chooser-option'),
 | 
        
           |  |  | 71 |         closeOption: getDataSelector('action', 'close-chooser-option-summary'),
 | 
        
           |  |  | 72 |         hide: getDataSelector('action', 'hide'),
 | 
        
           |  |  | 73 |         search: getDataSelector('action', 'search'),
 | 
        
           |  |  | 74 |         clearSearch: getDataSelector('action', 'clearsearch'),
 | 
        
           |  |  | 75 |     },
 | 
        
           |  |  | 76 |     render: {
 | 
        
           |  |  | 77 |         favourites: getDataSelector('render', 'favourites-area'),
 | 
        
           |  |  | 78 |     },
 | 
        
           |  |  | 79 |     elements: {
 | 
        
           |  |  | 80 |         section: '.section',
 | 
        
           |  |  | 81 |         sectionmodchooser: 'button.section-modchooser-link',
 | 
        
           |  |  | 82 |         sitemenu: '.block_site_main_menu',
 | 
        
           |  |  | 83 |         sitetopic: 'div.sitetopic',
 | 
        
           | 1441 | ariadna | 84 |         tab: 'a[data-bs-toggle="tab"]',
 | 
        
           |  |  | 85 |         activetab: 'a[data-bs-toggle="tab"][aria-selected="true"]',
 | 
        
           |  |  | 86 |         visibletabs: 'a[data-bs-toggle="tab"]:not(.d-none)'
 | 
        
           | 1 | efrain | 87 |     },
 | 
        
           |  |  | 88 | };
 |