Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nico3333fr/jquery-accessible-modal-window-aria
jQuery simple and accessible modal window, using ARIA
https://github.com/nico3333fr/jquery-accessible-modal-window-aria
a11y accessibility aria jquery modal
Last synced: 20 days ago
JSON representation
jQuery simple and accessible modal window, using ARIA
- Host: GitHub
- URL: https://github.com/nico3333fr/jquery-accessible-modal-window-aria
- Owner: nico3333fr
- License: mit
- Created: 2015-02-12T08:03:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-11-30T09:23:33.000Z (almost 4 years ago)
- Last Synced: 2024-07-21T03:10:34.697Z (4 months ago)
- Topics: a11y, accessibility, aria, jquery, modal
- Language: HTML
- Size: 60.5 KB
- Stars: 61
- Watchers: 5
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jQuery Simple and Accessible Modal Window
This jQuery plugin provides you a shiny and accessible modal window, using ARIA.
A presentation page and demo is here: https://a11y.nicolas-hoffmann.net/modal/ (with styles, etc.)
## How it works
Basically, it wraps all the page into a
div id="js-modal-page"
, and when you activate one modal, the scripts inserts adialog
element at the end of your page, adds thenoscroll
class on thebody
element (to remove scroll with CSS if needed), puts the focus into it and traps focus in the modal window. When you exit it, the focus is given back to the element that opened it.For mouse users, they can click outside the modal window to close it. For keyboard users, you can strike Esc to close it.
If you never activate a modal window, it won’t be anywhere in the code.
## Options and attributes
Simply put class="js-modal" on a button or a link to activate the script.
- Attribute
data-modal-text
: the text of your modal window (will be put into a p tag).
- Attributedata-modal-content-id
: the id of (hidden) content in your page that will be put into your modal window.
- Attributedata-modal-title
: the main title of the modal window.
- Attributedata-modal-close-text
: the text of the close button in your modal window.
- Attributedata-modal-close-title
: the title attribute of the close button in your modal window.
- Attributedata-modal-background-click="disabled"
: disable the possibility to click outside the modal window to close it.
- Attributedata-modal-close-img
: a path to a valid image for the close button.
- Attributedata-modal-focus-id
: when opening a modal, provides focus to the matchingid
(see [example on “It’s free” button](https://a11y.nicolas-hoffmann.net/modal/)).
- Attributedata-modal-aria-modal
: adds attributesaria-modal="true"
to the code of the modal.
- Attributedata-modal-remove-role-dialog
: removesrole="dialog"
of the code of the modal.
- Attributedata-modal-use-role-alertdialog
: instructs the modal to userole="alertdialog"
.
- Attributedata-modal-remove-dialog-tag
: instructs the modal to usediv
instead of usingdialog
tag.If you need to close it, add `class="js-modal-close"` on an element in the modal content, it will trigger a click on close button.
Enjoy.
P.S: this plugin is in [MIT license](https://github.com/nico3333fr/jquery-accessible-modal-window-aria/blob/master/LICENSE). It couldn't be done without the precious help of @ScreenFeedFr, @sophieschuermans, @johan_ramon, @goetsu and @romaingervois.