зеркало из
1
0
Форкнуть 0
A modal dialog that's opened with
.
Перейти к файлу
Mu-An 慕安 0612fe4af0
Merge pull request #29 from notriddle/patch-1
Fix the escape key when running under IE11
2019-03-21 15:04:20 -04:00
test inline test eslint config in root eslint config 2019-02-25 12:31:32 +00:00
.babelrc use babel-preset-github 2019-02-25 12:26:51 +00:00
.eslintrc.json inline test eslint config in root eslint config 2019-02-25 12:31:32 +00:00
.flowconfig Set up Flow 2018-08-09 20:20:03 -04:00
.gitignore Treat dist as build output directory 2018-04-03 12:28:22 -06:00
.travis.yml Fix Travis headless Chrome runner 2018-04-04 17:54:52 -06:00
LICENSE Add example usage 2018-03-29 15:26:32 -06:00
README.md drop ie11 support 2019-02-25 12:31:48 +00:00
index.css Add max width set to 90vw 2018-07-20 10:29:11 -07:00
index.html Pull built file for pages demo and comment out local built file 2018-08-17 08:47:06 -04:00
index.js Fix the escape key when running under IE11 2019-03-21 01:40:39 -07:00
index.js.flow Set up Flow 2018-08-09 20:20:03 -04:00
package-lock.json 2.0.0 2019-02-25 17:42:28 +00:00
package.json 2.0.0 2019-02-25 17:42:28 +00:00
prettier.config.js Initial commit 2017-11-24 15:47:45 +08:00

README.md

<details-dialog> element

A modal dialog that's opened with a <details> button.

Installation

$ npm install --save details-dialog-element

Usage

import 'details-dialog-element'
<details>
  <summary>Open dialog</summary>
  <details-dialog>
    Modal content
    <button type="button" data-close-dialog>Close</button>
  </details-dialog>
</details>

Events

details-dialog:will-close

A details-dialog:will-close event is fired when a request to close the dialog is made either by pressing escape, clicking a data-close-dialog element, clicking on the <summary> element, or when .toggle(false) is called on an open dialog.

This event can be cancelled to keep the dialog open.

document.addEventListener('details-dialog:will-close', function(event) {
  if (!confirm('Are you sure?')) {
    event.preventDefault()
  }
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.