a11y-dialog
Advanced tools
Comparing version 2.5.4 to 2.5.5
@@ -111,2 +111,4 @@ (function (global) { | ||
function show () { | ||
if (that.shown) return; | ||
that.shown = true; | ||
@@ -123,2 +125,4 @@ node.removeAttribute('aria-hidden'); | ||
function hide () { | ||
if (!that.shown) return; | ||
that.shown = false; | ||
@@ -125,0 +129,0 @@ node.setAttribute('aria-hidden', 'true'); |
@@ -1,1 +0,1 @@ | ||
!function(e){"use strict";function t(t,n,i){function o(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}o.prototype=e.Event.prototype;var a;a=e.CustomEvent&&"function"==typeof e.CustomEvent?new e.CustomEvent(n,{detail:i}):new o(n,{bubbles:!1,cancelable:!1,detail:i}),a&&t.dispatchEvent(a)}function n(e){var t=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];return i(t.join(","),e).filter(function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)})}function i(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function o(e,t){var i=n(e),o=i.indexOf(document.activeElement);t.shiftKey&&0===o?(i[i.length-1].focus(),t.preventDefault()):t.shiftKey||o!==i.length-1||(i[0].focus(),t.preventDefault())}function a(e){var t=n(e);t.length&&t[0].focus()}var d,r=function(e,n){function r(t){l.shown&&27===t.which&&(t.preventDefault(),s()),l.shown&&9===t.which&&o(e,t)}function c(t){l.shown&&!e.contains(t.target)&&a(e)}function u(){l.shown=!0,e.removeAttribute("aria-hidden"),n.setAttribute("aria-hidden","true"),d=document.activeElement,a(e),document.body.addEventListener("focus",c,!0),document.addEventListener("keydown",r),t(e,"dialog:show",this)}function s(){l.shown=!1,e.setAttribute("aria-hidden","true"),n.removeAttribute("aria-hidden"),d&&d.focus(),document.body.removeEventListener("focus",c,!0),document.removeEventListener("keydown",r),t(e,"dialog:hide",this)}function f(){s(),h.forEach(function(e){e.removeEventListener("click",u)}),v.forEach(function(e){e.removeEventListener("click",s)})}n=n||document.querySelector("#main");var l=this,h=i('[data-a11y-dialog-show="'+e.id+'"]'),v=i("[data-a11y-dialog-hide]",e).concat(i('[data-a11y-dialog-hide="'+e.id+'"]'));e.hasAttribute("aria-hidden")&&(this.shown=!JSON.parse(e.getAttribute("aria-hidden"))),this.show=u,this.hide=s,this.destroy=f,h.forEach(function(e){e.addEventListener("click",u)}),v.forEach(function(e){e.addEventListener("click",s)})};"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=r:"function"==typeof define&&define.amd?define("A11yDialog",[],function(){return r}):"object"==typeof e&&(e.A11yDialog=r)}(this); | ||
!function(e){"use strict";function t(e,t,n){function i(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}i.prototype=window.Event.prototype;var o;o=window.CustomEvent&&"function"==typeof window.CustomEvent?new window.CustomEvent(t,{detail:n}):new i(t,{bubbles:!1,cancelable:!1,detail:n}),o&&e.dispatchEvent(o)}function n(e){var t=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'];return i(t.join(","),e).filter(function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)})}function i(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function o(e,t){var i=n(e),o=i.indexOf(document.activeElement);t.shiftKey&&0===o?(i[i.length-1].focus(),t.preventDefault()):t.shiftKey||o!==i.length-1||(i[0].focus(),t.preventDefault())}function d(e){var t=n(e);t.length&&t[0].focus()}var a,r=function(e,n){function r(t){l.shown&&27===t.which&&(t.preventDefault(),s()),l.shown&&9===t.which&&o(e,t)}function c(t){l.shown&&!e.contains(t.target)&&d(e)}function u(){l.shown||(l.shown=!0,e.removeAttribute("aria-hidden"),n.setAttribute("aria-hidden","true"),a=document.activeElement,d(e),document.body.addEventListener("focus",c,!0),document.addEventListener("keydown",r),t(e,"dialog:show",this))}function s(){l.shown&&(l.shown=!1,e.setAttribute("aria-hidden","true"),n.removeAttribute("aria-hidden"),a&&a.focus(),document.body.removeEventListener("focus",c,!0),document.removeEventListener("keydown",r),t(e,"dialog:hide",this))}function f(){s(),h.forEach(function(e){e.removeEventListener("click",u)}),v.forEach(function(e){e.removeEventListener("click",s)})}n=n||document.querySelector("#main");var l=this,h=i('[data-a11y-dialog-show="'+e.id+'"]'),v=i("[data-a11y-dialog-hide]",e).concat(i('[data-a11y-dialog-hide="'+e.id+'"]'));e.hasAttribute("aria-hidden")&&(this.shown=!JSON.parse(e.getAttribute("aria-hidden"))),this.show=u,this.hide=s,this.destroy=f,h.forEach(function(e){e.addEventListener("click",u)}),v.forEach(function(e){e.addEventListener("click",s)})};"undefined"!=typeof module&&"undefined"!=typeof module.exports?module.exports=r:"function"==typeof define&&define.amd?define("A11yDialog",[],function(){return r}):"object"==typeof e&&(e.A11yDialog=r)}(this); |
{ | ||
"name": "a11y-dialog", | ||
"version": "2.5.4", | ||
"version": "2.5.5", | ||
"description": "A tiny script to make dialog windows accessible to assistive technology users.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/edenspiekermann/a11y-dialog", |
@@ -15,3 +15,3 @@ # A11y Dialog | ||
- JS API (`dialog.show()`, `dialog.hide()`, `dialog.destroy()`, `dialog.shown`); | ||
- DOM events (`dialog:open`, `dialog:close`); | ||
- DOM events (`dialog:show`, `dialog:hide`); | ||
- No `display` manipulation in JS, the hiding mechanism is entirely up to the CSS layer (using `[aria-hidden]` selectors); | ||
@@ -18,0 +18,0 @@ - Full test coverage with [CasperJS](http://casperjs.org) and [CodeShip](https://codeship.com); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16987
129