PageSourceSearch

https://irfa.paris/wp-content/themes/irfa/js/script.js?ver=1.0

js irfa.paris collected 2026-09-24 21:12:08 UTC 13,700 bytes, 396 lines download raw bytes

1$(document).ready(function() {
2  fixScrollOffset(null, this.location); // Scroll sur l'ancre au chargement
3
4  /* JS click sur bouton Menu burger */
5  $(".openbtnmenu").click(function(){
6    $("#myNav").css("width", "100%");
7    $("#myNav").css("left", "0");
8  });
9
10  /* JS click sur bouton fermer le menu */
11  $(".closebtn").click(function(){
12    $("#myNav").css("width", "0");
13    $("#myNav").css("left", "100%");
14  });
15
16  /* JS pour corriger l'offset du scroll avec le menu fixé */
17  function fixScrollOffset (event, target) {
18    var hash = target.hash;
19    var bootstrap_tabs = ["doc_missionnaire_tabs", "nav_missionnaire_tabs"];
20    if($(hash).length > 0 && !bootstrap_tabs.includes($(target).parent().attr('id')) && target.href.includes(window.location.href.split('#')[0])){
21      if(event){
22        event.preventDefault();
23      }
24      var customOffset = $("body.admin-bar").length == 0 ? 75 : 110;
25      var scrollDist = $(hash).offset().top - customOffset;
26      $(window).scrollTop(scrollDist);
27    }
28  }
29  $('a[href*=\\#]').click(function(event){
30    fixScrollOffset(event, this);
31  });
32  $(window).on('load', function(){
33    fixScrollOffset(null, this.location); // Si jamais le scroll auto au chargement n'a pas fonctionné on rappelle la fonction
34  });
35
36
37  /* JS activation tooltip */
38  var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
39  tooltipTriggerList.map(function (tooltipTriggerEl) {
40    new bootstrap.Tooltip(tooltipTriggerEl)
41  })
42
43  /* JS du menu page zonesgeographiques  (version mobile) */
44  $('#selectMenuPays, #selectMenuOrientationBibli, #selectMenuMissionnaire, #selectDocMissionnaire').on('change', function (e) {
45    if ($(this).attr('id') === 'selectMenuOrientationBibli' || $(this).attr('id') === 'selectMenuPays') {
46      var mainContent = 'pays';
47    } else if ($(this).attr('id') === 'selectMenuMissionnaire' || $(this).attr('id') === 'selectDocMissionnaire') {
48      var mainContent = 'missionnaire';
49    }
50
51    prefix = ($(this).attr('id') === 'selectMenuOrientationBibli' || $(this).attr('id') === 'selectMenuMissionnaire') ? 'list-' : '';
52    cleanTrigger = '#nav_' + mainContent + '_tabs a';
53    cleanTarget = '#nav_' + mainContent + '_content .tab-pane';
54    targetElemTrigger = '#nav_' + mainContent + '_tabs a#' + prefix + $(this).val() + '-list';
55    targetElemTarget = '#nav_' + mainContent + '_content #' + prefix + $(this).val() + '';
56
57    $(cleanTrigger).removeClass('active');
58    $(cleanTarget).removeClass('collapse active show');
59    $(targetElemTrigger).trigger('mousedown').trigger('click');
60    $(targetElemTrigger).addClass('active');
61    $(targetElemTarget).addClass('collapse active show');
62    // go to anchor 
63    $('html,body').animate({scrollTop: $(targetElemTarget).offset().top - 250}, 'fast');
64  });
65
66  /* JS du menu page missionnaire (version desktop) */
67  const triggerTabList = [].slice.call(document.querySelectorAll('#nav_pays_tabs button, #nav_missionnaire_tabs a'));
68  triggerTabList.forEach(function (triggerEl) {
69    let tabTrigger = new bootstrap.Tab(triggerEl)
70
71    triggerEl.addEventListener('click', function (event) {
72      event.preventDefault();
73      tabTrigger.show();
74
75      var content = triggerEl.parentNode.id.replace('tabs', 'content');
76      var customOffset = $("body.admin-bar").length == 0 ? 215 : 250;
77      $(window).scrollTop($("#"+content).offset().top - customOffset);
78    });
79  });
80
81  /* JS du formulaire contact form */
82  $(".wpcf7 form").submit(function(){
83    console.log("show")
84    $(this).find(".ajax-loader").css("display", "inline-block");
85  });
86
87  $(".wpcf7").on("wpcf7submit wpcf7invalid", function(){
88    console.log("hide")
89    $(this).find(".ajax-loader").hide();
90  });
91
92  /* JS d'affichage du menu filtre actualité */
93  $(".toggle_filter_tab, .toggle_filter_search").click(function(){
94    if(window.innerWidth < 992){
95      var menu = $(".filter_container");
96
97      if(!menu.hasClass('open_filter')){
98        // menu.css({"height": $(".facetwp-facet-actu_tag_filter").outerHeight()+60});
99        menu.css({"height": $(".result_filters").outerHeight()+60});
100        setTimeout(function(){
101          menu.addClass('open_filter');
102        },300);
103      }
104      else{
105        menu.css({"height": 0});
106        menu.removeClass('open_filter');
107      }
108    }
109  });
110
111  $(window).resize(function(){
112    var menu = $(".filter_container");
113    if(window.innerWidth > 992 && menu.length > 0){
114      var menu = $(".filter_container");
115      // menu.css({"height": $(".result_filters").outerHeight()+60});
116      menu.removeAttr('style');
117    }
118    else if(window.innerWidth < 992 && menu.hasClass('open_filter')){
119        menu.css({"height": 0});
120        menu.removeClass('open_filter');
121    }
122  });
123
124  /* Refresh automatique de la recherche à la selection d'un tri */
125  $(document).on("change", ".result-sort-by .facetwp-sort-select, .result-per-page .facetwp-per-page-select", function(){
126    if($(".search-filter-apply").length > 0){
127      $(".search-filter-apply")[0].click();
128    }
129  });
130
131  /* Refresh automatique avec entrer quand on édite un champs texte */
132  $(document).on("click", ".result_filters .facetwp-type-autocomplete .fcomplete-result", function(e){
133    if(e.target.className == "fcomplete-result"){
134      $(".result_filters .facetwp-type-autocomplete .facetwp-autocomplete").val(e.target.innerText)
135      if($(".search-filter-apply").length > 0){
136        $(".search-filter-apply")[0].click();
137      }
138    }
139  });
140  $(document).on("keydown", ".result_filters .facetwp-type-autocomplete .facetwp-autocomplete", function(e){
141    if(e.target.className != "fcomplete-result"){
142      autoSearchOnEnter(e, $(this));
143    }
144  });
145  $(document).on("keypress", ".result_filters .facetwp-type-search .facetwp-search", function(e){
146    autoSearchOnEnter(e, $(this));
147  });
148
149  /* JS fix fullscreen PDFJS-Viewer */
150  setTimeout(function() {
151    $('.pdfjs-fullscreen').each(function(){
152      var link = $(this).find('a').attr('href').replace('#zoom', "&zoom");
153      $(this).find('a').attr('href', link);
154    });
155
156    $('.pdfjs-iframe').each(function(){
157      var link = $(this).attr('src').replace('#zoom', "&zoom");
158      $(this).attr('src', link);
159    });
160  }, 10);
161
162  /* JS du bouton retour en haut */
163  var toTop = $(".vers-haut-page");
164  backToTop(toTop);
165  $(document).scroll(function(){
166    backToTop(toTop);
167  });
168
169  /* JS flash messages */
170  setTimeout(function() {
171    $('.flash-message').fadeOut('fast');
172  }, 5000); // <-- time in milliseconds
173  $('body').on('click', '.flash-message i', function(){
174    $('.flash-message').fadeOut('fast');
175  })
176
177  handle_anchorUrl();
178
179  /* JS de la liste déroulante du switch de langue pour les pages portails */
180  $('.lang-switcher-dropdown > a.btn-lang').click(function (e) {
181    e.preventDefault();
182
183    $('.lang-switcher-dropdown > ul').addClass('active');
184  });
185
186  $('body').click(function (e) {
187    const target = $(e.target);
188    if (!target.closest('.lang-switcher-dropdown').length && $('.lang-switcher-dropdown ul').hasClass('active')) {
189        $('.lang-switcher-dropdown ul').removeClass('active');
190    }
191  });
192
193});
194
195/* JS du menu page missionnaire (version desktop) */
196const triggerTabList = [].slice.call(document.querySelectorAll('#nav_pays_tabs button, #nav_missionnaire_tabs a'));
197triggerTabList.forEach(function (triggerEl) {
198  let tabTrigger = new bootstrap.Tab(triggerEl)
199
200  triggerEl.addEventListener('click', function (event) {
201    event.preventDefault();
202    tabTrigger.show();
203    
204    var content = triggerEl.parentNode.id.replace('tabs', 'content');
205    var customOffset = $("body.admin-bar").length == 0 ? 215 : 250;
206    $(window).scrollTop($("#"+content).offset().top - customOffset);
207  });
208});
209
210/* JS changement catégorie actualité */
211$(".categorie_switcher .button-switch").click(function(){
212  $(".switcher_row .facetwp-type-checkboxes .facetwp-checkbox").removeClass("checked disabled");
213
214  $(".switcher_row .facetwp-type-checkboxes .facetwp-checkbox[data-value='"+$(this).attr("data-value")+"']").click()
215
216  $(".button-switch").removeClass("selected");
217  $(".button-switch").removeAttr("disabled")
218
219  $(this).addClass("selected");
220  $(this).attr("disabled", true);
221})
222
223/* JS modification visuel FacetWP */
224$(document).on('facetwp-loaded', function(){
225  setTimeout(function(){
226    var facets = $('.facetwp-facet-ap_type_de_document .fs-wrap');
227    var facets_options = facets.find('.fs-option');
228    var facets_selected =  facets.find('.fs-option.d0.selected');
229
230    facets_options.each(function(index, option) {
231      if($(option).hasClass("d1") && facets_selected.length == 0) {
232        $(option).hide();
233      }
234      if($(option).hasClass("d0") && facets_selected.length > 0) {
235        $(option).addClass("expanded");
236      }
237    });
238
239    facets_options.each(function(index, option) {
240      if($(option).hasClass("d0") && index < (facets_options.length -1) && $(facets_options[index + 1]).hasClass('d1')) {
241        $(option).off('click'); // prevents FacetWP from reacting on options expand
242
243        $(option).append('<button type="button" class="expand"></button>');
244
245        $(option).find("button.expand").on('click', function(e) {
246          e.preventDefault();
247          e.stopPropagation(); // prevents FacetWP from reacting on options expand
248
249          var parent = $(this).closest('.fs-option');
250          var parentIndex = facets_options.index(parent);
251
252          if(!parent.hasClass("expanded")) {
253            $(".facetwp-facet-ap_type_de_document .fs-option.expanded").removeClass("expanded");
254            $(parent).addClass("expanded");
255          }
256          else {
257            $(parent).removeClass("expanded");
258          }
259
260          // Toggle all consecutive children until next parent
261          var i = parentIndex + 1;
262          var child = facets_options.eq(i);
263
264          while(i < facets_options.length && !child.hasClass('d0')) {
265            if($(parent).hasClass('expanded')) {
266              child.show();
267            }
268            else {
269              child.hide();
270            }
271
272            i++;
273            child = facets_options.eq(i);
274          }
275        });
276      }
277    });
278
279    /* JS action formulaire de recherche avec le bouton entrée */
280    $('.search_filter_container  input[type=text]').keypress(function(event){
281      if (event.key == 'Enter' || event.keyCode == 13){
282        FWP.refresh();
283      }
284    });
285  }, 10)
286});
287
288function autoSearchOnEnter(event, input){
289  if(event.originalEvent.key == "Enter" && input.val() != ''){
290    if($(".search-filter-apply").length > 0){
291      $(".search-filter-apply")[0].click();
292    }
293  }
294}
295
296function printPage(){
297  setTimeout(function(){
298    window.print();
299  }, 100);
300  return false;
301}
302
303/* JS du bouton retour en haut */
304function backToTop(toTop){
305  if(toTop.hasClass("fixed")){
306    if($(document).scrollTop() + window.innerHeight < $('footer').offset().top){
307        toTop.removeClass("fixed");
308        toTop.addClass("show");
309    }
310  }
311  else{
312    if(window.pageYOffset > 775){
313      if(toTop.offset().top + toTop.height() >= $('footer').offset().top - 50){
314        toTop.removeClass("show");
315        toTop.addClass("fixed");
316      }
317      else{
318        toTop.addClass("show"); 
319      }
320    }
321    else{
322        toTop.removeClass("fixed");
323        toTop.removeClass("show");
324    }
325  }
326}
327/** JS get home URL 
328 *  @route String ajoute une route specifique a l url
329 *  @params []string ajoute les paramètres après avoir ajouté la route spécifié 
330 *  @currentPage bool true renvoie l'URL courant sans modif
331*/
332function js_home_url(route = '', params = [], currentPage = false){
333  var devAdress = ['localhost', '192.168.51.89', '92.154.49.37'];
334  var href = document.location.href;
335  var origin = document.location.origin;
336  var hostname = document.location.hostname;
337  if (currentPage)
338    return href;
339
340  if(devAdress.includes(hostname)){
341    var devFolder = '/irfa';
342  } else {
343    var devFolder = '';
344  }
345  var url = origin + devFolder;
346  // add route
347  if (url[url.length-1] == '/' && route[0] == '/'){
348    url += route.replace('/', '');
349  } else if (url[url.length-1] != '/' && route[0] != '/'){
350    url += '/' + route;
351  } else {
352    url += route;
353  }
354  // remove diez
355  url = url.replaceAll('#', '');
356  // add params
357  if (Object.keys(params).length > 0){
358    url += '?'
359    for (const key in params) {
360      url += key + '=' + params[key] + '&'; 
361    }
362    if (url[url.length-1] == '&'){
363      url = url.substr(0, url.length-1);
364    }
365  }
366  return url;
367}
368
369function handle_anchorUrl(){
370  var hash_split = (document.location.href).split('#');
371  hash = hash_split.length > 1 ? hash_split.pop() : '';
372  if(hash != ''){
373    var targetId = '#' + hash + '-list';
374    var someTabTriggerEl = document.querySelector('[id="' + targetId + '"]');
375    if(someTabTriggerEl != null){
376      var tab = new bootstrap.Tab(someTabTriggerEl);
377      tab.show();
378    }
379  }
380}
381
382document.addEventListener('DOMContentLoaded', function() {
383
384function getHashId() {
385  return window.location.hash.substring(1);
386}
387
388if (window.location.pathname.includes('/se-documenter-sur-un-missionnaire')) {
389    var hashId = getHashId(); 
390    if (hashId) {
391        var elementToClick = document.querySelector('a[href="#' + hashId + '"]');
392        if (elementToClick) {
393            elementToClick.click(); 
394        }
395    }
396}});

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.