course/amd/src/local/activitychooser/selectors.js

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