PageSourceSearch

https://rare.org/wp-content/plugins/subtle-blocks/dependencies/a11y-dialog.min.js?ver=1.2.3

js rare.org collected 2026-09-24 18:00:08 UTC 6,030 bytes, 209 lines download raw bytes

1/*! a11y-dialog 7.5.2 — © Kitty Giraudel */
2! ( function ( t, e ) {
3	'object' === typeof exports && 'undefined' !== typeof module
4		? ( module.exports = e() )
5		: 'function' === typeof define && define.amd
6		? define( e )
7		: ( ( t =
8				'undefined' !== typeof globalThis
9					? globalThis
10					: t || self ).A11yDialog = e() );
11} )( this, function () {
12	'use strict';
13	const t = [
14		'a[href]:not([tabindex^="-"])',
15		'area[href]:not([tabindex^="-"])',
16		'input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])',
17		'input[type="radio"]:not([disabled]):not([tabindex^="-"])',
18		'select:not([disabled]):not([tabindex^="-"])',
19		'textarea:not([disabled]):not([tabindex^="-"])',
20		'button:not([disabled]):not([tabindex^="-"])',
21		'iframe:not([tabindex^="-"])',
22		'audio[controls]:not([tabindex^="-"])',
23		'video[controls]:not([tabindex^="-"])',
24		'[contenteditable]:not([tabindex^="-"])',
25		'[tabindex]:not([tabindex^="-"])',
26	];
27	function e( t ) {
28		( this._show = this.show.bind( this ) ),
29			( this._hide = this.hide.bind( this ) ),
30			( this._maintainFocus = this._maintainFocus.bind( this ) ),
31			( this._bindKeypress = this._bindKeypress.bind( this ) ),
32			( this.$el = t ),
33			( this.shown = ! 1 ),
34			( this._id =
35				this.$el.getAttribute( 'data-a11y-dialog' ) || this.$el.id ),
36			( this._previouslyFocused = null ),
37			( this._listeners = {} ),
38			this.create();
39	}
40	function i( t, e ) {
41		return (
42			( i = ( e || document ).querySelectorAll( t ) ),
43			Array.prototype.slice.call( i )
44		);
45		let i;
46	}
47	function n( t ) {
48		( t.querySelector( '[autofocus]' ) || t ).focus();
49	}
50	function s() {
51		i( '[data-a11y-dialog]' ).forEach( function ( t ) {
52			new e( t );
53		} );
54	}
55	return (
56		( e.prototype.create = function () {
57			this.$el.setAttribute( 'aria-hidden', ! 0 ),
58				this.$el.setAttribute( 'aria-modal', ! 0 ),
59				this.$el.setAttribute( 'tabindex', -1 ),
60				this.$el.hasAttribute( 'role' ) ||
61					this.$el.setAttribute( 'role', 'dialog' ),
62				( this._openers = i(
63					'[data-a11y-dialog-show="' + this._id + '"]'
64				) ),
65				this._openers.forEach(
66					function ( t ) {
67						t.addEventListener( 'click', this._show );
68					}.bind( this )
69				);
70			const t = this.$el;
71			return (
72				( this._closers = i( '[data-a11y-dialog-hide]', this.$el )
73					.filter( function ( e ) {
74						return (
75							e.closest(
76								'[aria-modal="true"], [data-a11y-dialog]'
77							) === t
78						);
79					} )
80					.concat(
81						i( '[data-a11y-dialog-hide="' + this._id + '"]' )
82					) ),
83				this._closers.forEach(
84					function ( t ) {
85						t.addEventListener( 'click', this._hide );
86					}.bind( this )
87				),
88				this._fire( 'create' ),
89				this
90			);
91		} ),
92		( e.prototype.show = function ( t ) {
93			return (
94				this.shown ||
95					( ( this._previouslyFocused = document.activeElement ),
96					this.$el.removeAttribute( 'aria-hidden' ),
97					( this.shown = ! 0 ),
98					n( this.$el ),
99					document.body.addEventListener(
100						'focus',
101						this._maintainFocus,
102						! 0
103					),
104					document.addEventListener( 'keydown', this._bindKeypress ),
105					this._fire( 'show', t ) ),
106				this
107			);
108		} ),
109		( e.prototype.hide = function ( t ) {
110			return this.shown
111				? ( ( this.shown = ! 1 ),
112				  this.$el.setAttribute( 'aria-hidden', 'true' ),
113				  this._previouslyFocused &&
114						this._previouslyFocused.focus &&
115						this._previouslyFocused.focus(),
116				  document.body.removeEventListener(
117						'focus',
118						this._maintainFocus,
119						! 0
120				  ),
121				  document.removeEventListener( 'keydown', this._bindKeypress ),
122				  this._fire( 'hide', t ),
123				  this )
124				: this;
125		} ),
126		( e.prototype.destroy = function () {
127			return (
128				this.hide(),
129				this._openers.forEach(
130					function ( t ) {
131						t.removeEventListener( 'click', this._show );
132					}.bind( this )
133				),
134				this._closers.forEach(
135					function ( t ) {
136						t.removeEventListener( 'click', this._hide );
137					}.bind( this )
138				),
139				this._fire( 'destroy' ),
140				( this._listeners = {} ),
141				this
142			);
143		} ),
144		( e.prototype.on = function ( t, e ) {
145			return (
146				void 0 === this._listeners[ t ] &&
147					( this._listeners[ t ] = [] ),
148				this._listeners[ t ].push( e ),
149				this
150			);
151		} ),
152		( e.prototype.off = function ( t, e ) {
153			const i = ( this._listeners[ t ] || [] ).indexOf( e );
154			return i > -1 && this._listeners[ t ].splice( i, 1 ), this;
155		} ),
156		( e.prototype._fire = function ( t, e ) {
157			const i = this._listeners[ t ] || [],
158				n = new CustomEvent( t, { detail: e } );
159			this.$el.dispatchEvent( n ),
160				i.forEach(
161					function ( t ) {
162						t( this.$el, e );
163					}.bind( this )
164				);
165		} ),
166		( e.prototype._bindKeypress = function ( e ) {
167			const n = document.activeElement;
168			( n && n.closest( '[aria-modal="true"]' ) !== this.$el ) ||
169				( this.shown &&
170					'Escape' === e.key &&
171					'alertdialog' !== this.$el.getAttribute( 'role' ) &&
172					( e.preventDefault(), this.hide( e ) ),
173				this.shown &&
174					'Tab' === e.key &&
175					( function ( e, n ) {
176						const s = ( function ( e ) {
177								return i( t.join( ',' ), e ).filter(
178									function ( t ) {
179										return !! (
180											t.offsetWidth ||
181											t.offsetHeight ||
182											t.getClientRects().length
183										);
184									}
185								);
186							} )( e ),
187							o = s.indexOf( document.activeElement );
188						n.shiftKey && 0 === o
189							? ( s[ s.length - 1 ].focus(), n.preventDefault() )
190							: n.shiftKey ||
191							  o !== s.length - 1 ||
192							  ( s[ 0 ].focus(), n.preventDefault() );
193					} )( this.$el, e ) );
194		} ),
195		( e.prototype._maintainFocus = function ( t ) {
196			! this.shown ||
197				t.target.closest( '[aria-modal="true"]' ) ||
198				t.target.closest( '[data-a11y-dialog-ignore-focus-trap]' ) ||
199				n( this.$el );
200		} ),
201		'undefined' !== typeof document &&
202			( 'loading' === document.readyState
203				? document.addEventListener( 'DOMContentLoaded', s )
204				: window.requestAnimationFrame
205				? window.requestAnimationFrame( s )
206				: window.setTimeout( s, 16 ) ),
207		e
208	);
209} );

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.