PageSourceSearch

https://www.ville-goussainville.fr/include/js/core.js.php

js ville-goussainville.fr collected 2026-10-02 18:38:17 UTC 19,804 bytes, 477 lines download raw bytes

1
2var cmsCore = {
3
4    mobile: 767, /* surchargeable localement */
5    tablet: 1024, /* surchargeable localement */
6
7    init: function () {
8        'use strict';
9
10        // gestion title lien externe/document
11        $(' a.external, a.document').each(function () {
12            var title = $(this).attr('title');
13            if (title === undefined) {
14                title = $(this).clone();
15                $('[aria-hidden="true"]', title).remove();
16                title = title.text().trim();
17                if (title === '') {
18                    var $img = $('img', $(this));
19                    if ($img.length) {
20                        title = $img.attr('alt').trim();
21                    }
22                }
23            }
24            if (title !== '') {
25                if ($(this).hasClass('external')) {
26                    title += ' (nouvelle fenêtre)';
27                } else if ($(this).data('file_ext') !== undefined) {
28                    title += ' (' + $(this).data('file_ext');
29                    if ($(this).data('file_weight') !== undefined) {
30                        title += ' - ' + $(this).data('file_weight');
31                    }
32                    title += ')';
33                }
34                $(this).attr('title', title.replace(/\s+/g, ' '));
35            }
36        });
37
38        // Toggle ARIA
39        $('.aria-toggle').on('click', function (e) {
40            var $button = $(this);
41            var $target = $('#' + $button.attr('aria-controls'));
42            if ($button.attr('aria-expanded') === 'true') {
43                // on ferme
44                $target.attr('aria-hidden', 'true').slideUp().off('keydown.aria.' + $button.attr('id'));
45                $button.attr('aria-expanded', 'false');
46                $('body').off('click.aria.' + $button.attr('id'));
47            } else {
48                // on ouvre
49                $target.removeAttr('aria-hidden').slideDown();
50                $button.attr('aria-expanded', 'true');
51                // on focus
52                $target.trigger('focus');
53                if (!$target.is(':focus')) {
54                    $target.attr('tabindex', '-1');
55                    $target.trigger('focus');
56                }
57                // echappe
58                $target.on('keydown.aria.' + $button.attr('id'), function (ev) {
59                    if (ev.which === 27) {
60                        $button.trigger('click', [true]);
61                        $button.trigger('focus');
62                    }
63                });
64                // clic en dehors
65                $('body').on('click.aria.' + $button.attr('id'), function (ev, triggered) {
66                    if (!triggered && !$(ev.target).closest($button).length && !$(ev.target).closest($target).length) {
67                        $button.trigger('click', [true]);
68                    }
69                });
70            }
71            e.preventDefault();
72        });
73        $('.aria-close').on('click', function (e) {
74            $('#' + $(this).attr('aria-controls')).trigger('click', [true]);
75            e.preventDefault();
76        });
77
78        // Défilement progessif au clic sur une ancre
79        $(document).on('click', "a[href^='#']", function (e) {
80            if (!$(this).hasClass('noScroll')) {
81                var href = $(this).attr('href');
82                if (href !== '#' && $(href).length) {
83                    cmsCore.scroll($(href));
84                    e.preventDefault();
85                    return false;
86                }
87            }
88            return true;
89        });
90
91        //colorbox
92        if ($('a.lightbox').length && $.fn.colorbox) {
93            $('a.lightbox').colorbox({
94                title: function () {
95                    return $(this).data('title') !== '' ? $(this).data('title') : ' ';
96                },
97                onComplete: function () {
98                    var alt = '';
99                    if ($('img', this).attr('alt') !== $(this).data('title') && $('img', this).attr('alt') !== '') {
100                        alt = $('img', this).attr('alt');
101                    }
102                    $('.cboxPhoto').attr('alt', alt);
103                },
104                maxWidth: '95%',
105                maxHeight: '95%'
106            });
107        }
108
109        // credit image
110        $('.spanCredit').hide();
111        $('.spanImgOuter').attr('tabindex', 0)
112            .on('mouseenter focus', function () {
113                $('.spanCredit', this).fadeIn();
114            })
115            .on('mouseleave blur', function () {
116                $('.spanCredit', this).fadeOut();
117            });
118
119        // Traitement rédactionnel
120        $(".txt table:not('.tableNotResponsive'), .partage table:not('.tableNotResponsive'), .tpl table:not('.tableNotResponsive')").wrap('<div class="tableauContainer"/>');
121
122        // Lien d'évitement
123        $('#lienEvitement').find('a')
124            .on('focus', function () {
125                $(this).closest('#lienEvitement').addClass('focus');
126            })
127            .on('blur', function () {
128                $(this).closest('#lienEvitement').removeClass('focus');
129            })
130            .on('click', function () {
131                if ($(this).hasClass('triggerClick')) {
132                    if ($(this).data('controls')) {
133                        var $e = $('#' + $(this).data('controls'));
134                        if ($e.is(':visible')) {
135                            $e.trigger('click', [true]);
136                            return false;
137                        }
138                    } else {
139                        $($(this).attr('href')).trigger('click', [true]);
140                        return false;
141                    }
142                }
143                return true;
144            });
145
146        // Haut de page sticky
147        var $hautDePage = $('#hautDePage');
148        $hautDePage.hide();
149
150        var scrollTimeout;
151        $(window).on('scroll', function () {
152            clearTimeout(scrollTimeout);
153            scrollTimeout = setTimeout(function() {
154                if ($(window).scrollTop() > 1) {
155                    $hautDePage.show(400);
156                } else {
157                    $hautDePage.hide(400);
158                }
159            }, 100);
160        });
161
162        // Google tracker pour les liens document + externe
163        $(document).on('click', 'a.document', function () {
164            window.open(this.href);
165            return false;
166        });
167        $(document).on('click', 'a.external', function () {
168            window.open(this.href);
169            return false;
170        });
171
172        //gestion nb caractère max
173        $('textarea[data-maxchar], input[data-maxchar]')
174            .each(function () {
175                $(this).attr('aria-describedby', $(this).attr('id') + '_max');
176                $(this).after('<span class="counter" id="' + $(this).attr('id') + '_max' + '"></span>');
177            })
178            .on('keyup input', function () {
179                var $span = $(this).nextAll('span.counter');
180                $span.html('Nombre de caractères : ' + $(this).val().length + ' / ' + $(this).data('maxchar'));
181                if ($(this).val().length > $(this).data('maxchar')) {
182                    $span.css('color', 'red');
183                } else {
184                    $span.css('color', '');
185                }
186            })
187            .trigger('keyup');
188
189        //confirm
190        $(document).on('click', '.confirm', function () {
191            var str = 'Êtes-vous sûr';
192            if ($(this).attr('title') !== undefined && $(this).attr('title') !== '') {
193                str += ' de vouloir\n"' + $(this).attr('title') + '"';
194            }
195            str += ' ?';
196            return confirm(str);
197        });
198
199        // gestion CB required
200        $('div[data-required-cb], span[data-required-cb]').each(function () {
201            var $cCB = $('input[type="checkbox"]', $(this));
202            var nb = $(this).data('required-cb');
203            $cCB.on('change', function () {
204                if ($cCB.filter(':checked').length >= nb) {
205                    $cCB.each(function () {
206                        this.setCustomValidity('');
207                        $(this).prop('required', false);
208                    });
209                } else {
210                    $cCB.filter(':not(:checked)').each(function () {
211                        this.setCustomValidity('Veuillez cocher au moins ' + nb + ' option(s)');
212                    });
213
214                }
215            });
216            if ($cCB.filter(':checked').length < $(this).data('required-cb')) {
217                $cCB.filter(':not(:checked)').prop('required', true);
218            }
219        });
220
221        //type d'input
222                $.datepicker.setDefaults($.datepicker.regional["fr"]);
223        $('input[data-type="date"]')
224                        .attr('placeholder', 'jj/mm/aaaa')
225            .attr('title', 'Format attendu : jj/mm/aaaa')
226            .attr('pattern', '^(((0[1-9]|[12]\\d|3[01])/(0[13578]|1[02])/((19|[2-9]\\d)\\d{2}))|((0[1-9]|[12]\\d|30)/(0[13456789]|1[012])/((19|[2-9]\\d)\\d{2}))|((0[1-9]|1\\d|2[0-8])/02/((19|[2-9]\\d)\\d{2}))|(29/02/((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))))$')
227                        .attr('maxlength', '10')
228            .not('.noCalendar')
229            .datepicker({
230                changeMonth: true,
231                changeYear: true
232            });
233        $('input[data-type="telephone"]')
234            .attr('pattern', '^0[1-9][0-9]{8}$')
235            .attr('title', 'Format attendu : numéro sur 10 chiffres sans espace');
236        $('input[data-type="telephoneInternational"]')
237            .attr('pattern', '/^\+\d{0,16}$')
238            .attr('title', 'Format attendu : numéro de téléphone format international +[indicatif sur 1 à 4 chiffres][numéro format national sans le 0] sans espace');
239        $('input[data-type="integer"]')
240            .attr('pattern', '^[0-9]*$')
241            .attr('title', 'Format attendu : nombre entier')
242            .addClass('alignright');
243        $('input[data-type="float"]')
244            .attr('pattern', '^[0-9]*\.?[0-9]*$')
245            .attr('title', 'Format attendu : nombre décimal')
246            .addClass('alignright');
247        //gestion de l'étoile
248        $('input[required], select[required], textarea[required]').not('input:checkbox, input:radio')
249            .each(function () {
250                $('label[for="' + $(this).attr('id') + '"]', $(this).closest('form')).append(' <span class="obligatoire">*</span>');
251            });
252        $('input[required][type="checkbox"], input[required][type="radio"], div[data-required-cb], span[data-required-cb]').closest('p').find('label:first').append(' <span class="obligatoire">*</span>');
253        //formatage virgule flottante
254        $(document).on('keyup', 'input[data-type="float"]', function () {
255            $(this).val($(this).val().replace(/,/, '.'));
256        });
257        //formatage espace sur nombre
258        $(document).on('keyup', 'input[data-type="float"], input[data-type="integer"]', function () {
259            $(this).val($(this).val().replace(/\s/, ''));
260        });
261        //formatage caractère sur téléphone
262        $(document).on('keyup', 'input[data-type="telephone"]', function () {
263            $(this).val($(this).val().replace(/\D/, ''));
264        });
265        //formatage caractère sur téléphone format international
266        $(document).on('keyup', 'input[data-type="telephoneInternational"]', function () {
267            $(this).val($(this).val().replace(/[^+,\d]/gm, ''));
268        });
269
270        // Lecteur audio multi HTML5
271        (function () {
272            var current = 0;
273            var autoplay = true;
274
275            // Pour chaque lecteur
276            $('.audioPlayerMulti').each(function (i, player) {
277                player = $(player);
278                var audio = player.find('audio');
279                var playlist = player.find('.playlist');
280                var tracks = playlist.find('li a');
281
282                // Première piste active
283                tracks.eq(0).parent().addClass('active');
284
285                // Choix des pistes
286                tracks.click(function (e) {
287                    var $track = $(this);
288                    var li = $track.parent();
289
290                    e.preventDefault();
291
292                    // Remplacement des sources
293                    audio.find('source').remove();
294                    var audioProperties = $track.data('audioProperties');
295                    audio.append('<source type="audio/mp3" src="' + $track.attr('href') + '">');
296                    if (audioProperties[0].srcOgg) {
297                        audio.append('<source type="audio/ogg" src="' + audioProperties[0].srcOgg + '">');
298                    }
299                    // Remplacement de l'alternative HTML
300                    audio.children('.htmlAlternative').html(audioProperties[0].htmlAlternative);
301
302                    // Changement de la piste active
303                    li.addClass('active').siblings().removeClass('active');
304
305                    // Reload et lecture de la piste
306                    audio[0].load();
307                    audio[0].play();
308
309                    // Nouvelle piste en cours
310                    current = li.index();
311                });
312
313                // Piste suivante
314                audio.on('ended', function () {
315                    if (autoplay) {
316                        current = current >= tracks.length - 1 ? 0 : current + 1;
317                        tracks.eq(current).trigger('click');
318                    }
319                });
320            });
321        })();
322    },
323    scroll: function ($idtf, delta) {
324        if ($idtf.length > 0) {
325            if (!delta) {
326                delta = 0;
327            }
328            $('html, body').animate({scrollTop: $idtf.offset().top + delta}, 'slow');
329            $idtf.trigger('focus');
330            if (!$idtf.is(':focus')) {
331                $idtf.attr('tabindex', '-1');
332                $idtf.trigger('focus');
333            }
334        }
335    }
336};
337$(cmsCore.init);
338
339//legende image, Doit être executé après le chargement des images
340$(window).on('load', function () {
341    'use strict';
342    $('.spanImgContainer').width(function () {
343        var $img = $('.spanImgOuter img', $(this)).outerWidth();
344        var $parent = $(this).closest('.innerParagraphe').width();
345        if ($img > $parent) {
346            return $parent;
347        }
348        return $img;
349    });
350});
351
352/*
353 * PRISE EN CHARGE DES BULLES D'AIDE SUR LES FORMULAIRES
354 * jQuery accessible simple (non-modal) tooltip window, using ARIA
355 * Adaptation de https://a11y.nicolas-hoffmann.net/simple-tooltip/
356 * License MIT: https://github.com/nico3333fr/jquery-accessible-simple-tooltip-aria/blob/master/LICENSE
357 */
358(function () {
359
360    'use strict';
361
362    /*
363     * jQuery accessible simple (non-modal) tooltip window, using ARIA
364     * @version v2.2.0
365     * Website: https://a11y.nicolas-hoffmann.net/simple-tooltip/
366     * License MIT: https://github.com/nico3333fr/jquery-accessible-simple-tooltip-aria/blob/master/LICENSE
367     */
368
369    function accessibleSimpleTooltipAria(options) {
370        var element = $(this);
371        options = options || element.data();
372        var text = options.simpletooltipText || '';
373        var prefix_class = typeof options.simpletooltipPrefixClass !== 'undefined' ? options.simpletooltipPrefixClass + '-' : '';
374        var content_id = typeof options.simpletooltipContentId !== 'undefined' ? '#' + options.simpletooltipContentId : '';
375
376        var index_lisible = Math.random().toString(32).slice(2, 12);
377        var aria_describedby = element.attr('aria-describedby') || '';
378
379        element.attr({
380            'aria-describedby': 'label_simpletooltip_' + index_lisible + ' ' + aria_describedby
381        });
382
383        if (element.parents('label').attr('for')) {
384            var $field = $('#' + $(this).parents('label').attr('for'));
385            var helper_id = element.attr('id') ? element.attr('id') : 'helper_' + index_lisible;
386            element.attr('id', helper_id);
387            var aria_describedby = $field.attr('aria-describedby') || '';
388            $field.attr({
389                'aria-describedby': element.attr('id') + ' ' + aria_describedby
390            });
391        }
392
393        element.wrap('<span class="' + prefix_class + 'simpletooltip_container"></span>');
394
395        var html = '<span class="js-simpletooltip ' + prefix_class + 'simpletooltip" id="label_simpletooltip_' + index_lisible + '" role="tooltip" aria-hidden="true">';
396
397        if (text !== '') {
398            html += '' + text + '';
399        } else {
400            var $contentId = $(content_id);
401            if (content_id !== '' && $contentId.length) {
402                html += $contentId.html();
403            }
404        }
405        html += '</span>';
406
407        $(html).insertAfter(element);
408    }
409
410    // Bind as a jQuery plugin
411    $.fn.accessibleSimpleTooltipAria = accessibleSimpleTooltipAria;
412
413    $(function () {
414        $('.helper').each(function () {
415            var map = {
416                '&': '&amp;',
417                "'": '&#39;',
418                '"': '&quot;',
419                '<': '&lt;',
420                '>': '&gt;'
421            };
422            $(this).replaceWith('<span tabindex="0" class="js-simple-tooltip helper" data-simpletooltip-text="' + $(this).html().replace(/[&"'\<\>]/g, function (c) {
423                return map[c];
424            }) + '"><img src="' + SIT_IMAGE + 'tooltip.png" alt="Aide contextuelle"></span>');
425        });
426        $('.js-simple-tooltip')
427            .each(function () {
428                // Call the function with this as the current tooltip
429                accessibleSimpleTooltipAria.apply(this);
430            });
431
432        // events ------------------
433        $('body')
434            .on('mouseenter focusin', '.js-simple-tooltip', function () {
435                var $this = $(this);
436                var aria_describedby = $this.attr('aria-describedby');
437                var tooltip_to_show_id = aria_describedby.substr(0, aria_describedby.indexOf(" "));
438                var $tooltip_to_show = $('#' + tooltip_to_show_id);
439                $tooltip_to_show.attr('aria-hidden', 'false');
440            })
441            .on('mouseleave', '.js-simple-tooltip', function (event) {
442                var $this = $(this);
443                var aria_describedby = $this.attr('aria-describedby');
444                var tooltip_to_show_id = aria_describedby.substr(0, aria_describedby.indexOf(" "));
445                var $tooltip_to_show = $('#' + tooltip_to_show_id);
446                var $is_target_hovered = $tooltip_to_show.is(':hover');
447
448                if (!$is_target_hovered) {
449                    $tooltip_to_show.attr('aria-hidden', 'true');
450                }
451            })
452            .on('focusout', '.js-simple-tooltip', function (event) {
453                var $this = $(this);
454                var aria_describedby = $this.attr('aria-describedby');
455                var tooltip_to_show_id = aria_describedby.substr(0, aria_describedby.indexOf(" "));
456                var $tooltip_to_show = $('#' + tooltip_to_show_id);
457
458                $tooltip_to_show.attr('aria-hidden', 'true');
459            })
460            .on('mouseleave', '.js-simpletooltip', function () {
461                var $this = $(this);
462                $this.attr('aria-hidden', 'true');
463            })
464            .on('keydown', '.js-simple-tooltip', function (event) {
465                // close esc key
466
467                var $this = $(this);
468                var aria_describedby = $this.attr('aria-describedby');
469                var tooltip_to_show_id = aria_describedby.substr(0, aria_describedby.indexOf(" "));
470                var $tooltip_to_show = $('#' + tooltip_to_show_id);
471
472                if (event.keyCode == 27) { // esc
473                    $tooltip_to_show.attr('aria-hidden', 'true');
474                }
475            });
476    });
477})();

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.