Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 19... Línea 19...
19
 * @module      core/local/dropdown/dialog
19
 * @module      core/local/dropdown/dialog
20
 * @copyright   2023 Ferran Recio <ferran@moodle.com>
20
 * @copyright   2023 Ferran Recio <ferran@moodle.com>
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
22
 */
Línea 23... Línea -...
23
 
-
 
24
// The jQuery module is only used for interacting with Bootstrap 4. It can be removed when MDL-71979 is integrated.
23
 
25
import jQuery from 'jquery';
24
import Dropdown from 'theme_boost/bootstrap/dropdown';
26
import {
25
import {
27
    firstFocusableElement,
26
    firstFocusableElement,
28
    lastFocusableElement,
27
    lastFocusableElement,
29
    previousFocusableElement,
28
    previousFocusableElement,
30
    nextFocusableElement,
29
    nextFocusableElement,
31
} from 'core/pagehelpers';
30
} from 'core/pagehelpers';
-
 
31
import Pending from 'core/pending';
Línea 32... Línea 32...
32
import Pending from 'core/pending';
32
import EventHandler from 'theme_boost/bootstrap/dom/event-handler';
33
 
33
 
34
const Selectors = {
34
const Selectors = {
35
    dropdownButton: '[data-for="dropdowndialog_button"]',
35
    dropdownButton: '[data-for="dropdowndialog_button"]',
Línea 59... Línea 59...
59
    init() {
59
    init() {
60
        if (this.element.dataset.dropdownDialogInitialized) {
60
        if (this.element.dataset.dropdownDialogInitialized) {
61
            return;
61
            return;
62
        }
62
        }
Línea -... Línea 63...
-
 
63
 
-
 
64
        // Use the Bootstrap key handler for the Dropdown button key handler.
63
 
65
        // This will avoid Boostrap Dropdown handler to prevent the propagation to the dialog.
-
 
66
        // Menu Item events.
64
        // Menu Item events.
67
        const dialogButtonSelector = `#${this.element.id} ${Selectors.dropdownButton}`;
65
        this.button.addEventListener('keydown', this._buttonKeyHandler.bind(this));
68
        EventHandler.on(document, 'keydown', dialogButtonSelector, this._buttonKeyHandler.bind(this));
-
 
69
        // Subpanel content events.
66
        // Subpanel content events.
70
        const dialogSelector = `#${this.element.id} ${Selectors.dropdownDialog}`;
Línea 67... Línea 71...
67
        this.panel.addEventListener('keydown', this._contentKeyHandler.bind(this));
71
        EventHandler.on(document, 'keydown', dialogSelector, this._contentKeyHandler.bind(this));
68
 
72
 
Línea 69... Línea 73...
69
        this.element.dataset.dropdownDialogInitialized = true;
73
        this.element.dataset.dropdownDialogInitialized = true;
Línea 143... Línea 147...
143
     */
147
     */
144
    setVisible(visible) {
148
    setVisible(visible) {
145
        if (visible === this.isVisible()) {
149
        if (visible === this.isVisible()) {
146
            return;
150
            return;
147
        }
151
        }
148
        // All jQuery in this code can be replaced when MDL-71979 is integrated.
-
 
149
        jQuery(this.button).dropdown('toggle');
152
        Dropdown.getOrCreateInstance(this.button).toggle();
150
    }
153
    }
Línea 151... Línea 154...
151
 
154
 
152
    /**
155
    /**
153
     * Get the visibility of a subpanel.
156
     * Get the visibility of a subpanel.