PageSourceSearch

https://www.neuchatelville.ch/typo3temp/assets/compressed/ElementA…5b1c9dab1e5b42fe3ed1c464217c1.js?1783607210

js neuchatelville.ch collected 2026-10-02 05:13:16 UTC 3,480 bytes, 98 lines download raw bytes

1/**
2 * Plugin pour la gestion du scroll vers un élément de contenu
3 */
4(function ($) {
5    $.ElementAnchorScroll = function (options) {
6        $.ElementAnchorScroll.opts = $.extend({}, $.ElementAnchorScroll.defaults, options);
7        var opts = $.ElementAnchorScroll.opts;
8
9        var windowWidth = $(window).width();
10
11        // Recherche la configuration correspondant à la largeur de l'écran
12        if (opts.responsive.length > 0) {
13            var breakpointSettings;
14
15            $.each(opts.responsive, function (index, configuration) {
16                if (windowWidth <= configuration.breakpoint) {
17                    breakpointSettings = configuration.settings;
18                }
19            });
20        }
21
22        if (typeof breakpointSettings == 'undefined') {
23            breakpointSettings = {
24                offsetTop: opts.offsetTop
25            };
26        }
27
28        $.ElementAnchorScroll.breakpointSettings = breakpointSettings;
29
30        // Click sur les liens ayant un ancre vers un élément
31        $('a[href*="#'+$.ElementAnchorScroll.opts.fakeAnchorPrefix+'"]').on('click', function () {
32            var linkPathname = $(this).attr("href").split("#")[0];
33            if(window.location.pathname == linkPathname) {
34                $.ElementAnchorScroll.scroll();
35                return false;
36            }
37        });
38
39        if(window.location.hash != '') {
40            $.ElementAnchorScroll.scroll();
41        }
42    };
43
44    /**
45     * Fonction pour "scroller" vers l'élément de contenu
46     */
47    $.ElementAnchorScroll.scroll = function () {
48        var hashValue = window.location.hash.split("#" + $.ElementAnchorScroll.opts.fakeAnchorPrefix)[1];
49
50        // Scroll uniquement si le hash utilise le même pattern que le plugin
51        if (hashValue != window.location.hash && false) {
52            var $contentElement = $("#" + $.ElementAnchorScroll.opts.validAnchorPrefix + hashValue);
53            $('html, body').animate({
54                scrollTop: $contentElement.offset().top - $.ElementAnchorScroll.breakpointSettings.offsetTop
55            }, $.ElementAnchorScroll.opts.animationTime, $.ElementAnchorScroll.opts.onScrollComplete($contentElement));
56        }
57    };
58
59    $.ElementAnchorScroll.defaults = {
60        // Préfix bidon de l'id de l'élément de contenu pour éviter de "trigger" le scroll natif vers l'élément de contenu
61        // #content-123
62        fakeAnchorPrefix: 'content-',
63        // Préfix valide de l'élément de contenu
64        // #c123
65        validAnchorPrefix: 'c',
66        offsetTop: 0,
67        // Temps d'animation du scroll
68        animationTime: 500,
69        // Fonction appelée une fois que le scroll a été effectué
70        onScrollComplete: function ($contentElement) {
71
72        },
73        // Configurations différente par rapport à la taille de l'écran
74        // La configuration est utilisé si la taille de l'écran est <= que le breakpoint
75        // ! Il est impératif que l'ordre des breakpoints soit ascendant !
76        responsive: [
77            {
78                breakpoint: 992,
79                settings: {
80                    offsetTop: 0
81                }
82            },
83            {
84                breakpoint: 768,
85                settings: {
86                    offsetTop: 0
87                }
88            },
89            {
90                breakpoint: 767,
91                settings: {
92                    offsetTop: 0
93                }
94            }
95        ]
96    };
97
98}(jQuery));

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.