Socket
Socket
Sign inDemoInstall

jquery-accessible-modal-window-aria

Package Overview
Dependencies
1
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jquery-accessible-modal-window-aria

This jQuery plugin will add a shiny and accessible modal window, using ARIA


Version published
Maintainers
1
Install size
1.27 MB
Created

Readme

Source

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 a dialog element at the end of your page, adds the noscroll class on the body 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).
  • Attribute data-modal-content-id: the id of (hidden) content in your page that will be put into your modal window.
  • Attribute data-modal-title: the main title of the modal window.
  • Attribute data-modal-close-text: the text of the close button in your modal window.
  • Attribute data-modal-close-title: the title attribute of the close button in your modal window.
  • Attribute data-modal-background-click="disabled": disable the possibility to click outside the modal window to close it.
  • Attribute data-modal-close-img: a path to a valid image for the close button.
  • Attribute data-modal-focus-id: when opening a modal, provides focus to the matching id (see example on “It’s free” button).
  • Attribute data-modal-aria-modal: adds attributes aria-modal="true" to the code of the modal.
  • Attribute data-modal-remove-role-dialog: removes role="dialog" of the code of the modal.
  • Attribute data-modal-use-role-alertdialog: instructs the modal to use role="alertdialog".
  • Attribute data-modal-remove-dialog-tag: instructs the modal to use div instead of using dialog 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.

Chuck Norris approved this

P.S: this plugin is in MIT license. It couldn't be done without the precious help of @ScreenFeedFr, @sophieschuermans, @johan_ramon, @goetsu and @romaingervois.

Keywords

FAQs

Last updated on 30 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc