diff --git a/bower.json b/bower.json index 48bac29..978744f 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "description": "ES2015 accessible modal window system, using ARIA (compatible IE9+ when transpiled)", "homepage": "https://van11y.net/accessible-modal/", "main": "van11y-accessible-modal-window-aria.es6.js", - "version": "1.1.0", + "version": "1.1.1", "keywords": [ "Accessibility", "ARIA", diff --git a/dist/van11y-accessible-modal-window-aria.es6.js b/dist/van11y-accessible-modal-window-aria.es6.js index 0e85e44..457b6f7 100644 --- a/dist/van11y-accessible-modal-window-aria.es6.js +++ b/dist/van11y-accessible-modal-window-aria.es6.js @@ -202,7 +202,6 @@ return `\n
\n ' + button_close + '\n
\n ' + title + '\n ' + content + '\n
\n
\n
'; + return '\n
\n ' + button_close + '\n
\n ' + title + '\n ' + content + '\n
\n
\n '; }; var closeModal = function closeModal(config) { diff --git a/dist/van11y-accessible-modal-window-aria.min.js b/dist/van11y-accessible-modal-window-aria.min.js index 98888f5..374ffa6 100644 --- a/dist/van11y-accessible-modal-window-aria.min.js +++ b/dist/van11y-accessible-modal-window-aria.min.js @@ -1,7 +1,7 @@ /** * van11y-accessible-modal-window-aria - ES2015 accessible modal window system, using ARIA (compatible IE9+ when transpiled) - * @version v1.0.7 + * @version v1.1.1 * @link https://van11y.net/accessible-modal/ * @license MIT : https://github.com/nico3333fr/van11y-accessible-modal-window-aria/blob/master/LICENSE */ -"use strict";!function(t){function e(t,e){for("string"==typeof e&&(e=document.createElement(e)),t.appendChild(e);t.firstChild!==e;)e.appendChild(t.firstChild)}function a(t){t.parentNode.removeChild(t)}var n="js-modal",o="label_modal_",l="modal",d="data-modal-background-click",i="data-modal-prefix-class",r="data-modal-text",s="data-modal-content-id",c="data-modal-title",u="data-modal-close-text",m="data-modal-close-title",b="data-modal-close-img",f="dialog",g="modal-close",v="js-modal-close",A="js-modal-close",C="data-content-back-id",p="data-focus-back",h="modal__content",k="js-modal-content",y="modal__closeimg",x="modal-close__text",I="modal-title",L="modal-title",T="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",E="js-modal-page",j="js-modal",B="js-modal-overlay",M="modal-overlay",P="Close modal",_="data-background-click",D="invisible",H="no-scroll",N="role",q="open",F="aria-labelledby",S="aria-hidden",w='aria-modal="true"',O="aria-haspopup",R="dialog",$=function(e){return t.getElementById(e)},K=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},V=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},z=function(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)},G=function(t,e){for(var a=!1,n=t.parentNode;n&&a===!1;)z(n,e)===!0?a=!0:n=n.parentNode;return a===!0?n.getAttribute("id"):""},J=function(t){var e=B,a=t.text||P,n=t.prefixClass+M,o="disabled"===t.backgroundEnabled?"disabled":"enabled";return'\n '+a+"\n "},Q=function(t){var e=j,a=t.modalPrefixClass+l,n=t.modalPrefixClass+g,o=t.modalCloseImgPath?'':'\n '+t.modalCloseText+"\n ",d=t.modalPrefixClass+h,i=t.modalPrefixClass+L,r=""!==t.modalTitle?'\n '+t.modalTitle+"\n ":"",s='\n '+o+"\n ",c=t.modalText;if(""===c&&t.modalContentId){var u=$(t.modalContentId);u&&(c='\n '+u.innerHTML+"\n \n
\n '+s+'\n
\n '+r+"\n "+c+"\n
\n
\n "},U=function(t){if(a(t.modal),a(t.overlay),""!==t.contentBackId){var e=$(t.contentBackId);e&&(e.innerHTML=t.modalContent)}if(t.modalFocusBackId){var n=$(t.modalFocusBackId);n&&n.focus()}},W=function(){return[].slice.call(t.querySelectorAll("."+n))},X=function Y(){W().forEach(function(a,n){var l=n+1,d=$(E),i=t.querySelector("body");if(a.setAttribute("id",o+l),a.setAttribute(O,R),null===d||0===d.length){var r=t.createElement("DIV");r.setAttribute("id",E),e(i,r)}}),["click","keydown"].forEach(function(e){t.body.addEventListener(e,function(a){var o=G(a.target,n);if((z(a.target,n)===!0||""!==o)&&"click"===e){var l=t.querySelector("body"),f=""!==o?$(o):a.target,g=f.hasAttribute(i)===!0?f.getAttribute(i)+"-":"",h=f.hasAttribute(r)===!0?f.getAttribute(r):"",y=f.hasAttribute(s)===!0?f.getAttribute(s):"",x=f.hasAttribute(c)===!0?f.getAttribute(c):"",I=f.hasAttribute(u)===!0?f.getAttribute(u):P,L=f.hasAttribute(m)===!0?f.getAttribute(m):I,M=f.hasAttribute(b)===!0?f.getAttribute(b):"",D=f.hasAttribute(d)===!0?f.getAttribute(d):"",N=$(E);l.insertAdjacentHTML("beforeEnd",J({text:L,backgroundEnabled:D,prefixClass:g})),l.insertAdjacentHTML("beforeEnd",Q({modalText:h,modalPrefixClass:g,backgroundEnabled:y,modalTitle:x,modalCloseText:I,modalCloseTitle:L,modalCloseImgPath:M,modalContentId:y,modalFocusBackId:f.getAttribute("id")})),N.setAttribute(S,"true"),K(l,H);var q=$(v);q.focus(),a.preventDefault()}var F=G(a.target,A);if((a.target.getAttribute("id")===v||""!==F||a.target.getAttribute("id")===B)&&"click"===e){var l=t.querySelector("body"),N=$(E),w=$(j),O=$(k)?$(k).innerHTML:"",R=$(B),W=$(v),X=W.getAttribute(p),Y=W.getAttribute(C),D=R.getAttribute(_);a.target.getAttribute("id")===B&&"disabled"===D||(U({modal:w,modalContent:O,overlay:R,modalFocusBackId:X,contentBackId:Y,backgroundEnabled:D,fromId:a.target.getAttribute("id")}),N.removeAttribute(S),V(l,H))}if($(j)&&"keydown"===e){var l=t.querySelector("body"),N=$(E),w=$(j),O=$(k)?$(k).innerHTML:"",R=$(B),W=$(v),X=W.getAttribute(p),Y=W.getAttribute(C),Z=[].slice.call(w.querySelectorAll(T));27===a.keyCode&&(U({modal:w,modalContent:O,overlay:R,modalFocusBackId:X,contentBackId:Y}),N.removeAttribute(S),V(l,H)),9===a.keyCode&&Z.indexOf(a.target)>=0&&(a.shiftKey?a.target===Z[0]&&(Z[Z.length-1].focus(),a.preventDefault()):a.target===Z[Z.length-1]&&(Z[0].focus(),a.preventDefault())),9===a.keyCode&&Z.indexOf(a.target)===-1&&(a.preventDefault(),Z[0].focus())}},!0)}),document.removeEventListener("DOMContentLoaded",Y)};document.addEventListener("DOMContentLoaded",X)}(document); \ No newline at end of file +"use strict";!function(t){function e(t,e){for("string"==typeof e&&(e=document.createElement(e)),t.appendChild(e);t.firstChild!==e;)e.appendChild(t.firstChild)}function a(t){t.parentNode.removeChild(t)}var n="js-modal",o="label_modal_",l="modal",d="data-modal-background-click",i="data-modal-prefix-class",r="data-modal-text",s="data-modal-content-id",c="data-modal-title",u="data-modal-close-text",m="data-modal-close-title",b="data-modal-close-img",f="modal-close",g="js-modal-close",v="js-modal-close",A="data-content-back-id",C="data-focus-back",p="modal__content",h="js-modal-content",k="modal__closeimg",y="modal-close__text",x="modal-title",I="modal-title",L="a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]",T="js-modal-page",E="js-modal",j="js-modal-overlay",B="modal-overlay",M="Close modal",P="data-background-click",_="invisible",D="no-scroll",H="open",N="aria-labelledby",q="aria-hidden",F='aria-modal="true"',S="aria-haspopup",w="dialog",O=function(e){return t.getElementById(e)},R=function(t,e){t.classList?t.classList.add(e):t.className+=" "+e},$=function(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},K=function(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)},V=function(t,e){for(var a=!1,n=t.parentNode;n&&a===!1;)K(n,e)===!0?a=!0:n=n.parentNode;return a===!0?n.getAttribute("id"):""},z=function(t){var e=j,a=t.text||M,n=t.prefixClass+B,o="disabled"===t.backgroundEnabled?"disabled":"enabled";return'\n '+a+"\n "},G=function(t){var e=E,a=t.modalPrefixClass+l,n=t.modalPrefixClass+f,o=t.modalCloseImgPath?'':'\n '+t.modalCloseText+"\n ",d=t.modalPrefixClass+p,i=t.modalPrefixClass+I,r=""!==t.modalTitle?'\n '+t.modalTitle+"\n ":"",s='\n '+o+"\n ",c=t.modalText;if(""===c&&t.modalContentId){var u=O(t.modalContentId);u&&(c='\n '+u.innerHTML+"\n \n
\n '+s+'\n
\n '+r+"\n "+c+"\n
\n
\n "},J=function(t){if(a(t.modal),a(t.overlay),""!==t.contentBackId){var e=O(t.contentBackId);e&&(e.innerHTML=t.modalContent)}if(t.modalFocusBackId){var n=O(t.modalFocusBackId);n&&n.focus()}},Q=function(){return[].slice.call(t.querySelectorAll("."+n))},U=function W(){Q().forEach(function(a,n){var l=n+1,d=O(T),i=t.querySelector("body");if(a.setAttribute("id",o+l),a.setAttribute(S,w),null===d||0===d.length){var r=t.createElement("DIV");r.setAttribute("id",T),e(i,r)}}),["click","keydown"].forEach(function(e){t.body.addEventListener(e,function(a){var o=V(a.target,n);if((K(a.target,n)===!0||""!==o)&&"click"===e){var l=t.querySelector("body"),f=""!==o?O(o):a.target,p=f.hasAttribute(i)===!0?f.getAttribute(i)+"-":"",k=f.hasAttribute(r)===!0?f.getAttribute(r):"",y=f.hasAttribute(s)===!0?f.getAttribute(s):"",x=f.hasAttribute(c)===!0?f.getAttribute(c):"",I=f.hasAttribute(u)===!0?f.getAttribute(u):M,B=f.hasAttribute(m)===!0?f.getAttribute(m):I,_=f.hasAttribute(b)===!0?f.getAttribute(b):"",H=f.hasAttribute(d)===!0?f.getAttribute(d):"",N=O(T);l.insertAdjacentHTML("beforeEnd",z({text:B,backgroundEnabled:H,prefixClass:p})),l.insertAdjacentHTML("beforeEnd",G({modalText:k,modalPrefixClass:p,backgroundEnabled:y,modalTitle:x,modalCloseText:I,modalCloseTitle:B,modalCloseImgPath:_,modalContentId:y,modalFocusBackId:f.getAttribute("id")})),N.setAttribute(q,"true"),R(l,D);var F=O(g);F.focus(),a.preventDefault()}var S=V(a.target,v);if((a.target.getAttribute("id")===g||""!==S||a.target.getAttribute("id")===j)&&"click"===e){var l=t.querySelector("body"),N=O(T),w=O(E),Q=O(h)?O(h).innerHTML:"",U=O(j),W=O(g),X=W.getAttribute(C),Y=W.getAttribute(A),H=U.getAttribute(P);a.target.getAttribute("id")===j&&"disabled"===H||(J({modal:w,modalContent:Q,overlay:U,modalFocusBackId:X,contentBackId:Y,backgroundEnabled:H,fromId:a.target.getAttribute("id")}),N.removeAttribute(q),$(l,D))}if(O(E)&&"keydown"===e){var l=t.querySelector("body"),N=O(T),w=O(E),Q=O(h)?O(h).innerHTML:"",U=O(j),W=O(g),X=W.getAttribute(C),Y=W.getAttribute(A),Z=[].slice.call(w.querySelectorAll(L));27===a.keyCode&&(J({modal:w,modalContent:Q,overlay:U,modalFocusBackId:X,contentBackId:Y}),N.removeAttribute(q),$(l,D)),9===a.keyCode&&Z.indexOf(a.target)>=0&&(a.shiftKey?a.target===Z[0]&&(Z[Z.length-1].focus(),a.preventDefault()):a.target===Z[Z.length-1]&&(Z[0].focus(),a.preventDefault())),9===a.keyCode&&Z.indexOf(a.target)===-1&&(a.preventDefault(),Z[0].focus())}},!0)}),document.removeEventListener("DOMContentLoaded",W)};document.addEventListener("DOMContentLoaded",U)}(document); \ No newline at end of file diff --git a/package.json b/package.json index 05b5a4f..efd4968 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "name": "van11y-accessible-modal-window-aria", "description": "ES2015 accessible modal window system, using ARIA (compatible IE9+ when transpiled)", "main": "dist/van11y-accessible-modal-window-aria.min.js", - "version": "1.1.0", + "version": "1.1.1", "keywords": [ "Accessibility", "ARIA", diff --git a/src/van11y-accessible-modal-window-aria.es6.js b/src/van11y-accessible-modal-window-aria.es6.js index 0e85e44..457b6f7 100644 --- a/src/van11y-accessible-modal-window-aria.es6.js +++ b/src/van11y-accessible-modal-window-aria.es6.js @@ -202,7 +202,6 @@ return `