PageSourceSearch

https://www.cabourg.fr/wp-content/themes/cabourg/assets/libs/AccessConfig/js/src/accessconfig.js?ver=1.0.0

js cabourg.fr collected 2026-10-02 11:20:38 UTC 28,199 bytes, 836 lines download raw bytes

1/*
2@licstart  The following is the entire license notice for the
3JavaScript code in this page.
4
5Copyright (C) 2018  Access42
6
7The JavaScript code in this page is free software: you can
8redistribute it and/or modify it under the terms of the GNU
9General Public License (GNU GPL) as published by the Free Software
10Foundation, either version 3 of the License, or (at your option)
11any later version.  The code is distributed WITHOUT ANY WARRANTY;
12without even the implied warranty of MERCHANTABILITY or FITNESS
13FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
14
15As additional permission under GNU GPL version 3 section 7, you
16may distribute non-source (e.g., minimized or compacted) forms of
17that code without the copy of the GNU GPL normally required by
18section 4, provided you include this license notice and a URL
19through which recipients can access the Corresponding Source.
20
21
22@licend  The above is the entire license notice
23for the JavaScript code in this page.
24*/
25/*** AccessConfig **/
26
27var AccessConfig = (function() {
28
29	'use strict '
30
31	/*** Configuration **/
32	var config = {
33		Setup:{
34			//id to catch in the html
35			id: 'accessconfig',
36		},
37
38		/**
39		General Setting
40		useExtendContrast : true for three choices (default, inverted, enforced), false for two choices (default, inverted)
41		**/
42
43		Setting: {
44			useExtendContrast: true
45		},
46		BodyActive: {
47			classSetting: 'active'
48		},
49		Overlay: {
50			classSetting: 'overlay'
51		},
52
53		/**
54		Modal button and window container
55		**/
56
57		ModalButton: {
58			id: 'button'
59		},
60		ModalContainer: {
61			classSetting: 'modal',
62			titleLang: {
63				en: 'Accessibility setting',
64				fr: 'Paramètres d’accessibilité',
65			},
66			titleId: 'title',
67			titleClass: 'title',
68		},
69		CloseButton: {
70			id: 'close',
71			classSetting: 'close',
72			lang: {
73				en: 'close',
74				fr: 'fermer'
75			},
76			hiddenTextClass: 'sr-only'
77		},
78
79		/**
80		Inline content container
81		**/
82
83		InlineContentContainer: {
84			id: 'inline-c'
85		},
86
87		/**
88		Parameters checkboxes
89		lang is based on html lang declaration, first entry is the default when html lang is unknow
90		**/
91
92		FormFieldsetContent: {
93			classSetting: 'content'
94		},
95		FormFieldset: {
96			classSetting: 'fieldset'
97		},
98		LegendFieldset: {
99			classSetting: 'legend'
100		},
101		FormRadio:{
102			classSetting: 'radio'
103		},
104
105		/** Contrast
106		value : className of the dedicated className style
107		Important ! : value and id must be identical
108		**/
109
110		ContrastFieldset: {
111			//caution : don't change
112			id: 'contrast'
113		},
114		ContrastLegend: {
115			lang: {
116				en: 'Contrast',
117				fr: 'Contrastes'
118			}
119		},
120		DefaultContrastCheckbox: {
121			id: 'default-contrast',
122			value: 'default-contrast',
123			//caution : don't change
124			groupName: 'contrast',
125			//label
126			lang: {
127				en: 'Default',
128				fr: 'Défaut'
129			}
130		},
131		HighContrastCheckbox:{
132			id: 'high-contrast',
133			value: 'high-contrast',
134			//caution : don't change
135			groupName: 'contrast',
136			//label
137			lang: {
138				en: 'Reinforce',
139				fr: 'Renforcer'
140			}
141		},
142		InvertContrastCheckbox:{
143			id: 'inv-contrast',
144			value: 'inv-contrast',
145			//caution : don't change
146			groupName: 'contrast',
147			//label
148			lang: {
149				en: 'Reverse',
150				fr: 'Inverser'
151			}
152		},
153
154		/**
155		Dyslexia font
156		**/
157
158		DyslexiaFieldset: {
159			//caution : don't change
160			id: 'font'
161		},
162		DyslexiaLegend: {
163			//label
164			lang: {
165				en: 'Font (dyslexia)',
166				fr: 'Police (dyslexie)'
167			}
168		},
169		DefaultFontCheckbox:{
170			id: 'default-font',
171			value: 'default-font',
172			//caution : don't change
173			groupName: 'font',
174			//label
175			lang: {
176				en: 'Default',
177				fr: 'Défaut'
178			}
179		},
180		DyslexiaFontCheckbox:{
181			id: 'dys-font',
182			value: 'dys-font',
183			//caution : don't change
184			groupName: 'font',
185			//label
186			lang: {
187				en: 'Adapt',
188				fr: 'Adapter'
189			}
190		},
191
192		/**
193		Line spacing
194		**/
195
196		LineSpacingFieldset: {
197			//caution : don't change
198			id: 'line-spacing'
199		},
200		LineSpacingLegend: {
201			//label
202			lang: {
203				en: 'Line spacing',
204				fr: 'Interlignage'
205			}
206		},
207		DefaultLineSpacingCheckbox:{
208			id: 'default-spacing',
209			value: 'default-spacing',
210			//caution : don't change
211			groupName: 'line-spacing',
212			//label
213			lang: {
214				en: 'Default',
215				fr: 'Défaut'
216			}
217		},
218		DyslexiaLineSpacingCheckbox:{
219			id: 'dys-spacing',
220			value: 'dys-spacing',
221			//caution : don't change
222			groupName: 'line-spacing',
223			//label
224			lang: {
225				en: 'Increase',
226				fr: 'Augmenter'
227			}
228		},
229
230		/**
231		Justification
232		**/
233
234		JustificationFieldset: {
235			//caution : don't change
236			id: 'justification'
237		},
238		JustificationLegend: {
239			//label
240			lang: {
241				en: 'Justification',
242				fr: 'Justification'
243			}
244		},
245		DefaultJustificationCheckbox:{
246			id: 'default-justification',
247			value: 'default-justification',
248			//caution : don't change
249			groupName: 'justification',
250			//label
251			lang: {
252				en: 'Default',
253				fr: 'Défaut'
254			}
255		},
256		DyslexiaJustificationCheckbox:{
257			id: 'cancel-justification',
258			value: 'cancel-justification',
259			//caution : don't change
260			groupName: 'justification',
261			//label
262			lang: {
263				en: 'Remove',
264				fr: 'Supprimer'
265			}
266		},
267
268		/**
269		Image replacement
270		**/
271
272		ImageReplacementFieldset: {
273			//caution : don't change
274			id: 'image'
275		},
276		ImageReplacementCSS: {
277			//Css class to use on each image to replace
278			replacementCss: 'replace-img',
279			//Css class to style the replacement text
280			replacementStyle: 'replace-style'
281		},
282		ImageReplacementLegend: {
283			//label
284			lang: {
285				en: 'Images',
286				fr: 'Images'
287			}
288		},
289		DefaultImageReplacementCheckbox:{
290			id: 'default-img',
291			value: 'default-img',
292			//caution : don't change
293			groupName: 'image',
294			//label
295			lang: {
296				en: 'Default',
297				fr: 'Défaut'
298			}
299		},
300		ImageReplacementCheckbox:{
301			id: 'text-img',
302			value: 'text-img',
303			//caution : don't change
304			groupName: 'image',
305			//label
306			lang: {
307				en: 'Replace with text',
308				fr: 'Remplacer par du texte'
309			}
310		},
311	}
312	//global
313	var global = {
314		mode: null,
315		cookieName: null,
316		openObj: null,
317		imgTab : null,
318		imgSpan: null
319	}
320
321	/** Onload */
322	window.onload = function(){
323
324		if(!document.querySelector( '[data-accessconfig-params]' )){
325			console.log('AccessConfig warning : HTML missing')
326		}else{
327		/** Get parameters define in HTML code by user via data-accessconfig-params attribut (JSON format) **/
328			var openButton = document.querySelector( '[data-accessconfig-params]' );
329			global.userParams = JSON.parse(openButton.getAttribute( 'data-accessconfig-params' ));
330			global.userParams.Prefix ? (userPrefix = global.userParams.Prefix) : (userPrefix = 'a42-ac');
331
332			/** Set the setting form **/
333			settingForm();
334
335			/** Modal option**/
336			if( global.userParams.Modal == true || global.userParams.Modal === undefined) {
337				/** If user set data-accessconfig-param.Modal to true, then create a button to launch the modal **/
338				// var modalButton = document.createElement( 'button' );
339				// modalButton.setAttribute( 'id', userPrefix+'-'+config.ModalButton.id );
340				// modalButton.setAttribute( 'data-accessconfig-button','true' );
341
342				// var modalButtonText = document.querySelector( '[data-accessconfig-buttonname]' );
343				// var modalButtonText = document.createTextNode(modalButtonText.getAttribute( 'data-accessconfig-buttonname' ));
344				// modalButton.appendChild(modalButtonText);
345
346				// var setup = document.getElementById(config.Setup.id);
347				// setup.appendChild(modalButton);
348
349				/** Detect other button that can launch the modal by search to data-accessconfig-button="true" **/
350				var otherOpenButton = document.querySelectorAll( '[data-accessconfig-button="true"]' );
351				for (i = 0, len = otherOpenButton.length; i < len; i++ ){
352					otherOpenButton[i].addEventListener( 'click', function(){
353						dialog( this );
354					}, false);
355				}
356			}
357
358			// Contrast features
359			if(global.userParams.Contrast != false){
360				global.mode = userPrefix+'-'+config.ContrastFieldset.id;
361				global.cookieName = 'contrast';
362				setEvent();
363			}
364			// Font feature
365			if(global.userParams.Font != false){
366				global.mode = userPrefix+'-'+config.DyslexiaFieldset.id;
367				global.cookieName = 'font';
368				setEvent();
369			}
370			// Line spacing feature
371			if(global.userParams.LineSpacing != false){
372				global.mode = userPrefix+'-'+config.LineSpacingFieldset.id;
373				global.cookieName = 'line-spacing';
374				setEvent();
375			}
376			// Justification feature
377			if(global.userParams.Justification != false){
378				global.mode = userPrefix+'-'+config.JustificationFieldset.id;
379				global.cookieName = 'justification';
380				setEvent();
381			}
382			// Image replacement feature
383			if(global.userParams.ImageReplacement != false){
384				global.mode = userPrefix+'-'+config.ImageReplacementFieldset.id;
385				global.cookieName = 'image';
386				setImgtab();
387				setEvent();
388			}
389
390		}
391	}
392
393	/** Dependencies **/
394	/* Create modal or inline setting form : data-accessconfig-params = "Modal" */
395	function settingForm(){
396
397		//Constructor
398		function $create (o) {
399			var tn = o.tagName;
400			var x = document.createElement(tn);
401			for (var i in o) if (i!='tagName'&&typeof(o[i])!='function') x.setAttribute(i, o[i]);
402			return x;
403		}
404
405		var langRef = setdefaultLang();
406		var div = $create({tagName:'div', id:userPrefix, class:userPrefix});
407
408		var fieldsetContent = $create( {tagName:'div', class:userPrefix+'-'+config.FormFieldsetContent.classSetting});
409
410		// set modale
411		if( global.userParams.Modal == true || global.userParams.Modal === undefined) {
412			//modale
413			div.setAttribute( 'role', 'dialog' );
414			div.setAttribute( 'aria-labelledby', userPrefix+'-'+config.ModalContainer.titleId );
415			div.setAttribute( 'tabindex', '-1' );
416			global.userParams.ContainerClass ? div.classList.add( userPrefix+'-'+global.userParams.ContainerClass ) : 
417										   div.classList.add( userPrefix+'-'+config.ModalContainer.classSetting );
418			//title
419			var titleWindow = $create({tagName:'h1', id:userPrefix+'-'+config.ModalContainer.titleId});
420			global.userParams.ModalTitle ? titleWindow.classList.add( userPrefix+global.userParams.ModalTitle ) : 
421										   titleWindow.classList.add( userPrefix+'-'+config.ModalContainer.titleClass );
422			var titleTxt = document.createTextNode( config.ModalContainer.titleLang[ langRef ]);
423			titleWindow.appendChild( titleTxt );
424			div.appendChild( titleWindow );
425			//Close button
426			var CClose = $create({tagName:'button', type:'button',id:userPrefix+'-'+config.CloseButton.id});
427			global.userParams.ModalCloseButton ? CClose.classList.add( userPrefix+global.userParams.ModalCloseButton ) :
428												 CClose.classList.add( userPrefix+'-'+config.CloseButton.classSetting );
429			var SpanHidden = $create({tagName:'span', class:config.CloseButton.hiddenTextClass});
430			var CloseTxt = document.createTextNode( config.CloseButton.lang[ langRef ]);
431			SpanHidden.appendChild( CloseTxt );
432			CClose.appendChild( SpanHidden );
433			div.appendChild( CClose );
434			div.appendChild(fieldsetContent);
435		}
436		else {
437			//Inline form
438			var setupdiv = document.getElementById( config.Setup.id );
439			setupdiv.appendChild(div);
440			div.classList.add( userPrefix+'accessconfig-inline');
441			div.appendChild(fieldsetContent);
442		}
443
444		/**
445		Contrast features
446		**/
447
448		if(global.userParams.Contrast != false){
449
450			var fieldset = $create({tagName:'fieldset', id:userPrefix+'-'+config.ContrastFieldset.id});
451			var legend = document.createElement( 'legend' );
452			var legendText = document.createTextNode( config.ContrastLegend.lang[ langRef ] );
453			legend.appendChild( legendText );
454			fieldset.appendChild( legend );
455
456			/**Default option**/
457			var CInput = $create({tagName:'input', type:'radio', checked:'checked', id:userPrefix+'-'+config.DefaultContrastCheckbox.id, value:userPrefix+'-'+config.DefaultContrastCheckbox.value, name:userPrefix+'-'+config.DefaultContrastCheckbox.groupName});
458			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DefaultContrastCheckbox.id});
459			var defaultCText = document.createTextNode ( config.DefaultContrastCheckbox.lang[ langRef ] );
460			CLabel.appendChild( defaultCText );
461			fieldset.appendChild( CInput );
462			fieldset.appendChild( CLabel );
463
464			/**Alterntative option 1 : higher contrast**/
465			if( config.Setting.useExtendContrast ) {
466				var CInput = $create({tagName:'input', type:'radio', id:userPrefix+'-'+config.HighContrastCheckbox.id , value:userPrefix+'-'+config.HighContrastCheckbox.value, name:userPrefix+'-'+config.HighContrastCheckbox.groupName});
467				var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.HighContrastCheckbox.id});
468				var defaultCText = document.createTextNode ( config.HighContrastCheckbox.lang[ langRef ] );
469				CLabel.appendChild( defaultCText );
470				fieldset.appendChild( CInput );
471				fieldset.appendChild( CLabel );
472			}
473
474			/**Alterntative option 2 : inverted contrast**/
475			var CInput = $create({tagName:'input', type:'radio', id:userPrefix+'-'+config.InvertContrastCheckbox.id, value:userPrefix+'-'+config.InvertContrastCheckbox.value, name:userPrefix+'-'+config.InvertContrastCheckbox.groupName});
476			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.InvertContrastCheckbox.id});
477			var defaultCText = document.createTextNode ( config.InvertContrastCheckbox.lang[ langRef ] );
478			CLabel.appendChild( defaultCText );
479			fieldset.appendChild( CInput );
480			fieldset.appendChild( CLabel );
481			fieldsetContent.appendChild( fieldset );
482		}
483
484		/**
485		Font feature
486		**/
487
488		if(global.userParams.Font != false){
489			var fieldset = $create({tagName:'fieldset', id:userPrefix+'-'+config.DyslexiaFieldset.id});
490			var legend = document.createElement( 'legend' );
491			var legendText = document.createTextNode( config.DyslexiaLegend.lang[ langRef ] );
492			legend.appendChild( legendText );
493			fieldset.appendChild( legend );
494
495			/**Default option**/
496			var CInput = $create({tagName:'input', type:'radio', checked:'checked', id:userPrefix+'-'+config.DefaultFontCheckbox.id, value:userPrefix+'-'+config.DefaultFontCheckbox.value, name:userPrefix+'-'+config.DefaultFontCheckbox.groupName});
497			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DefaultFontCheckbox.id});
498			var defaultCText = document.createTextNode ( config.DefaultFontCheckbox.lang[ langRef ] );
499			CLabel.appendChild( defaultCText );
500			fieldset.appendChild( CInput );
501			fieldset.appendChild( CLabel );
502
503			/**Alternative option : alternative font OpenDyslexic**/
504			var CInput = $create({tagName:'input', type:'radio', id:userPrefix+'-'+config.DyslexiaFontCheckbox.id, value:userPrefix+'-'+config.DyslexiaFontCheckbox.value, name:userPrefix+'-'+config.DyslexiaFontCheckbox.groupName});
505			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DyslexiaFontCheckbox.id});
506			var defaultCText = document.createTextNode ( config.DyslexiaFontCheckbox.lang[ langRef ] );
507			CLabel.appendChild( defaultCText );
508			fieldset.appendChild( CInput );
509			fieldset.appendChild( CLabel );
510			fieldsetContent.appendChild( fieldset );
511		}
512
513		/**
514		Line spacing feature
515		**/
516
517		if(global.userParams.LineSpacing != false){
518			var fieldset = $create({tagName:'fieldset', id:userPrefix+'-'+config.LineSpacingFieldset.id});
519			var legend = document.createElement( 'legend' );
520			var legendText = document.createTextNode( config.LineSpacingLegend.lang[ langRef ] );
521			legend.appendChild( legendText );
522			fieldset.appendChild( legend );
523
524			/**Default option**/
525			var CInput = $create({tagName:'input', type:'radio',checked:'checked', id:userPrefix+'-'+config.DefaultLineSpacingCheckbox.id, value:userPrefix+'-'+config.DefaultLineSpacingCheckbox.value, name:userPrefix+'-'+config.DefaultLineSpacingCheckbox.groupName});
526			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DefaultLineSpacingCheckbox.id});
527			var defaultCText = document.createTextNode ( config.DefaultLineSpacingCheckbox.lang[ langRef ] );
528			CLabel.appendChild( defaultCText );
529			fieldset.appendChild( CInput );
530			fieldset.appendChild( CLabel );
531
532			/**Alternative option : line spacing increase**/
533			var CInput = $create({tagName:'input', type:'radio',id:userPrefix+'-'+config.DyslexiaLineSpacingCheckbox.id, value:userPrefix+'-'+config.DyslexiaLineSpacingCheckbox.value, name:userPrefix+'-'+config.DyslexiaLineSpacingCheckbox.groupName});
534			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DyslexiaLineSpacingCheckbox.id});
535			var defaultCText = document.createTextNode ( config.DyslexiaLineSpacingCheckbox.lang[ langRef ] );
536			CLabel.appendChild( defaultCText );
537			fieldset.appendChild( CInput );
538			fieldset.appendChild( CLabel );
539			fieldsetContent.appendChild( fieldset );
540		}
541
542		/**
543		Justification feature
544		**/
545
546		if(global.userParams.Justification != false){
547			var fieldset = $create({tagName:'fieldset', id:userPrefix+'-'+config.JustificationFieldset.id});
548			var legend = document.createElement( 'legend' );
549			var legendText = document.createTextNode( config.JustificationLegend.lang[ langRef ] );
550			legend.appendChild( legendText );
551			fieldset.appendChild( legend );
552
553			/**Default option**/
554			var CInput = $create({tagName:'input', type:'radio',checked:'checked', id:userPrefix+'-'+config.DefaultJustificationCheckbox.id, value:userPrefix+'-'+config.DefaultJustificationCheckbox.value, name:userPrefix+'-'+config.DefaultJustificationCheckbox.groupName});
555			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DefaultJustificationCheckbox.id});
556			var defaultCText = document.createTextNode ( config.DefaultJustificationCheckbox.lang[ langRef ] );
557			CLabel.appendChild( defaultCText );
558			fieldset.appendChild( CInput );
559			fieldset.appendChild( CLabel );
560
561			/**Alternative option : kill justification**/
562			var CInput = $create({tagName:'input', type:'radio',id:userPrefix+'-'+config.DyslexiaJustificationCheckbox.id, value:userPrefix+'-'+config.DyslexiaJustificationCheckbox.value, name:userPrefix+'-'+config.DyslexiaJustificationCheckbox.groupName});
563			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DyslexiaJustificationCheckbox.id});
564			var defaultCText = document.createTextNode ( config.DyslexiaJustificationCheckbox.lang[ langRef ] );
565			CLabel.appendChild( defaultCText );
566			fieldset.appendChild( CInput );
567			fieldset.appendChild( CLabel );
568			fieldsetContent.appendChild( fieldset );
569		}
570
571		/**
572		Image replacement feature
573		**/
574
575		if(global.userParams.ImageReplacement != false){
576			var fieldset = $create({tagName:'fieldset', id:userPrefix+'-'+config.ImageReplacementFieldset.id});
577			var legend = document.createElement( 'legend' );
578			var legendText = document.createTextNode( config.ImageReplacementLegend.lang[ langRef ] );
579			legend.appendChild( legendText );
580			fieldset.appendChild( legend );
581
582			/**Default option**/
583			var CInput = $create({tagName:'input', type:'radio',checked:'checked', id:userPrefix+'-'+config.DefaultImageReplacementCheckbox.id, value:userPrefix+'-'+config.DefaultImageReplacementCheckbox.value, name:userPrefix+'-'+config.DefaultImageReplacementCheckbox.groupName});
584			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.DefaultImageReplacementCheckbox.id});
585			var defaultCText = document.createTextNode ( config.DefaultImageReplacementCheckbox.lang[ langRef ] );
586			CLabel.appendChild( defaultCText );
587			fieldset.appendChild( CInput );
588			fieldset.appendChild( CLabel );
589
590			/**Alternative option : Image replacement**/
591			var CInput = $create({tagName:'input', type:'radio', id:userPrefix+'-'+config.ImageReplacementCheckbox.id, value:userPrefix+'-'+config.ImageReplacementCheckbox.value, name:userPrefix+'-'+config.ImageReplacementCheckbox.groupName});
592			var CLabel = $create({tagName:'label', for:userPrefix+'-'+config.ImageReplacementCheckbox.id});
593			var defaultCText = document.createTextNode ( config.ImageReplacementCheckbox.lang[ langRef ] );
594			CLabel.appendChild( defaultCText );
595			fieldset.appendChild( CInput );
596			fieldset.appendChild( CLabel );
597			fieldsetContent.appendChild( fieldset );
598		}
599
600		/**Set generic class attributes on fieldset, legend and radio**/
601
602		allFieldset = div.querySelectorAll( 'fieldset' );
603		for (i = 0, len = allFieldset.length; i < len; i++ ){
604			global.userParams.FormFieldset ? allFieldset[i].classList.add( userPrefix+global.userParams.FormFieldset ) : 
605											 allFieldset[i].classList.add( userPrefix+'-'+config.FormFieldset.classSetting );
606		}
607
608		allLegend = div.querySelectorAll( 'legend' );
609		for (i = 0, len = allLegend.length; i < len; i++ ){
610			global.userParams.FormFieldsetLegend ? 	allLegend[i].classList.add( userPrefix+global.userParams.FormFieldsetLegend ) : 
611													allLegend[i].classList.add( userPrefix+'-'+config.LegendFieldset.classSetting );
612		}
613
614		allRadio = div.querySelectorAll( 'input[type="radio"]' );
615		for (i = 0, len = allRadio.length; i < len; i++ ){
616			global.userParams.FormRadio ? 	allRadio[i].classList.add( userPrefix+global.userParams.FormRadio ) : 
617											allRadio[i].classList.add( userPrefix+'-'+config.FormRadio.classSetting );
618		}
619
620		/** Set the modal **/
621		var modalAttach = document.querySelector( 'body');
622		var modalAttachFirstChild = modalAttach.firstChild;
623		/** attach modal as the first child of body **/
624		if( global.userParams.Modal == true || global.userParams.Modal === undefined) modalAttach.insertBefore( div, modalAttachFirstChild);
625	}
626
627	/** Get default language (based on lang attribute) **/
628	function setdefaultLang(){
629		var lang = document.querySelector( 'html' ).getAttribute( 'lang' );
630		if( lang ){
631			var ndx;
632			( lang.indexOf( '-' ) > 0 ) ? ndx = lang.indexOf( '-' ) : ndx = 3;
633			return lang.substring( 0, ndx );
634		}
635		else {
636		 return 'en';
637		}
638	}
639
640	/** Setting managers **/
641	function setEvent(){
642		var body = document.querySelector( 'body' );
643		var fieldset = document.getElementById( global.mode );
644		var checkBoxList = fieldset.querySelectorAll( 'input' );
645		for (i = 0, len = checkBoxList.length; i < len; i++ ){
646			checkBoxList[i].addEventListener( 'click', function(){
647				setAdaptive( this );
648			}, false);
649		}
650		var target = readCookie( global.cookieName );
651		if( target ){
652
653			body.classList.add( target );
654			for (i = 0, len = checkBoxList.length; i < len; i++ ){
655				checkBoxList[i].removeAttribute( 'checked' );
656			}
657			document.getElementById( target ).setAttribute( 'checked', 'checked');
658		}
659		//Setting image replacement
660		if( body.classList.contains( userPrefix+'-'+config.DefaultImageReplacementCheckbox.value ) ){
661			replaceImgSpan();
662		}
663		if( body.classList.contains( userPrefix+'-'+config.ImageReplacementCheckbox.value ) ){
664			replaceImg();
665		}
666	}
667	/**Set adaptive mode**/
668	function setAdaptive( obj ){
669		global.mode = obj.getAttribute( 'name' );
670		global.cookieName = obj.getAttribute( 'name' );
671		var fieldset = document.getElementById( global.mode );
672
673		var checkBoxList = fieldset.querySelectorAll( 'input' );
674		var body = document.querySelector( 'body' );
675		for (i = 0, lenx = checkBoxList.length; i < lenx; i++ ){
676			var value = checkBoxList[i].getAttribute( 'value' );
677			checkBoxList[i].removeAttribute('checked');
678			if( value === userPrefix+'-'+config.DefaultImageReplacementCheckbox.value){
679				replaceImgSpan();
680			}
681				body.classList.remove( value );
682
683		}
684		var newClass = obj.getAttribute( 'value' );
685		obj.setAttribute( 'checked', 'checked' );
686		var value = obj.getAttribute( 'value' );
687			if( value === userPrefix+'-'+config.ImageReplacementCheckbox.value){
688				replaceImg();
689			}
690		body.classList.add( newClass );
691		createCookie(global.cookieName, newClass,'180');
692	}
693
694	/**
695	Image replacement helpers
696	**/
697
698	function setImgtab(){
699		global.imgSpan = new Array;
700		var selector = '.'+ userPrefix+'-'+config.ImageReplacementCSS.replacementCss;
701		global.imgTab = document.querySelectorAll( selector );
702		for (j = 0, len = global.imgTab.length; j < len; j++ ){
703			var imgPReplacement = document.createElement( 'span' );
704			var imgAlt = global.imgTab[j].getAttribute( 'alt' );
705			var imgTxtReplacement = document.createTextNode( imgAlt );
706			imgPReplacement.appendChild( imgTxtReplacement );
707			imgPReplacement.classList.add( userPrefix+'-'+config.ImageReplacementCSS.replacementCss );
708			imgPReplacement.classList.add( userPrefix+'-'+config.ImageReplacementCSS.replacementStyle );
709			global.imgSpan[j] = imgPReplacement;
710		}
711	}
712	function replaceImg(){
713		for (j = 0, len = global.imgTab.length; j < len; j++ ){
714			if( global.imgTab[j].parentNode ){
715				var parent = global.imgTab[j].parentNode;
716				global.imgTab[j] = parent.replaceChild( global.imgSpan[j], global.imgTab[j] );
717			}
718		}
719	}
720	function replaceImgSpan(){
721		for (j = 0, len = global.imgSpan.length; j < len; j++ ){
722			if( global.imgSpan[j].parentNode ){
723				var parent = global.imgSpan[j].parentNode;
724				global.imgSpan[j] = parent.replaceChild( global.imgTab[j], global.imgSpan[j] );
725			}
726		}
727	}
728
729	/**
730	Modal manager
731	**/
732
733	function dialog( returnTo ) {
734		//on ajoute une classe au body
735		document.body.classList.add(userPrefix+'-'+config.BodyActive.classSetting);
736		var overlay = document.createElement( 'div' );
737		overlay.classList.add( userPrefix+'-'+config.Overlay.classSetting );
738		document.body.appendChild(overlay);
739
740		//open
741		global.openObj = document.getElementById( userPrefix );
742		global.openObj.style.display = 'block';
743		document.getElementById( userPrefix+'-'+config.CloseButton.id ).focus();
744		//Init events
745		//escape close
746		document.addEventListener( 'keydown', escClose, false );
747		//button close
748		var closeButton = document.getElementById( userPrefix+'-'+config.CloseButton.id );
749		closeButton.addEventListener( 'click', buttonClose, false );
750		//trappingFocus
751		document.addEventListener( 'focus', trappingFocus, true );
752		//close functions
753		function escClose( event ){
754			if( event.keyCode === 27 ){
755				global.openObj.style.display = 'none';
756				returnTo.focus();
757				//reset listener and object trapping focus
758				document.removeEventListener( 'keydown', escClose , false );
759				//on retire la  classe du body
760				document.body.classList.remove(userPrefix+'-'+config.BodyActive.classSetting);
761				var overlay = document.querySelector( '.'+userPrefix+'-'+config.Overlay.classSetting  );
762				if(overlay){
763					overlay.remove();
764				}
765				//global.openObj = null;
766			}
767		}
768		function buttonClose(){
769			global.openObj.style.display = 'none';
770			returnTo.focus();
771			//reset listener and object trapping focus
772			closeButton.removeEventListener( 'click', buttonClose, false );
773			//on retire la  classe du body
774			document.body.classList.remove(userPrefix+'-'+config.BodyActive.classSetting);
775			var overlay = document.querySelector( '.'+userPrefix+'-'+config.Overlay.classSetting  );
776			if(overlay){
777				overlay.remove();
778			}
779			//reset object trapping focus
780			//global.openObj = null
781		}
782	}
783	/* Generic trapping focus function (based on global.openObj setting) */
784	function trappingFocus( event ){
785		if ( global.openObj && !global.openObj.contains( event.target ) ) {
786			event.stopPropagation();
787			global.openObj.focus();
788		}
789	}
790
791	/**
792		Cookies
793	**/
794	function createCookie( name, value, days ) {
795		if ( days ) {
796			var datetime = new Date();
797			datetime.setTime( datetime.getTime() + ( days * 24 * 60 * 60 * 1000 ) );
798			var expires = "; expires=" + datetime.toGMTString();
799		}
800		else var expires = "";
801		document.cookie = name + "=" + value + expires + "; path=/";
802	}
803	function readCookie( name ) {
804		var nameEQ = userPrefix+'-'+name + "=";
805		var ca = document.cookie.split( ';' );
806		for(var i = 0; i < ca.length; i++ ) {
807			var c = ca[i];
808			while ( c.charAt(0) == ' ' ) c = c.substring( 1, c.length );
809			if ( c.indexOf( nameEQ ) == 0 ) return c.substring( nameEQ.length, c.length );
810		}
811		return null;
812	}
813	function eraseCookie( name ) {
814		createCookie( name , "", -1 );
815	}
816} )();
817
818//Polyfill pour la méthode remove non disponible dans InternetExplorer
819//Credit : https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
820
821(function (arr) {
822  arr.forEach(function (item) {
823    if (item.hasOwnProperty('remove')) {
824      return;
825    }
826    Object.defineProperty(item, 'remove', {
827      configurable: true,
828      enumerable: true,
829      writable: true,
830      value: function remove() {
831        if (this.parentNode !== null)
832          this.parentNode.removeChild(this);
833      }
834    });
835  });
836})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

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.