TP_JO2024/home/dist/component/modal/modal.nomodule.min.js

4 lines
9.1 KiB
JavaScript
Raw Permalink Normal View History

2024-03-27 17:19:37 +01:00
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
!function(){"use strict";var t=window.dsfr,e={MODAL:t.internals.ns.selector("modal"),SCROLL_DIVIDER:t.internals.ns.selector("scroll-divider"),BODY:t.internals.ns.selector("modal__body"),TITLE:t.internals.ns.selector("modal__title")},i=function(e){function i(){e.call(this,t.core.DisclosureType.OPENED)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"ModalButton"},Object.defineProperties(i,n),i}(t.core.DisclosureButton),n={CONCEALING_BACKDROP:t.internals.ns.attr("concealing-backdrop")},o=function(o){function s(){o.call(this,t.core.DisclosureType.OPENED,e.MODAL,i,"ModalsGroup"),this._isActive=!1,this.scrolling=this.resize.bind(this,!1),this.resizing=this.resize.bind(this,!0)}o&&(s.__proto__=o),s.prototype=Object.create(o&&o.prototype),s.prototype.constructor=s;var r={body:{configurable:!0},isDialog:{configurable:!0}},a={instanceClassName:{configurable:!0}};return a.instanceClassName.get=function(){return"Modal"},s.prototype.init=function(){o.prototype.init.call(this),this._isDialog="DIALOG"===this.node.tagName,this.isScrolling=!1,this.listenClick(),this.addEmission(t.core.RootEmission.KEYDOWN,this._keydown.bind(this))},s.prototype._keydown=function(e){if(e===t.core.KeyCodes.ESCAPE)this._escape()},s.prototype._escape=function(){switch(document.activeElement?document.activeElement.tagName:void 0){case"INPUT":case"LABEL":case"TEXTAREA":case"SELECT":case"AUDIO":case"VIDEO":break;default:this.isDisclosed&&(this.conceal(),this.focus())}},s.prototype.retrieved=function(){this._ensureAccessibleName()},r.body.get=function(){return this.element.getDescendantInstances("ModalBody","Modal")[0]},s.prototype.handleClick=function(t){t.target===this.node&&"false"!==this.getAttribute(n.CONCEALING_BACKDROP)&&this.conceal()},s.prototype.disclose=function(t){return!!o.prototype.disclose.call(this,t)&&(this.body&&this.body.activate(),this.isScrollLocked=!0,this.setAttribute("aria-modal","true"),this.setAttribute("open","true"),this._isDialog||this.activateModal(),!0)},s.prototype.conceal=function(t,e){return!!o.prototype.conceal.call(this,t,e)&&(this.isScrollLocked=!1,this.removeAttribute("aria-modal"),this.removeAttribute("open"),this.body&&this.body.deactivate(),this._isDialog||this.deactivateModal(),!0)},r.isDialog.get=function(){return this._isDialog},r.isDialog.set=function(t){this._isDialog=t},s.prototype.activateModal=function(){this._isActive||(this._isActive=!0,this._hasDialogRole="dialog"===this.getAttribute("role"),this._hasDialogRole||this.setAttribute("role","dialog"))},s.prototype.deactivateModal=function(){this._isActive&&(this._isActive=!1,this._hasDialogRole||this.removeAttribute("role"))},s.prototype._setAccessibleName=function(t,e){var i=this.retrieveNodeId(t,e);this.warn("add reference to "+e+" for accessible name (aria-labelledby)"),this.setAttribute("aria-labelledby",i)},s.prototype._ensureAccessibleName=function(){if(!this.hasAttribute("aria-labelledby")&&!this.hasAttribute("aria-label")){this.warn("missing accessible name");var t=this.node.querySelector(e.TITLE),i=this.primaryButtons[0];switch(!0){case null!==t:this._setAccessibleName(t,"title");break;case void 0!==i:this.warn("missing required title, fallback to primary button"),this._setAccessibleName(i,"primary")}}},Object.defineProperties(s.prototype,r),Object.defineProperties(s,a),s}(t.core.Disclosure),s=['[tabindex="0"]',"a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details","iframe"].join(),r=['[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'].join(),a=function(t,e){if(!(t instanceof Element))return!1;var i=window.getComputedStyle(t);if(!i)return!1;if("hidden"===i.visibility)return!1;for(void 0===e&&(e=t);e.contains(t);){if("none"===i.display)return!1;t=t.parentElement}return!0},l=function(t,e){this.element=null,this.activeElement=null,this.onTrap=t,
//# sourceMappingURL=modal.nomodule.min.js.map