File "tec-a11y-dialog.min.js"
Full Path: /home/londdqdw/public_html/06/wp-content/plugins/the-events-calendar/common/src/resources/js/tec-a11y-dialog.min.js
File size: 8.67 KB
MIME-type: text/plain
Charset: utf-8
/**
* This JS file was auto-generated via Terser.
*
* Contributors should avoid editing this file, but instead edit the associated
* non minified file file. For more information, check out our engineering docs
* on how we handle JS minification in our engineering docs.
*
* @see: https://evnt.is/dev-docs-minification
*/
!function(global){"use strict";var focusedBeforeDialog,FOCUSABLE_ELEMENTS=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex^="-"])'],browser=function browserTests(){var android=/(android)/i.test(navigator.userAgent),chrome=!!window.chrome,firefox="undefined"!=typeof InstallTrigger,ie=document.documentMode,edge=!ie&&!!window.StyleMedia,ios=!!navigator.userAgent.match(/(iPod|iPhone|iPad)/i),iosMobile=!!navigator.userAgent.match(/(iPod|iPhone)/i),opera=!!window.opera||navigator.userAgent.indexOf(" OPR/")>=0,safari=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")>0||!chrome&&!opera&&"undefined"!==window.webkitAudioContext,os=navigator.platform;return{android:android,chrome:chrome,edge:edge,firefox:firefox,ie:ie,ios:ios,iosMobile:iosMobile,opera:opera,safari:safari,os:os}}(),scroll=0,scroller=browser.ie||browser.firefox||browser.chrome&&!browser.edge?document.documentElement:document.body;function A11yDialog(options){this.options=function extend(obj,src){return Object.keys(src).forEach((function(key){obj[key]=src[key]})),obj}({appendTarget:"",bodyLock:!0,closeButtonAriaLabel:"Close this dialog window",closeButtonClasses:"a11y-dialog__close-button",contentClasses:"a11y-dialog__content",effect:"none",effectSpeed:300,effectEasing:"ease-in-out",overlayClasses:"a11y-dialog__overlay",overlayClickCloses:!0,trigger:null,wrapperClasses:"a11y-dialog",ariaDescribedBy:"",ariaLabel:"",ariaLabelledBy:""},options),this._rendered=!1,this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.trigger=function isString(x){return"[object String]"===Object.prototype.toString.call(x)}(this.options.trigger)?getNodes(this.options.trigger,!0,document,!0):this.options.trigger,this.node=null,this.trigger?(this._listeners={},this.create()):console.warn("Lookup for a11y target node failed.")}function convertElements(elements){for(var converted=[],i=elements.length;i--;converted.unshift(elements[i]));return converted}function getNodes(selector,convert,node,custom){node||(node=document);var selectorString=custom?selector:'[data-js="'+selector+'"]',nodes=node.querySelectorAll(selectorString);return convert&&(nodes=convertElements(nodes)),nodes}function setFocusToFirstItem(node){var focusableChildren=getFocusableChildren(node);focusableChildren.length&&focusableChildren[0].focus()}function getFocusableChildren(node){return function $$(selector,context){return convertElements((context||document).querySelectorAll(selector))}(FOCUSABLE_ELEMENTS.join(","),node).filter((function(child){return!!(child.offsetWidth||child.offsetHeight||child.getClientRects().length)}))}A11yDialog.prototype.create=function(){return this.shown=!1,this.trigger.forEach(function(opener){opener.addEventListener("click",this._show)}.bind(this)),this._fire("create"),this},A11yDialog.prototype.render=function(event){var contentNode=getNodes(this.trigger[0].dataset.content)[0];if(!contentNode)return this;var ariaDescribedBy=this.options.ariaDescribedBy?'aria-describedby="'+this.options.ariaDescribedBy+'" ':"",ariaLabel=this.options.ariaLabel?'aria-label="'+this.options.ariaLabel+'"':"",ariaLabelledBy=this.options.ariaLabelledBy?'aria-labelledby="'+this.options.ariaLabelledBy+'"':"",node=document.createElement("div");node.setAttribute("aria-hidden","true"),node.classList.add(this.options.wrapperClasses),node.innerHTML='<div data-js="a11y-overlay" tabindex="-1" class="'+this.options.overlayClasses+'"></div>\n <div class="'+this.options.contentClasses+'" role="dialog" aria-modal="true" '+ariaLabelledBy+ariaDescribedBy+ariaLabel+'>\n <div role="document">\n <button data-js="a11y-close-button" class="'+this.options.closeButtonClasses+'" type="button" aria-label="'+this.options.closeButtonAriaLabel+'" ></button>\n '+contentNode.innerHTML+" </div>\n </div>";var appendTarget=this.trigger;return this.options.appendTarget.length&&(appendTarget=document.querySelectorAll(this.options.appendTarget)[0]||this.trigger),function insertAfter(newNode,referenceNode){referenceNode.parentNode.insertBefore(newNode,referenceNode.nextElementSibling)}(node,appendTarget),this.node=node,this.overlay=getNodes("a11y-overlay",!1,this.node)[0],this.closeButton=getNodes("a11y-close-button",!1,this.node)[0],this.options.overlayClickCloses&&this.overlay.addEventListener("click",this._hide),this.closeButton.addEventListener("click",this._hide),this._rendered=!0,this._fire("render",event),this},A11yDialog.prototype.show=function(event){return this.shown?this:(this._rendered||this.render(event),this._rendered?(this.shown=!0,this._applyOpenEffect(),this.node.setAttribute("aria-hidden","false"),this.options.bodyLock&&function lock(){scroll=scroller.scrollTop,document.body.classList.add("a11y-dialog__body-locked"),document.body.style.position="fixed",document.body.style.width="100%",document.body.style.marginTop="-"+scroll+"px"}(),focusedBeforeDialog=document.activeElement,setFocusToFirstItem(this.node),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",event),this):this)},A11yDialog.prototype.hide=function(event){return this.shown?(this.shown=!1,"none"===this.options.effect&&this.node.setAttribute("aria-hidden","true"),this._applyCloseEffect(),this.options.bodyLock&&function unlock(){document.body.style.marginTop="",document.body.style.position="",document.body.style.width="",scroller.scrollTop=scroll,document.body.classList.remove("a11y-dialog__body-locked")}(),focusedBeforeDialog&&focusedBeforeDialog.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",event),this):this},A11yDialog.prototype.destroy=function(){return this.hide(),this.trigger.forEach(function(opener){opener.removeEventListener("click",this._show)}.bind(this)),this._rendered&&(this.options.overlayClickCloses&&this.overlay.removeEventListener("click",this._hide),this.closeButton.removeEventListener("click",this._hide)),this._fire("destroy"),this._listeners={},this},A11yDialog.prototype.on=function(type,handler){return void 0===this._listeners[type]&&(this._listeners[type]=[]),this._listeners[type].push(handler),this},A11yDialog.prototype.off=function(type,handler){var index=this._listeners[type].indexOf(handler);return index>-1&&this._listeners[type].splice(index,1),this},A11yDialog.prototype._fire=function(type,event){(this._listeners[type]||[]).forEach(function(listener){listener(this.node,event)}.bind(this))},A11yDialog.prototype._bindKeypress=function(event){this.shown&&27===event.which&&(event.preventDefault(),this.hide()),this.shown&&9===event.which&&function trapTabKey(node,event){var focusableChildren=getFocusableChildren(node),focusedItemIndex=focusableChildren.indexOf(document.activeElement);event.shiftKey&&0===focusedItemIndex?(focusableChildren[focusableChildren.length-1].focus(),event.preventDefault()):event.shiftKey||focusedItemIndex!==focusableChildren.length-1||(focusableChildren[0].focus(),event.preventDefault())}(this.node,event)},A11yDialog.prototype._maintainFocus=function(event){this.shown&&!this.node.contains(event.target)&&setFocusToFirstItem(this.node)},A11yDialog.prototype._applyOpenEffect=function(){var _this=this;setTimeout((function(){_this.node.classList.add("a11y-dialog--open")}),50),"fade"===this.options.effect&&(this.node.style.opacity="0",this.node.style.transition="opacity "+this.options.effectSpeed+"ms "+this.options.effectEasing,setTimeout((function(){_this.node.style.opacity="1"}),50))},A11yDialog.prototype._applyCloseEffect=function(){var _this=this;this.node.classList.remove("a11y-dialog--open"),"fade"===this.options.effect?(this.node.style.opacity="0",setTimeout((function(){_this.node.style.transition="",_this.node.setAttribute("aria-hidden","true")}),this.options.effectSpeed)):"css"===this.options.effect&&setTimeout((function(){_this.node.setAttribute("aria-hidden","true")}),this.options.effectSpeed)},"undefined"!=typeof module&&void 0!==module.exports?module.exports=A11yDialog:"function"==typeof define&&define.amd?define("A11yDialog",[],(function(){return A11yDialog})):"object"==typeof global&&(global.A11yDialog=A11yDialog)}("undefined"!=typeof global?global:window);