PageSourceSearch

https://cc-gallymauldre.fr/modules/contrib/one_click_accessibility/js/accessibility-tools.js?v=10.6.17

js cc-gallymauldre.fr collected 2026-09-25 07:39:14 UTC 7,387 bytes, 273 lines download raw bytes

1/*!
2 * @author: Pojo Team
3 */
4/* global jQuery, PojoA11yOptions */
5
6( function( $, window, document, undefined ) {
7	'use strict';
8
9	var Pojo_Accessibility_App = {
10		cache: {
11			$document: $( document ),
12			$window: $( window )
13		},
14
15		cacheElements: function() {
16			this.cache.$toolbar = $( '#pojo-a11y-toolbar' );
17			this.cache.$toolbarLinks = this.cache.$toolbar.find( 'a.pojo-a11y-toolbar-link' );
18			this.cache.$toolbarToolsLinks = this.cache.$toolbar.find( '.pojo-a11y-tools a.pojo-a11y-toolbar-link' );
19			this.cache.$btnToolbarToggle = this.cache.$toolbar.find( 'div.pojo-a11y-toolbar-toggle > a' );
20			this.cache.$skipToContent = $( '#pojo-a11y-skip-content' );
21			this.cache.$body = $( 'body' );
22		},
23
24		settings: {
25			minFontSize: 110,
26			maxFontSize: 200,
27			buttonsClassPrefix: 'pojo-a11y-btn-',
28			bodyClassPrefix: 'pojo-a11y-',
29			bodyFontClassPrefix: 'pojo-a11y-resize-font-',
30			storageKey: 'pojo-a11y',
31			expires:  43200000 // 12 hours
32		},
33
34		variables: {
35			currentFontSize: 110,
36			currentSchema: null
37		},
38
39		activeActions: {},
40
41		buildElements: function() {
42			// Move the `toolbar/skip to content` to top
43			this.cache.$body.prepend( this.cache.$toolbar );
44			this.cache.$body.prepend( this.cache.$skipToContent );
45		},
46
47		bindEvents: function() {
48			var $self = this;
49
50			$self.cache.$btnToolbarToggle.on( 'click', function( event ) {
51				event.preventDefault();
52
53				$self.cache.$toolbar.toggleClass( 'pojo-a11y-toolbar-open','1000' );
54
55				if ( $self.cache.$toolbar.hasClass( 'pojo-a11y-toolbar-open' ) ) {
56					$self.cache.$toolbarLinks.attr( 'tabindex', '0' );
57				} else {
58					$self.cache.$toolbarLinks.attr( 'tabindex', '-1' );
59				}
60			} );
61
62			$( document ).on( 'keyup', function( event ) {
63				var TAB_KEY = 9;
64				
65				if ( TAB_KEY !== event.which || ! $self.cache.$btnToolbarToggle.is( ':focus' ) ) {
66					return;
67				}
68				$self.cache.$toolbar.addClass( 'pojo-a11y-toolbar-open' );
69				$self.cache.$toolbarLinks.attr( 'tabindex', '0' );
70			} );
71
72			$self.bindToolbarButtons();
73		},
74
75		bindToolbarButtons: function() {
76			var self = this;
77
78			self.cache.$toolbarToolsLinks.on( 'click', function( event ) {
79				event.preventDefault();
80
81				var $this = $( this ),
82					action = $this.data( 'action' ),
83					actionGroup = $this.data( 'action-group' ),
84					deactivate = false;
85
86				if ( 'reset' === action ) {
87					self.reset();
88					return;
89				}
90
91				if ( -1 !== [ 'toggle', 'schema' ].indexOf( actionGroup ) ) {
92					deactivate = $this.hasClass( 'active' );
93				}
94
95				self.activateButton( action, deactivate );
96			} );
97		},
98
99		activateButton: function( action, deactivate ) {
100			var $button = this.getButtonByAction( action ),
101				actionGroup = $button.data( 'action-group' );
102
103			this.activeActions[ action ] = ! deactivate;
104
105			this.actions[ actionGroup ].call( this, action, deactivate );
106
107			this.saveToLocalStorage();
108		},
109
110		getActiveButtons: function() {
111			return this.cache.$toolbarToolsLinks.filter( '.active' );
112		},
113
114		getButtonByAction: function( action ) {
115			return this.cache.$toolbarToolsLinks.filter( '.' + this.settings.buttonsClassPrefix + action );
116		},
117
118		actions: {
119			toggle: function( action, deactivate ) {
120				var $button = this.getButtonByAction( action ),
121					fn = deactivate ? 'removeClass' : 'addClass';
122
123				if ( deactivate ) {
124					$button.removeClass( 'active' );
125				} else {
126					$button.addClass( 'active' );
127				}
128
129				this.cache.$body[ fn ]( this.settings.bodyClassPrefix + action );
130			},
131			resize: function( action, deactivate ) {
132				var oldFontSize = this.variables.currentFontSize;
133
134				if ( 'resize-plus' === action && this.settings.maxFontSize > oldFontSize ) {
135					this.variables.currentFontSize += 10;
136				}
137
138				if ( 'resize-minus' === action && this.settings.minFontSize < oldFontSize ) {
139					this.variables.currentFontSize -= 10;
140				}
141
142				if ( deactivate ) {
143					this.variables.currentFontSize = this.settings.minFontSize;
144				}
145
146				this.cache.$body.removeClass( this.settings.bodyFontClassPrefix + oldFontSize );
147
148				var isPlusActive = 110 < this.variables.currentFontSize,
149					plusButtonAction = isPlusActive ? 'addClass' : 'removeClass';
150
151				this.getButtonByAction( 'resize-plus' )[ plusButtonAction ]( 'active' );
152
153				if ( isPlusActive ) {
154					this.cache.$body.addClass( this.settings.bodyFontClassPrefix + this.variables.currentFontSize );
155				}
156
157				this.activeActions[ 'resize-minus' ] = false;
158				this.activeActions[ 'resize-plus' ] = isPlusActive;
159				this.cache.$window.trigger( 'resize' );
160			},
161			schema: function( action, deactivate ) {
162				var currentSchema = this.variables.currentSchema;
163
164				if ( currentSchema ) {
165					this.cache.$body.removeClass( this.settings.bodyClassPrefix + currentSchema );
166					this.getButtonByAction( currentSchema ).removeClass( 'active' );
167					this.activeActions[ currentSchema ] = false;
168
169					this.saveToLocalStorage();
170				}
171
172				if ( deactivate ) {
173					this.variables.currentSchema = null;
174					return;
175				}
176
177				currentSchema = this.variables.currentSchema = action;
178				this.cache.$body.addClass( this.settings.bodyClassPrefix + currentSchema );
179				this.getButtonByAction( currentSchema ).addClass( 'active' );
180			}
181		},
182
183		reset: function() {
184			for ( var action in this.activeActions ) {
185				if ( this.activeActions.hasOwnProperty( action ) && this.activeActions[ action ] ) {
186					this.activateButton( action, true );
187				}
188			}
189
190			localStorage.removeItem( this.settings.storageKey );
191		},
192
193		saveToLocalStorage: function() {
194			// if ( '1' !== PojoA11yOptions.enable_save ) {
195			// 	return;
196			// }
197
198			if ( ! this.variables.expires ) {
199				this.variables.expires = ( new Date() ).getTime() + this.settings.expires;
200			}
201
202			var data = {
203				actions: this.activeActions,
204				variables: {
205					currentFontSize: this.variables.currentFontSize,
206					expires: this.variables.expires
207				}
208			};
209
210			localStorage.setItem( this.settings.storageKey, JSON.stringify( data ) );
211		},
212
213		setFromLocalStorage: function() {
214			// if ( '1' !== PojoA11yOptions.enable_save ) {
215			// 	return;
216			// }
217
218			var localData = JSON.parse( localStorage.getItem( this.settings.storageKey ) );
219			if ( ! localData ) {
220				return;
221			}
222
223			var currentDate = new Date(),
224				expires = localData.variables.expires;
225
226			if ( currentDate > expires ) {
227				localStorage.removeItem( this.settings.storageKey );
228				return;
229			}
230
231			var actions = localData.actions;
232
233			if ( localData.variables.currentFontSize > 110 ) {
234				localData.variables.currentFontSize -= 10;
235			}
236
237			$.extend( this.variables, localData.variables );
238
239			for ( var action in actions ) {
240				if ( actions.hasOwnProperty( action ) && actions[ action ] ) {
241					this.activateButton( action, false );
242				}
243			}
244		},
245
246		handleGlobalOptions: function() {
247			// if ( '1' === PojoA11yOptions.focusable ) {
248				this.cache.$body.addClass( 'pojo-a11y-focusable' );
249			// }
250
251			// if ( '1' === PojoA11yOptions.remove_link_target ) {
252				$( 'a[target="_blank"]' ).attr( 'target', '' );
253			// }
254
255			// if ( '1' === PojoA11yOptions.add_role_links ) {
256				$( 'a' ).attr( 'role', 'link' );
257			// }
258		},
259
260		init: function() {
261			this.cacheElements();
262			this.buildElements();
263			this.bindEvents();
264			this.handleGlobalOptions();
265		}
266	};
267
268	$( document ).ready( function( $ ) {
269		Pojo_Accessibility_App.init();
270		Pojo_Accessibility_App.setFromLocalStorage();
271	} );
272
273}( jQuery, window, document ) );

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.