PageSourceSearch

https://www.ccr.fr/wp-content/themes/neve-child/js/custom.js?ver=1.0

js ccr.fr collected 2026-10-01 12:05:14 UTC 10,518 bytes, 332 lines download raw bytes

1
2
3jQuery(document).ready(function($) {
4	
5	
6	/* --- Modification des tag du slider Publications --- */
7	$(".tag-slider-publication").each(function() {
8		var $el = $(this);
9		var text = $.trim($el.text().toLowerCase());
10		switch (text) {
11			// Case 1
12			case "# sciences":
13			case "# rapport scientifique":
14			case "# études climat":
15				$el.text("# Sciences")
16				   .css({
17					   "background-color": "#5496C2",
18					   "color": "#ffffff"
19				   });
20				break;
21			// Case 2
22			case "# cat nat":
23			case "# bilan cat nat":
24			case "# rapport au ministre":
25				$el.text("# CatNat")
26				   .css({
27					   "background-color": "#E8FF98",
28					   "color": "#002B3B"
29				   });
30				break;
31			// Case 3
32			case "# prévention":
33			case "# rapport national prévention":
34			case "# études ppri":
35			case "# rapports régionaux":
36				$el.text("# Prévention")
37				   .css({
38					   "background-color": "#9BB9BE",
39					   "color": "#002B3B"
40				   });
41				break;
42			// Case 4
43			case "# guide d’indemnisation":
44				$el.text("# Assurabilité")
45				   .css({
46					   "background-color": "#C76341",
47					   "color": "#ffffff"
48				   });
49				break;
50			// Case 5
51			case "# rapport d’activité":
52				$el.text("# Institutionnel")
53				   .css({
54					   "background-color": "#728961",
55					   "color": "#ffffff"
56				   });
57				break;
58			// Default
59			default:
60				$el.text("# Autres")
61				   .css({
62					   "background-color": "#2D515E",
63					   "color": "#ffffff"
64				   });
65		}
66	});
67
68	
69	/* --- Ajoute ... à la fin d'un trim */
70	jQuery(document).ready(function($) {
71		var max = 60;
72		$('.text-limit-60 p').each(function() {
73		var texte = $(this).text().trim();
74			if (texte.length > max) {
75			  $(this).text(texte.substring(0, max) + '...');
76			}
77		});
78	});
79	jQuery(document).ready(function($) {
80		var max = 60;
81		$('.text-limit-60 a').each(function() {
82		var texte = $(this).text().trim();
83			if (texte.length > max) {
84			  $(this).text(texte.substring(0, max) + '...');
85			}
86		});
87	});
88
89    $('#portailMenuToggle').click(function (){
90        //close menu principal
91        if ($('.menu-mobile-toggle').hasClass('is-active')) {
92            $('.menu-mobile-toggle').click();
93        }
94    });
95
96    $('.caret-wrap').click(function(){
97        var parentLi = $(this).parent().parent();
98        var submenu = parentLi.children('.sub-menu');
99        if ($(this).hasClass('dropdown-open')){
100            submenu.css('display','none')
101        }else {
102            submenu.css('display','block');
103        }
104    });
105
106    $('.menu-mobile >li>div>a>span.menu-item-title-wrap').click(function(e){
107
108        var parentDiv = $(this).parent().parent();
109        var parentLi = $(this).parent().parent().parent();
110        var block_btn = parentDiv.children('.caret-wrap');
111        var submenu = parentLi.children('.sub-menu');
112
113        if (block_btn.hasClass('dropdown-open')){
114            submenu.attr('style', 'display:none !important');
115        }else {
116            submenu.attr('style', 'display:block !important');
117        }
118    });
119    /* --- PAGE ACTIVITE, RENDRE TOUT LE BLOC CLICKABLE --- */
120    $(document).ready(function() {
121        $('a.lien-activite').each(function() {
122            const link = $(this).attr('href');
123            let newLink = "<a href='" + link + "' style='position: absolute; display: block; width:100%; height:100%; left:0; top:0; text-decoration: none; z-index:2;'></a>"
124            const clickableParent = $(this).closest('.parent-activite');
125            clickableParent.append(newLink);
126        });
127		$('h3.lien-activite a').each(function() {
128            const link = $(this).attr('href');
129            let newLink = "<a href='" + link + "' style='position: absolute; display: block; width:100%; height:100%; left:0; top:0; text-decoration: none; z-index:2;'></a>"
130            const clickableParent = $(this).closest('.parent-activite');
131            clickableParent.append(newLink);
132        });
133		$('div.event-card a').each(function() {
134            const link = $(this).attr('href');
135            let newLink = "<a href='" + link + "' style='position: absolute; display: block; width:100%; height:100%; left:0; top:0; text-decoration: none; z-index:2;'></a>"
136            const clickableParent = $(this).closest('.parent-activite');
137            clickableParent.append(newLink);
138		});
139    });
140  
141    /* PAGINATION POST */
142
143
144    /* --- SOUS MENU --- */
145    $('#menu-item-17320').on('click', function(e) {
146       // e.preventDefault();
147        var submenu = $('#menu-item-17320 > a').next('.sub-menu');
148
149        if (submenu.is(':visible')) {
150            submenu.slideUp(300);
151        } else {
152            submenu.slideDown(300);
153        }
154    });
155
156    /*$(document).on('click', function(e) {
157        var $trigger = $("#menu-item-17320");
158        if($trigger !== e.target && !$trigger.has(e.target).length){
159            $('.sub-menu').slideUp(300);
160        }
161    });
162    // CE CODE EST CONFLIT AVEC LE MENU
163     */
164
165
166    //$('#portailMenuContainer').appendTo('#header-grid');
167
168    // $('#portailCata').click(function () {
169    //     $('#portailMenuContainer').slideToggle();
170    //     var isExpanded = $(this).attr('aria-expanded') === 'true';
171    //     $(this).attr('aria-expanded', !isExpanded);
172    // });
173
174
175    function isMobile() {
176        return window.innerWidth < 992;
177    }
178
179    var mainMenu = $('.builder-item.has-nav');
180    var mainMenuItem = mainMenu.find('#menu-item-3453');
181
182    // Gestion du clic pour le menu principal
183    mainMenuItem.children('a').on('click', function(e) {
184        if (isMobile()) {
185            e.preventDefault();
186            var submenu = mainMenuItem.find('> .sub-menu');
187
188            if (submenu.is(':visible')) {
189                submenu.slideUp(300);
190            } else {
191                submenu.slideDown(300);
192            }
193        }
194    });
195
196    // Fermeture uniquement si le clic est hors des zones sensibles
197    $(document).on('click', function(e) {
198        if (isMobile()) {
199            var target = $(e.target);
200
201            // Ne ferme PAS si on clique dans :
202            if (
203                target.closest('#menu-item-3453').length || // notre sous-menu principal
204                target.closest('.builder-item.desktop-left').length || // ton autre menu onclick
205                target.closest('.modal-search').length // optionnel : modale si elle a une classe
206            ) {
207                return; // on ne fait rien
208            }
209
210            // Sinon on ferme le sous-menu principal
211            // mainMenu.find('.sub-menu').slideUp(300);
212        }
213    });
214
215
216    /* --- DEBUT MENU SELECT OPTION PERSONNALISE --- */
217    $("select").each(function () {
218        if ($(this).parent("div[id^='wp-block-themeisle-blocks-form-input']").length) {
219            $(this).parent("div[id^='wp-block-themeisle-blocks-form-input']").addClass('custom-select');
220        }
221    });
222    var customSelect = $(".custom-select");
223    customSelect.each(function () {
224        var thisCustomSelect = $(this),
225            options = thisCustomSelect.find("option"),
226            firstOptionText = options.first().text();
227        var selectedItem = $("<div></div>", {
228            class: "selected-item"
229        })
230            .appendTo(thisCustomSelect)
231            .text(firstOptionText);
232        var allItems = $("<div></div>", {
233            class: "all-items all-items-hide"
234        }).appendTo(thisCustomSelect);
235        var allItemsBox = $("<div></div>", {
236            class: "all-items-box"
237        }).appendTo(allItems);
238        options.each(function () {
239            var that = $(this),
240                optionText = that.text();
241            var item = $("<div></div>", {
242                class: "item",
243                on: {
244                    click: function () {
245                        var selectedOptionText = that.text();
246                        selectedItem.text(selectedOptionText).removeClass("arrowanim");
247                        allItems.addClass("all-items-hide");
248                    }
249                }
250            })
251                .appendTo(allItemsBox)
252                .text(optionText);
253        });
254    });
255    var selectedItem = $(".selected-item"),
256        allItems = $(".all-items");
257    selectedItem.on("click", function (e) {
258        var currentSelectedItem = $(this),
259            currentAllItems = currentSelectedItem.next(".all-items");
260        allItems.not(currentAllItems).addClass("all-items-hide");
261        selectedItem.not(currentSelectedItem).removeClass("arrowanim");
262        currentAllItems.toggleClass("all-items-hide");
263        currentSelectedItem.toggleClass("arrowanim");
264        e.stopPropagation();
265    });
266
267    $(document).on("click", function () {
268        var opened = $(".all-items:not(.all-items-hide)"),
269            index = opened.parent().index();
270        customSelect
271            .eq(index)
272            .find(".all-items")
273            .addClass("all-items-hide");
274        customSelect
275            .eq(index)
276            .find(".selected-item")
277            .removeClass("arrowanim");
278    });
279
280    /* --- FIN MENU SELECT OPTION PERSONNALISE --- */
281
282
283    /* --- DEBUT PROFIL MODAL --- */
284    var modal = document.getElementById('profileModal');
285    var btn = document.getElementById('openProfileModal');
286    var span = document.getElementsByClassName('close-modal')[0];
287    var applyFilterBtn = document.getElementById('applyFilter');
288    var articlesContainer = document.getElementById('articlesContainer');
289
290    btn.onclick = function () {
291        modal.style.visibility = "visible";
292        modal.setAttribute('aria-expanded', 'true');
293        document.body.style.overflow = "hidden";
294        loadArticles();
295    }
296
297    span.onclick = function () {
298        modal.style.visibility = "hidden";
299        modal.setAttribute('aria-expanded', 'false');
300        document.body.style.overflow = "auto";
301    }
302
303    window.onclick = function (event) {
304        if (event.target == modal) {
305            modal.style.display = "none";
306            document.body.style.overflow = "auto";
307        }
308    }
309
310    applyFilterBtn.onclick = function () {
311        loadArticles();
312    }
313
314    function loadArticles() {
315        var selectedTags = Array.from(document.querySelectorAll('#filterForm input[type="checkbox"]:checked')).map(function (cb) {
316            return cb.value;
317        });
318
319        var data = {
320            action: 'load_filtered_articles',
321            tags: selectedTags
322        };
323
324        jQuery.post(ajaxurl, data, function (response) {
325            articlesContainer.innerHTML = response;
326        });
327    }
328    /* --- FIN PROFIL MODAL --- */
329	
330	
331
332});

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.