Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-18007: Drawer menu improvements for accessibility #2075

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
require(['jquery', 'bootstrap'], function($) {
$(function() {

// Fix the bad location of the dropdown menu when the trigger is close to the end of the screen.
// See: http://jira.xwiki.org/browse/XWIKI-12609
/* Fix the bad location of the dropdown menu when the trigger is close to the end of the screen.
See: http://jira.xwiki.org/browse/XWIKI-12609 */
$(document).on('shown.bs.dropdown', function (event) {
var toggle = $(event.relatedTarget);
var menu = toggle.next('.dropdown-menu');
Expand Down Expand Up @@ -51,3 +51,23 @@ require(['jquery', 'bootstrap'], function($) {
translateButton.attr('title', translateButton.attr('data-title')).popover();
});
});
require(['jquery', 'iscroll', 'drawer'], function($, IScroll) {
// Unfortunately drawer doesn't declare the dependency on iscroll and expects it to be defined as a global variable.
window.IScroll = IScroll;
$(function() {
/* Note that the 'drawer-open' and 'drawer-close' CSS classes are added before the open and close animations end
which prevents us from using them in automated tests. We need something more reliable so we listen to
'drawer.opened' and 'drawer.closed' events and add our own markers. */
$('.drawer-nav').closest('body').drawer().on('drawer.opened', function(event) {
$('#tmDrawerActivator').attr('aria-expanded', 'true');
}).on('drawer.closed', function(event) {
$('#tmDrawerActivator').attr('aria-expanded', 'false');
});
});
// Drawer can be closed by pressing the ESC key, regardless of how it was opened, whether by keyboard or clicking.
$(document).on('keydown', function (event) {
if (event.key === 'Escape') {
$('.drawer-nav').closest('body').drawer('close');
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,6 @@ if (window.Prototype && Prototype.BrowserFeatures.ElementExtensions) {
disablePrototypeJS('hide', pluginsToDisable);
});
}
require(['jquery', 'iscroll', 'drawer'], function($, IScroll) {
// Unfortunately drawer doesn't declare the dependency on iscroll and expects it to be defined as a global variable.
window.IScroll = IScroll;
$(function() {
// Note that the 'drawer-open' and 'drawer-close' CSS classes are added before the open and close animations end
// which prevents us from using them in automated tests. We need something more reliable so we listen to
// 'drawer.opened' and 'drawer.closed' events and add our own markers.
$('.drawer-nav').closest('body').drawer().on('drawer.opened', function(event) {
$('#tmDrawerActivator').attr('aria-expanded', 'true');
}).on('drawer.closed', function(event) {
$('#tmDrawerActivator').attr('aria-expanded', 'false');
});
});
});
##
## Pass useful contextual information from the server to the client using the global XWiki object.
##
Expand Down