Allyable accessibility icon is floating as default. Scrolling the page does not affecting the icon position and it will always be displayed.
Allyable provides ways to manipulate the icon position through its platform:
- Vertically: top, bottom, middle
- Horizontally: right, left, center
The accessibility icon can be embedded in the DOM as part of a menu, list, or anywhere else on the digital asset.
Embedding the accessibility icon in the DOM requires code adjustments. Using a layout fix in the Allyable portal allows creating customized code and the necessary adjustments.
A layout fix is a code editor which is not related to a CSS selector (specific element) or a specific page. Any code adjustments can be added for DOM manipulations. A layout fix must be assigned to a bundle for publishment to digital assets. A bundle is published only once, after assigning a layout fix to it we should work on the layout fix only.
Creating a layout fix (if does not already exist):
- Expand AllyAudit in the main menu
- Select Fixes
- Click the “+” button at the bottom right and select “layout fix”
- Pick the required domain from the domains list
- Publish the layout fix for the first time
Assigning a layout fix to a bundle:
- Expand AllyAudit in the main menu
- Select Bundles
- Click the “pencil” button at the bottom right
- Pick the required domain from the domains list
- Provide a name to the bundle
- Click the “+” button to the right of the “Fixes” title to assign a layout fix to the bundle (only published layout fixes will be listed)
- Select all layout fixes if you have only one or pick the one that you’ve created
- Publish the bundle
In some cases, we want different positions for different devices like desktops, mobiles, etc.
To set a different location to a specific device, code adjustments need to be created.
- The default settings should be adjusted for desktops as described above.
- For mobiles or other devices, we will add CSS styling and code to override the default adjustments.
Code example: Adjust the location of the accessibility icon and menu to the bottom in mobile devices (width<980)
this.event(function (content, $) {
if ($( window ).width() < 980) {
$(`.${MENU_CLASS_PREFIX}-accessibility-panel`).removeClass('top').addClass('bottom').css('bottom', '15px');
$(`#${AWEB_PREFIX}-open-panel`).removeClass('top').addClass('bottom').css('bottom', '15px');
}
}, EngineState.Ready);
@media only screen and (max-width: 980px) {
body #mk-aweb-accessibility-panel-wrapper .mk-aweb-menu-open-accessibility-panel.top {
top: 207px!important;
}
body #mk-aweb-accessibility-panel-wrapper .mk-aweb-menu-accessibility-panel.top {
top: 246px!important;
}
}
When the "Tab" button is used for navigating, the “tabindex” attribute specifies the tab order of an element. The default tab order provided by the DOM moves the focus from top to bottom on native focusable elements (input, select, textarea, anchor, button, area). To add our custom icon to the navigation order tabindex=”0” attribute should be added to the element.
Code example: adding tabindex=0 attribute to an element using jQuery
If the custom icon is not located first in the navigation order, we would want assistive technologies to move the focus first to the custom icon and then to other elements. Providing a tabindex greater than “0” to elements should be avoided according to accessibility guidelines but to set our custom icon first in navigation order will assist users with disabilities and assistive technologies to find the accessibility features easily.
Code example: adding tabindex>0 attribute to an element using jQuery
Customized elements need to be operated using a mouse and a keyboard for people who use assistive technology. Links support keyboard functionality by default.
For custom elements to be part of the keyboard navigation order, they must have a tabindex attribute with a positive value. To activate it by keyboard, Click and Keyup events must be implemented.
To remove focusable elements from keyboard navigation tabindex=”-1” attribute should be provided.
$('.myObjectClass').on('keyup', function (e) {
if (e.which === 13) {
$(this).trigger('click');
}
});
Code example: adding a keyup keyboard event to activate the click event of an element using jQuery
$('.myObjectClass').on('keyup click', function (e) {
if (e.which === 13 || e.type === 'click') {
// do something
}
});
- Create a custom element like a link or button for activating the AllyToolbar menu
- Make the custom element accessible by providing all the necessary attributes and functionality.
- Hide the default icon by checking “Menu hidden”. Main menu – Administrator – Domains – Edit the domain – Menu customization tab – Menu hidden
- Create a keyup/click events for opening AllyToolbar from within Allyable layout fix
Code example: creating a function to control clicking a custom accessibility icon with the relevant ARIA attributes.
function changeIcon($: JQueryStatic): void {
$('.customerCustomIcon’).off(‘click keyup tap’).attr('tabindex', '1').attr('aria-label', 'Open accessibility menu. click ESC to close').on('click keyup tap', function (e) {
if (e.which == 13 || e.type == 'click') {
$(`#${AWEB_PREFIX}-open-panel`).trigger(‘click’);
e.preventDefault();
e.stopPropagation();
}
});
}
- Control AllyToolbar from within the customer code
Code example: function we want to call that require window.aweb object to be ready
funtion openAwebMenu() {
window.aweb.addExtension(8 /*EngineState.Localized*/, function ($ /* jQuery */) {
//MENU OPEN CODE GOES HERE, after localization is finished
}
}
Code example: Wrapper for the above function that ensures window.aweb object is ready before we access itif (window.aweb === undefined) {/* if window.aweb is not defined, we add listener that will listen to aweb initialization event */window.document.addEventListener('awebInitialized', function () {/* AWeb is initialized here and now window.aweb exist, so we ready to call function that utilize it */openAwebMenu();},{once: true //This settings will destroy listener After AWEB is ready. There is no need of it afterwards cause window.aweb is already defined and can be accessed directly});} else {/* if window.aweb is already defined, we can call required function directly */openAwebMenu();}
Though it is not recommended, the accessibility layer can be activated manually by end users. Accessibility assists all users, with or without disabilities and applying the accessibility layer when the page loads makes the site accessible and easier to navigate to all.
To run the accessibility layer by an element click:
<html>
<body>
<script>
var AWEB_BOOT = ‘none’;
</script>
<script src="https://portal.allyable.com/aweb?license=<LICENSE_ID>" async referrerpolicy="no-referrer-when-downgrade" referrerPolicy="no-referrer-when-downgrade"></script>
</body>
</html>
window.aweb.run().then(
function success()
{
window.aweb.openMenu().then(
function success () {
// success code here
},
function failure() {
// failed code here
});
},function failure() {
// failed code here
});