PageSourceSearch

https://www.solidarites.org/fr/wp-content/plugins/cyres-shortcodes…/assets/js/scripts.js?ver=a144a119

js solidarites.org collected 2026-10-02 03:34:54 UTC 11,432 bytes, 311 lines download raw bytes

1// Position world map info window
2function positionInfoWindows( worldMap ) {
3
4    // Déclencher la fonction seulement si la carte est visible
5    if ( $('.col-left').is(':visible') === true || $('#world-map-missions').is(':visible') === true ) {
6
7        /**
8         * Au clic sur un pays activé, afficher l'infobulle
9         * Pour cela, on doit positionner celle-ci juste au-dessus de son pays (ou au-dessous si pas assez de place).
10         *
11         * LE PROBLEME :
12         * Le svg est responsive, il est transformé par les attributs "viewBox" et "preserveAspectRatio", ainsi la carte
13         * ne dépasse pas du conteneur.
14         * Hors, quand on récupère les coordonnées et dimensions des pays, on obtient les résultats avant transformation.
15         * Il faut donc tout convertir en fonction du ratio entre le svg à taille réelle et le svg transformé.
16         */
17
18        // Calculate ratio
19        var svgWidthInit = parseInt(document.getElementById('svg-world').getBBox().width),
20            svgWidthTransform = parseInt($('#svg-world').width()),
21            ratio = svgWidthTransform / svgWidthInit;
22
23        worldMap.find('path.has-mission').each(function () {
24
25            var countryId = $(this).attr('id');
26            countryId = countryId.substr(8, countryId.length);
27
28            // Get country coordinates
29            var countryCoordinates = $(this)[0].getBBox(),
30                countryW = parseInt(countryCoordinates.width * ratio),
31                countryH = parseInt(countryCoordinates.height * ratio),
32                countryY = parseInt(countryCoordinates.y * ratio),
33                countryX = parseInt(countryCoordinates.x * ratio);
34
35            // Info window
36            var iw = $('#iw-' + countryId);
37
38            // Hide the window: visibility hidden, not display none because it causes a bug with getBBox on Firefox
39            iw.removeClass('hidden').addClass('invisible');
40
41            // Get info window width and height, in order to position them depending on the country coordinates
42            var iwW = iw.width(),
43                iwH = iw.outerHeight() + 6;
44
45            // Place the info window above the country
46            if (iwH <= countryY - 6) {
47                iw.css('top', (countryY - 6 - iwH) + 'px')
48                    .removeClass('iw-bottom')
49                    .addClass('iw-top');
50            }
51            // Place the info window below the country
52            else {
53                iw.css('top', (countryY + countryH + 6) + 'px')
54                    .removeClass('iw-top')
55                    .addClass('iw-bottom');
56            }
57
58            // Place the info window horizontally
59            var iwX = countryX + (countryW / 2) - (iwW / 2);
60            if (iwX < 0) {
61                iwX = 0;
62            } else if (iwX + iwW > svgWidthTransform) {
63                iwX = svgWidthTransform - iwW;
64            }
65            iw.css('left', iwX + 'px');
66
67            // Hide the window for real
68            iw.addClass('hidden').removeClass('invisible');
69        });
70    }
71}
72
73// Display world map info windows
74function displayInfoWindows( worldMap ) {
75
76    worldMap.on( 'click', 'path.has-mission.active', function() {
77
78        var id = $(this).attr('id');
79        id = id.substr(8, id.length);
80
81        var iw = $('#iw-' + id),
82            missionList = $('#missions-left-menu');
83
84        // If click to display
85        if ($(this).attr('class') === 'country has-mission active') {
86
87            // Feature the country in the list in the left column if we are on the "Dans le monde" page
88            if (missionList.length) {
89                missionList.find('li').removeClass('click');
90                missionList.find('li[data-country="' + id + '"]').addClass('click');
91            }
92
93            // Hide the displayed country and info window
94            var clickedCountry = worldMap.find('path.click');
95            if (clickedCountry.length > 0) {
96
97                var clickedCountryId = clickedCountry.attr('id');
98                clickedCountryId = clickedCountryId.substr(8, clickedCountryId.length);
99
100                $('#iw-' + clickedCountryId).addClass('hidden');
101                clickedCountry.attr('class', 'country has-mission active');
102            }
103
104            // Show the new country and info window
105            $(this).attr('class', 'country has-mission active click');
106            iw.removeClass('hidden');
107        }
108
109        // If click to close
110        else {
111
112            // Remove the featured state in the country list in the left column
113            if (missionList.length) {
114                missionList.find('li').removeClass('click');
115            }
116
117            // Hide the infowindow
118            $(this).attr('class', 'country has-mission active');
119            iw.addClass('hidden');
120        }
121    });
122}
123
124// Handle mission status
125function handleMissionStatus( worldMap ) {
126
127    var buttons = worldMap.parent().find('.widget-title-missions a');
128    buttons.click(function(e) {
129
130        e.preventDefault();
131
132        // If the button is inactive
133        if (!$(this).hasClass('active')) {
134
135            // Activate it and inactive the other button
136            buttons.removeClass('active');
137            $(this).addClass('active');
138
139            // Hide the infowindows
140            $('.iw').addClass('hidden');
141
142            // Get the status
143            var status = $(this).attr('id');
144
145            // Change the list on the left column and remove the featured state
146            var missionList = $('#missions-left-menu');
147            missionList.find('li').removeClass('active click');
148            missionList.find('li[data-status="' + status + '"]').addClass('active');
149
150            // Change the countries displayed on the map
151            var map = $('#svg-world');
152            map.find('path.active').attr('class', 'country has-mission');
153            map.find('path[data-status="' + status + '"]').attr('class', 'country has-mission active');
154        }
155    });
156}
157
158// Hover country on the map if it is hovered in the list in the left column and vice versa
159function hoverCountry() {
160
161    var missionList = $('#missions-left-menu'),
162        map = $('#svg-world');
163
164    if (map.length && missionList.length) {
165
166        // Hover the list
167        missionList.find('a').hover(
168            function() {
169                map.find('path[data-hover]').removeAttr('data-hover');
170                map.find('path#country-' + $(this).parent().attr('data-country')).attr('data-hover', '');
171            },
172            function() {
173                map.find('path#country-' + $(this).parent().attr('data-country')).removeAttr('data-hover');
174            }
175        );
176
177        // Hover the countries on the map
178        map.find('path.has-mission').hover(
179            function() {
180                var country_id = $(this).attr('id');
181                country_id = country_id.substr(8, country_id.length);
182                missionList.find('li[data-country="' + country_id + '"] a').addClass('hover');
183            },
184            function() {
185                var country_id = $(this).attr('id');
186                country_id = country_id.substr(8, country_id.length);
187                missionList.find('li[data-country="' + country_id + '"] a').removeClass('hover');
188            }
189        );
190    }
191}
192
193jQuery(document).ready(function($) {
194    'use strict';
195
196    // Dons en action
197    $('.donation-list').each(function() {
198        $(this).addClass('desktop')
199            .clone().removeClass('desktop').addClass('mobile').insertAfter($(this));
200    });
201    var donationListMobile = $('.donation-list.mobile');
202    if (donationListMobile.find('.don').length > 1) {
203        donationListMobile.owlCarousel({
204            autoPlay: true,
205            itemsCustom: [
206                [0, 1],
207                [700, 2]
208            ]
209        });
210    }
211
212    // Carousel chiffres clés sur la page "Mandat humanitaire"
213    var carouselChiffresCles = $('.mandat-chiffres-cles.mobile');
214    if (carouselChiffresCles.length) {
215        carouselChiffresCles.owlCarousel({
216            autoPlay: true,
217            navigation: false,
218            pagination: true,
219            itemsCustom: [
220                [0, 1],
221                [600, 2],
222                [900, 3]
223            ]
224        });
225    }
226
227    // Mission chiffres clés : affichage mobile des actus mission : déplacer le bloc "Chiffres clé" sous le contenu
228    var chiffresCle = $('.single-post .mission-figures-container');
229    if (chiffresCle.length) {
230        var chiffresCleCopy = '' +
231            '<div class="vc_row wpb_row vc_row-fluid mission-figures-container-mobile">' +
232            '   <div class="vc_col-xs-12">' +
233            '       <div class="container">' +
234            '           <div class="row">' +
235            '               <div class="wpb_column vc_col-sm-12">' +
236            '                   <div class="vc_column-inner">' +
237            '                       <div class="wpb_wrapper">' +
238            '                            <div class="mission-figures-container v-mobile">' + chiffresCle.html() + '</div>' +
239            '                       </div>' +
240            '                   </div>' +
241            '               </div>' +
242            '           </div>' +
243            '       </div>' +
244            '   </div>' +
245            '</div>';
246        $('.post-content').append(chiffresCleCopy);
247    }
248
249    // Posts association / adhérents -> carousel
250    $('.association-news .lfp-container').each(function() {
251        $(this).owlCarousel({
252            autoPlay: true,
253            navigation: false,
254            pagination: false,
255            itemsCustom: [
256                [0, 1],
257                [600, 2],
258                [900, 3],
259                [1200, 4]
260            ]
261        });
262    });
263
264    // Posts featured -> carousel
265    $('.featured-news .lfp-container').each(function() {
266        $(this).owlCarousel({
267            singleItem: true,
268            navigation: true,
269            navigationText: ['&lt;', '&gt;']
270        });
271    });
272
273    // Press and publications
274    $('.publications-container').each(function() {
275        $(this).owlCarousel({
276            autoPlay: true,
277            navigation: false,
278            itemsCustom: [
279                [0, 1],
280                [600, 2],
281                [900, 3],
282                [1200, 4]
283            ]
284        })
285    });
286
287    // World map home
288    var worldMap = $('#world-map');
289    if (worldMap.length) {
290        positionInfoWindows( worldMap );
291        displayInfoWindows( worldMap );
292        $(window).resize(function() {
293            positionInfoWindows( worldMap );
294        });
295        $('#missions-current, #missions-previous').change(function() {
296            window.location = $(this).val();
297        });
298    }
299
300    // World map in int pages
301    var worldMapMissions = $('#world-map-missions');
302    if (worldMapMissions.length) {
303        positionInfoWindows( worldMapMissions );
304        displayInfoWindows( worldMapMissions );
305        handleMissionStatus( worldMapMissions );
306        hoverCountry();
307        $(window).resize(function() {
308            positionInfoWindows( worldMapMissions );
309        });
310    }
311});

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.