PageSourceSearch

https://lasostadellatartaruga.it/wp-content/plugins/wp-accessibility/js/wp-accessibility.js?ver=2.0.1

js lasostadellatartaruga.it collected 2026-10-08 04:30:43 UTC 11,296 bytes, 287 lines download raw bytes

1(function( $ ) { 'use strict';
2	var html   = document.querySelector( 'html' );
3	if ( wpa.lang ) {
4		var lang   = html.getAttribute( 'lang' );
5		if ( ! lang ) {
6			$('html').attr( 'lang', wpa.lang );
7			if ( wpa.errors ) {
8				console.log( 'HTML language set by WP Accessibility' );
9			}
10		}
11	}
12
13	if ( wpa.dir ) {
14		var dir  = html.getAttribute( 'dir' );
15		if ( ! dir ) {
16			$('html').attr( 'dir', wpa.dir );
17			if ( wpa.errors ) {
18				console.log( 'HTML language direction set by WP Accessibility' );
19			}
20		}
21	}
22
23	var viewport = document.querySelector( 'meta[name="viewport"]' );
24	if ( viewport ) {
25		var conditionsBefore = viewport.getAttribute( 'content' );
26		var conditionsAfter  = viewport.getAttribute( 'content' );
27		if ( conditionsBefore.search(/user-scalable=no/g) ) {
28			conditionsAfter = conditionsBefore.replace( 'user-scalable=no', 'user-scalable=yes' );
29			viewport.setAttribute( 'content', conditionsAfter );
30			if ( wpa.errors && conditionsAfter != conditionsBefore ) {
31				console.log( 'Viewport made scalable by WP Accessibility' );
32			}
33		}
34		if ( conditionsBefore.search(/maximum-scale=1/g) ) {
35			conditionsAfter = conditionsBefore.replace( 'maximum-scale=1', 'maximum-scale=5' );
36			conditionsAfter = conditionsAfter.replace( 'maximum-scale=0', 'maximum-scale=5' );
37			viewport.setAttribute( 'content', conditionsAfter );
38			if ( wpa.errors && conditionsAfter != conditionsBefore  ) {
39				console.log( 'Viewport maximum scale set by WP Accessibility' );
40			}
41		}
42	}
43
44	if ( wpa.skiplinks.enabled ) {
45		$('body').prepend( wpa.skiplinks.output );
46		if ( wpa.errors ) {
47			console.log( 'Skip links added by WP Accessibility' );
48		}
49	}
50
51	if ( wpa.current ) {
52		$(function() {
53			$( '.current-menu-item a, .current_page_item a' ).attr( 'aria-current', 'page' );
54		});
55		if ( wpa.errors ) {
56			console.log( 'ARIA current added by WP Accessibility' );
57		}
58	}
59
60	if ( wpa.labels ) {
61		var wpa_names = [ 's', 'author', 'email', 'url', 'comment' ];
62		$.each( wpa_names, function( index, value ) {
63			if ( value == 'comment' ) {
64				var field = $( 'textarea[name=' + value + ']' );
65			} else {
66				var field = $( 'input[name=' + value + ']' ).not( '#adminbar-search' );
67			}
68			if ( 0 !== field.length ) {
69				var field_id = field.attr( 'id' );
70				var implicit = $( field ).parent( 'label' );
71				var aria = $( field ).attr( 'aria-label' );
72				var ariaId = $( field ).attr( 'aria-labelledby' );
73				var ariaTarget = {};
74				if ( ariaId ) {
75					ariaTarget = $( '#' + ariaId );
76				}
77				var hasAria   = ( '' == aria || 'undefined' == typeof( aria ) ) ? false : true;
78				var hasAriaId = ( '' == ariaId || 'undefined' == typeof( ariaId ) ) ? false : true;
79				// Add label if aria label empty, aria labelledby empty, or aria reference ID does not exist.
80				if ( ( ! hasAria && ! hasAriaId ) || ( ! hasAria && ( hasAriaId && 0 === ariaTarget.length ) ) ) {
81					if ( field_id ) {
82						var label = $( 'label[for=' + field_id + ']' );
83						if ( !label.length && !implicit.length ) {
84							field.before( "<label for='" + field_id + "' class='wpa-screen-reader-text'>" + wpa.wpalabels[value] + "</label>" );
85							if ( wpa.errors ) {
86								console.log( 'Explicit label on ' + wpa.wpalabels[value] + 'added by WP Accessibility' );
87							}
88						}
89					} else {
90						if ( !implicit.length ) {
91							field.attr( 'id', 'wpa_label_' + value ).before( "<label for='wpa_label_" + value + "' class='wpa-screen-reader-text'>" + wpa.wpalabels[value] + "</label>" );
92							if ( wpa.errors ) {
93								console.log( 'Implicit label on ' + wpa.wpalabels[value] + 'added by WP Accessibility' );
94							}
95						}
96					}
97				}
98			}
99		});
100	}
101
102
103	if ( wpa.titles ) {
104		var images   = 0;
105		var controls = 0;
106		var fields   = 0;
107		const els    = document.querySelectorAll( 'img, a, input, textarea, select, button' );
108		els.forEach((el) => {
109			var title = el.getAttribute( 'title' );
110			if ( title && '' !== title ) {
111				switch ( el.tagName ) {
112					case 'IMG':
113						// If image has alt, remove title. If not, set title as alt.
114						var alt = el.getAttribute( 'alt' );
115						if ( ! alt || '' === alt ) {
116							el.setAttribute( 'alt', title );
117							el.removeAttribute( 'title' );
118						} else {
119							el.removeAttribute( 'title' );
120						}
121						images++;
122						break;
123					case 'A':
124					case 'BUTTON':
125						// If link or button has contained text or an img with alt, remove title. Otherwise, set title as aria-label unless element already has aria-label.
126						var linkText = wpaElementText(el);
127						if ( ! linkText || '' === linkText ) {
128							var ariaLabel = el.getAttribute( 'aria-label' );
129							if ( ! ariaLabel || '' === ariaLabel ) {
130								el.setAttribute( 'aria-label', title );
131								el.removeAttribute( 'title' );
132							}
133						} else {
134							el.removeAttribute( 'title' );
135						}
136						controls++;
137						break;
138					case 'INPUT':
139					case 'SELECT':
140					case 'TEXTAREA':
141						// If input field has an aria-label, aria-labelledby, associated label, or wrapping label, remove title. Else, add title as aria-label.
142						var ariaLabel        = el.getAttribute( 'aria-label' );
143						var ariaLabelled     = el.getAttribute( 'aria-labelledby' );
144						var ariaLabeller     = ( ariaLabelled ) ? document.getElementById( ariaLabelled ) : false;
145						var labelId          = el.getAttribute( 'id' );
146						var label            = ( labelId ) ? document.querySelector( 'label[for="' + labelId + '"]' ) : false;
147						var parentLabel      = el.closest( 'label' );
148						var hasAriaLabel     = ( ariaLabel && '' !== ariaLabel ) ? true : false;
149						var hasRealLabel     = ( label && '' !== wpaElementText( label ) ) ? true : false;
150						var hasImplicitLabel = ( parentLabel && '' !== wpaElementText( parentLabel ) ) ? true : false;
151						var hasAriaLabelled  = ( ariaLabeller && '' !== wpaElementText( arialabeller ) ) ? true : false;
152						if ( hasAriaLabel || hasRealLabel || hasImplicitLabel || hasAriaLabelled ) {
153							// This has a label.
154							el.removeAttribute( 'title' );
155						} else {
156							el.setAttribute( 'aria-label', title );
157							el.removeAttribute( 'title' );
158						}
159						fields++;
160						break;
161				}
162			}
163		});
164		if ( wpa.errors ) {
165			if ( images > 0 ) {
166				console.log( images + ' title attributes removed from images by WP Accessibility' );
167			}
168			if ( controls > 0 ) {
169				console.log( controls + ' title attributes removed from links and buttons by WP Accessibility' );
170			}
171			if ( fields > 0 ) {
172				console.log( fields + ' title attributes removed from input fields by WP Accessibility' );
173			}
174		}
175	}
176
177	if ( wpa.target ) {
178		var targeted      = $('a:not(.wpa-allow-target)');
179		var targetRemoved = 0;
180		targeted.each( function() {
181			var target = $( this ).attr( 'target' );
182			if ( target ) {
183				$( this ).removeAttr( 'target' );
184				targetRemoved++;
185			}
186		});
187		if ( targetRemoved > 0 && wpa.errors ) {
188			console.log( targetRemoved + ' target attributes removed from links by WP Accessibility' );
189		}
190	}
191
192	if ( wpa.tabindex ) {
193		// Remove tabindex from elements that should be natively focusable.
194		var focusable  = $('input,a,select,textarea,button').not('a:not([href])');
195		var tabRemoved = 0;
196		focusable.each( function() {
197			var tabindex = $( this ).attr( 'tabindex' );
198			if ( tabindex ) {
199				$( this ).removeAttr('tabindex');
200				tabRemoved++;
201			}
202		});
203
204		if ( tabRemoved > 0 && wpa.errors ) {
205			console.log( tabRemoved + ' tabindex attributes removed from links, buttons and inputs by WP Accessibility' );
206		}
207
208		// Add tabindex to elements that appear active but are not natively focusable.
209		var fakeButtons = $('div[role="button"]').not('div[tabindex]' );
210		var buttonLinks = $('a[role="button"]').not('a[tabindex],a[href]');
211		fakeButtons.attr( 'tabindex', '0' ).addClass('wpa-focusable');
212		if ( fakeButtons.length > 0 && wpa.errors ) {
213			console.log( fakeButtons.length + ' tabindex attributes added to divs with the button role by WP Accessibility' );
214		}
215		buttonLinks.attr( 'tabindex', '0' ).addClass('wpa-focusable');
216		if ( buttonLinks.length > 0 && wpa.errors ) {
217			console.log( buttonLinks.length + ' tabindex attributes added to anchor elements with the button role and no href value by WP Accessibility' );
218		}
219	}
220
221	if ( wpa.underline.enabled ) {
222		// Underline any link not inside a `nav` region. Using JS for this avoids problems with cascade precedence.
223		var originalOutline = $( wpa.underline.target ).css( 'outline-width' );
224		var originalOffset  = $( wpa.underline.target ).css( 'outline-offset' );
225		var textColor       = $( wpa.underline.target ).css( 'color' );
226		var originalColor   = $( wpa.underline.target ).css( 'outline-color' );
227		$( wpa.underline.target ).not( 'nav ' + wpa.underline.target ).css( 'text-decoration', 'underline' );
228
229		$( wpa.underline.target ).on( 'mouseenter', function() {
230			$( this ).css( 'text-decoration', 'none' );
231		});
232		$(  wpa.underline.target ).on( 'mouseleave', function() {
233			// Reset visible appearance on exit.
234			$( this ).css( 'text-decoration', 'underline' );
235		});
236
237		$( wpa.underline.target ).on( 'focusin', function() {
238			var newOutline = '2px';
239			if ( originalOutline == '2px' ) {
240				newOutline = '4px';
241			}
242			// Ensure there's a visible change of appearance on hover or focus.
243			$(this).css( 'outline-width', newOutline );
244			$(this).css( 'outline-color', textColor );
245			$(this).css( 'outline-offset', '2px' );
246		});
247		$(  wpa.underline.target ).on( 'focusout', function() {
248			// Reset visible appearance on exit.
249			$(this).css( 'outline-width', originalOutline );
250			$(this).css( 'outline-color', originalColor );
251			$(this).css( 'outline-offset', originalOffset );
252		});
253	}
254}(jQuery));
255
256/**
257 * Check whether an element contains text, including inspecting contained content for image alt attributes or aria-label attributes.
258 *
259 *
260 * @arg el DOM element to check.
261 *
262 * Based on work by Roger Johansson https://www.456bereastreet.com/archive/201105/get_element_text_including_alt_text_for_images_with_javascript/
263 */
264function wpaElementText(el) {
265	var text = '';
266	// Text node (3) or CDATA node (4) - return its text
267	if ( (el.nodeType === 3) || (el.nodeType === 4) ) {
268		text = el.nodeValue;
269	// If node is an element (1) and an img, input[type=image], or area element, return its alt text
270	} else if ( (el.nodeType === 1) && (
271			(el.tagName.toLowerCase() == 'img') ||
272			(el.tagName.toLowerCase() == 'area') ||
273			((el.tagName.toLowerCase() == 'input') && el.getAttribute('type') && (el.getAttribute('type').toLowerCase() == 'image'))
274			) ) {
275		text = el.getAttribute('alt') || '';
276	// Traverse children unless this is a script or style element
277	} else if ( (el.nodeType === 1) && !el.tagName.match(/^(script|style)$/i) ) {
278		var children = el.childNodes;
279		for (var i = 0, l = children.length; i < l; i++) {
280			// If an element has an aria-label, that will override any other contained text.
281			var ariaLabel = el.getAttribute( 'aria-label' );
282			text += ( ariaLabel ) ? ariaLabel : wpaElementText( children[i] ) + ' ';
283		}
284	}
285
286	return text;
287};

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.