Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 46... Línea 46...
46
     *
46
     *
47
     * data-show-active-item - Add to the .dropdown-menu element to enable default
47
     * data-show-active-item - Add to the .dropdown-menu element to enable default
48
     *                         functionality.
48
     *                         functionality.
49
     * data-skip-active-class - Add to the .dropdown-menu to prevent this code from
49
     * data-skip-active-class - Add to the .dropdown-menu to prevent this code from
50
     *                          adding the active class to the dropdown items
50
     *                          adding the active class to the dropdown items
51
     * data-active-item-text - Add to an element within the data-toggle="dropdown" element
51
     * data-active-item-text - Add to an element within the data-bs-toggle="dropdown" element
52
     *                         to use it as the active option text placeholder otherwise the
52
     *                         to use it as the active option text placeholder otherwise the
53
     *                         data-toggle="dropdown" element itself will be used.
53
     *                         data-bs-toggle="dropdown" element itself will be used.
54
     * data-active-item-button-aria-label-components - String components to set the aria
54
     * data-active-item-button-aria-label-components - String components to set the aria
55
     *                         lable on the dropdown button. The string will be given the
55
     *                         lable on the dropdown button. The string will be given the
56
     *                         active item text.
56
     *                         active item text.
57
     */
57
     */
58
    var initActionOptionDropdownHandler = function() {
58
    var initActionOptionDropdownHandler = function() {
59
        var body = $('body');
59
        var body = $('body');
Línea -... Línea 60...
-
 
60
 
-
 
61
        // Ensure on load that the "current" item is always marked to ensure we make space for active item indicator.
-
 
62
        body.find('.dropdown-menu').each(function() {
-
 
63
            $(this).find('[aria-current="true"]').addClass('dropdown-item-active');
-
 
64
        });
60
 
65
 
61
        CustomEvents.define(body, [CustomEvents.events.activate]);
66
        CustomEvents.define(body, [CustomEvents.events.activate]);
62
        body.on(CustomEvents.events.activate, '[data-show-active-item]', function(e) {
67
        body.on(CustomEvents.events.activate, '[data-show-active-item]', function(e) {
63
            // The dropdown item that the user clicked on.
68
            // The dropdown item that the user clicked on.
64
            var option = $(e.target).closest('.dropdown-item');
69
            var option = $(e.target).closest('.dropdown-item');
Línea 75... Línea 80...
75
                return;
80
                return;
76
            }
81
            }
Línea 77... Línea 82...
77
 
82
 
78
            // Clear the active class from all other options.
83
            // Clear the active class from all other options.
79
            var dropdownItems = menuContainer.find('.dropdown-item');
84
            var dropdownItems = menuContainer.find('.dropdown-item');
80
            dropdownItems.removeClass('active');
85
            dropdownItems.removeClass(['active', 'dropdown-item-active']);
Línea 81... Línea 86...
81
            dropdownItems.removeAttr('aria-current');
86
            dropdownItems.removeAttr('aria-current');
82
 
87
 
83
            if (!menuContainer.attr('data-skip-active-class')) {
88
            if (!menuContainer.attr('data-skip-active-class')) {
84
                // Make this option active unless configured to ignore it.
89
                // Make this option active unless configured to ignore it.
85
                // Some code, for example the Bootstrap tabs, may want to handle
90
                // Some code, for example the Bootstrap tabs, may want to handle
86
                // adding the active class itself.
91
                // adding the active class itself.
-
 
92
                option.addClass('active');
Línea 87... Línea 93...
87
                option.addClass('active');
93
            }
88
            }
94
            option.addClass('dropdown-item-active');
Línea 89... Línea 95...
89
 
95
 
90
            // Update aria attribute for active item.
96
            // Update aria attribute for active item.
91
            option.attr('aria-current', true);
97
            option.attr('aria-current', true);
Línea 92... Línea 98...
92
 
98
 
93
            var activeOptionText = option.text();
99
            var activeOptionText = option.text();
94
            var dropdownToggle = menuContainer.parent().find('[data-toggle="dropdown"]');
100
            var dropdownToggle = menuContainer.parent().find('[data-bs-toggle="dropdown"]');