PageSourceSearch

https://www.sun7.re/wp-content/themes/blankslate/assets/js/charte.js

js sun7.re collected 2026-10-04 18:45:47 UTC 6,669 bytes, 188 lines download raw bytes

1$(function(){
2    dataCatalogueURL();
3    const animateOnce = true;
4    let animateNodes = $('[data-animate]');
5    $(animateNodes).removeClass('animate__animated');
6    $(animateNodes).on('inview', function (event, isInView){
7        let animation = $(this).attr('data-animate');
8        if(isInView) $(this).addClass('animate__animated').addClass(animation);
9        else if(!animateOnce && $(this).hasClass('animate__animated')) $(this).removeClass('animate__animated').removeClass(animation);
10    });
11    /*loadMap();*/
12    expandableObject();
13    cookiesProcess();
14});
15
16/**
17 * G�re les syst�me accordeon
18 * @param {HTMLElement} item  : Objet concern�
19 */
20let tabProcessor = function (item){
21    const hSelector = $(item).attr('data-header');
22    const bSelector = $(item).attr('data-body');
23    const hClickSelector = $(item).attr('data-click');
24
25    if(hSelector != undefined && bSelector != undefined){
26        const header = $(item).find(hSelector);
27        const body = $(item).find(bSelector);
28        let cta = header;
29
30        let expandFunction = () => {
31            $(item).toggleClass('expanded');
32            applyHeight();
33        };
34
35        let applyHeight = function (){
36            let hHeight = $(header).outerHeight();
37            let bHeight = $(body).outerHeight();
38            let objectHeight = hHeight + bHeight;
39
40            if($(item).hasClass('expanded')) $(item).height(objectHeight);
41            else $(item).height(hHeight);
42        };
43
44        if(hClickSelector != undefined) cta = $(item).find(hClickSelector);
45        $(cta).click(() => expandFunction());
46        applyHeight();
47        $(window).resize(() => applyHeight());
48    }
49};
50
51/**
52 *  Initialisation des carte Google Maps
53 */
54let loadMap = function (){
55    if($('[data-map]').length > 0){
56        const zoom = 13;
57
58        /* Chargement du script de Google Maps */
59        let s = document.createElement("script");
60        s.type = "text/javascript";
61        s.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB_HX85mT7Yy8yFSrbVPaRMyWsXNjykqPU";
62        $("head").append(s);
63
64        /* Pr�paration des donn�es de chaque carte */
65        setTimeout(() => {
66            $('[data-map]').each(function (){
67                const lat = $(this).data('latitude');
68                const long = $(this).data('longitude');
69                const infoCenter = document.createElement('div');
70                const infoCenterTitle = document.createElement('h4');
71                const infoCenterAddress = document.createElement('div');
72
73                infoCenter.classList.add('infocenter-block');
74                infoCenterTitle.innerHTML = $(this).data('title');
75                infoCenterAddress.classList.add('address');
76                infoCenterAddress.innerHTML = $(this).parents('.shop-item').find('.address').html();
77                infoCenter.append(infoCenterTitle, infoCenterAddress);
78
79                initMap(this, lat, long, zoom, infoCenter);
80            });
81        }, 1000);
82    }
83}
84
85/**
86 * Chargement les cartes Google Maps
87 * @param {HTMLElement} wrapper : Conteneur du parent. Objet dans lequel la carte sera ajout�e
88 * @param {string} latitude : Latitude
89 * @param {string} longitude : Longitude
90 * @param {string} zoom : Niveau du zoom � appliquer
91 * @param {HTMLElement} infocenter : (optionnel) Donn�es � afficher lors du clique sur le pin de la map
92 */
93function initMap(wrapper, latitude, longitude, zoom = 19, infocenter = null) {
94    let infowindow = null
95    var mapOptions = {
96        zoom: zoom,
97        center: new google.maps.LatLng(latitude, longitude),
98    };
99
100    if(infocenter != null) {
101        infowindow = new google.maps.InfoWindow({
102            content: infocenter,
103        });
104    }
105
106    var map = new google.maps.Map(wrapper, mapOptions);
107    var marker = new google.maps.Marker({
108        position: new google.maps.LatLng(latitude, longitude),
109        map: map
110    });
111
112    if(infocenter != null) {
113        marker.addListener("click", () => {
114            infowindow.open({
115                anchor: marker,
116                map,
117            });
118        });
119    }
120};
121
122/**
123 * Contourne un bug Elementor. Lorsqu'on met un PDF en href d'un bouton ou d'un lien,
124 * On a une erreur 403 au moment de l'enregistrement.
125 */
126function dataCatalogueURL(){
127   $('[data-catalogue-url]').each(function (){
128       let url = $(this).attr('data-catalogue-url');
129       $(this).attr('href', url+'.pdf');
130   });
131}
132
133/**
134 * Gestion des objets extensibles
135 */
136function expandableObject(closeOther = false){
137    const className = "expand";
138    $('[data-expandable]').each(function (){
139        let obj = $(this);
140        let header = $(obj).data('header');
141        let body = $(obj).data('body');
142
143        console.log(header);
144        console.log(body);
145
146        $(obj).find(header).css('cursor', 'pointer');
147        $(this).find(header).off('click');
148        $(this).find(header).click(function (){
149            console.log('test');
150            if(closeOther){
151                $(obj).parent().find('[data-expandable]').removeClass(className);
152                $(obj).addClass(className);
153                $(obj).parent().find('[data-expandable]').each(function (){
154                    calculateExpandableHeight(this, $(this).data('header'), $(this).data('body'));
155                });
156            } else {
157                $(obj).toggleClass(className);
158                calculateExpandableHeight($(obj), header, body);
159            }
160        });
161        $(window).resize(() => calculateExpandableHeight($(obj), header, body) );
162        calculateExpandableHeight($(obj), header, body);
163    });
164}
165
166/**
167 * Calcule et applique les hauteurs des objets expandable en fonction de leur status
168 * @param item: Objet concern�
169 * @param header: S�lecteur du header de l'objet (d�clencheur)
170 * @param body: S�lecteur de body de l'objet (contenu � afficher ou non)
171 */
172function calculateExpandableHeight(item, header, body){
173    let headerH = $(item).find(header).outerHeight();
174    if(!$(item).hasClass('expand')) $(item).css('max-height', headerH);
175    else $(item).css('max-height', ($(item).find(body).outerHeight() + parseInt($(item).css('padding-bottom')) + headerH));
176}
177
178function cookiesProcess(){
179    $('.cc-preferences').click(function (e){
180        e.preventDefault();
181        cc.showHidePoppin(true);
182        $(".cc-step-1").css('display', 'none');
183        $(".cc-step-2").css('display', 'flex');
184        cc.resizePoppin();
185
186        return false;
187    });
188}

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.