PageSourceSearch

https://webpublication.fr/wp-content/themes/semplice4-child/js/custom.js?v=202609281359

js webpublication.fr collected 2026-10-02 14:39:18 UTC 13,798 bytes, 405 lines download raw bytes

1var fullScreenLoader = {
2  createIframe: function() {
3      // Create a placeholder iframe
4      var newIframe = $('<iframe id="webpublication-iframe" allowfullscreen="true" src=""></iframe>');
5      $('body').append(newIframe);
6  },
7  openIframe: function(url, isFullscreen) {
8      var iframeElement = document.querySelector('#webpublication-iframe');
9      var body = document.querySelector('body');
10      iframeElement.src = url;
11      iframeElement.classList.add('isOpened');
12      body.classList.add('fullscreenOpened');
13      if (isFullscreen) {
14          if (iframeElement.requestFullscreen) {
15              iframeElement.requestFullscreen();
16          } else if (iframeElement.webkitRequestFullscreen) { /* Safari */
17              iframeElement.webkitRequestFullscreen();
18          }
19      }
20  },
21  handleMessage: function(e) {
22      if (e.data.target === 'webpublication-integration') {
23          if (e.data.action === 'close') {
24              fullScreenLoader.handleMessageClose();
25          }
26      }
27  },
28  resetIframe: function() {
29      var iframeElement = document.querySelector('#webpublication-iframe');
30      var body = document.querySelector('body');
31      iframeElement.src = '';
32      iframeElement.classList.remove('isOpened');
33      body.classList.remove('fullscreenOpened');
34  },
35  handleMessageClose: function() {
36      if (document.exitFullscreen) {
37          document.exitFullscreen();
38      } else if (document.webkitExitFullscreen) { /* Safari */
39          document.webkitExitFullscreen();
40      } else {
41          fullScreenLoader.resetIframe();
42      }
43  },
44  handleNativeClose: function() {
45      if (!document.webkitIsFullScreen && !document.mozFullScreen && !document.msFullscreenElement) {
46          fullScreenLoader.resetIframe();
47      }
48  },
49  loadIframeFromHref: function(e) {
50      e.preventDefault();
51      var integrationParams = 'version=html&vp=1&integration=true&backHome=true';
52      var targetURL = $(e.target).closest('a').attr('href');
53      var symbol = targetURL.indexOf('?') !== -1 ? '&' : '?';
54      var integrationURL = targetURL + symbol + integrationParams;
55      fullScreenLoader.openIframe(integrationURL, true);
56  }
57}
58
59jQuery(document).ready(function ($) {
60
61  var urlParams = new URL(window.location.href);
62
63  // Triger the free-quote popup on all pages if a get param is present
64  (function () {
65    var popup = urlParams.searchParams.get("popup");
66    if (popup == 'free-quote') {
67      $('#pum-387').popmake('open');
68    } else if (popup == 'create-an-account') {
69      $('#pum-1715').popmake('open');
70    }
71  })();
72
73  // Scroll to hash
74  $('.js-animate-scroll').on('click', function(e){
75      e.preventDefault();
76      var href = $(this).attr('href');
77      var hashIndex = href.indexOf('#');
78      var topBarOffsetAdjustment = 100;
79      if(hashIndex != -1){
80          var hash = href.substr(hashIndex, href.length);
81          $('html, body').animate({
82              scrollTop: ($(hash).offset().top - topBarOffsetAdjustment)
83          }, 1000);
84      }
85  });
86
87  // Language selector dropdown
88  (function () {
89    // toggle between hiding and showing the dropdown content */
90    var $langSelectorBtn = $('#lang-selector__trigger');
91    var $langSelectorList = $("#lang-selector__list");
92
93    $langSelectorBtn.on('click', function () {
94      $langSelectorList.toggleClass('show');
95    });
96
97    //- Close the dropdown if the user clicks outside of it
98    window.onclick = function (event) {
99      var target = $(event.target);
100      if (!target.is($langSelectorBtn)) {
101        $langSelectorList.removeClass('show');
102      }
103    }
104  })();
105
106  //Set placeholder to footer subscription form
107  (function () {
108    $('.es_txt_email').attr('placeholder', 'votre adresse email');
109    //Add scrool indicator to the html element
110    function isScrolled(el) {
111      if (window.pageYOffset > 0) {
112        el.addClass('scrolled');
113        el.removeClass('not-scrolled');
114      } else {
115        el.addClass('not-scrolled');
116        el.removeClass('scrolled');
117      }
118    }
119    var $body = $('body');
120    isScrolled($body);
121    $(window).scroll(function () {
122      isScrolled($body);
123    });
124  })();
125
126  //Setup our on form Sumbit Listener.
127  $(document).on('nfFormSubmitResponse', function (response) {
128
129    if (response.handleObj.handler.arguments[1].response.data.form_id === '8') {
130
131      // Create a new user on our ASP using a proxy script
132      var dataString =
133        'email=' + encodeURIComponent(response.handleObj.handler.arguments[1].response.data.fields['53']['value']) + '&' +
134        'password=' + response.handleObj.handler.arguments[1].response.data.fields['67']['value'] + '&' +
135        'phone=' + response.handleObj.handler.arguments[1].response.data.fields['54']['value'] + '&' +
136        'locale=' + 'fr_FR' + '&' +
137        'company=' + response.handleObj.handler.arguments[1].response.data.fields['52']['value'] + '&' +
138        'sendEmail=' + 'true';
139
140      var url = "https://webpublication.fr/proxy/asp_create_user.php";
141
142      $.ajax({
143        type: "POST",
144        url: url,
145        data: dataString,
146        success: function (data) {
147          $('#popmake-1715').append('<div class="create-user-message">Un nouvel utilisateur a été créé. <br><a target="_blank" href="https://fr.adminzone-secure.net/react-admin/?locale=fr_FR#/login">Connexion.</a></div>');
148        },
149        error: function (error) {
150          var responseText = JSON.parse(error.responseText);
151          if (responseText.message == 'DUPLICATE_EMAIL--email') {
152            $('#popmake-1715').append('<div class="create-user-message">Cet email est déjà lié à un utilisateur existant. <br><a target="_blank" href="https://fr.adminzone-secure.net/react-admin/?locale=fr_FR#/login">Connexion.</a></div>');
153          } else {
154            $('#popmake-1715').append('<div class="create-user-message">Un problème est survenu lors de la création de votre profil utilisateur.</div>');
155          }
156        }
157      });
158
159    } //endif
160
161  }); // on nfFormSubmitResponse
162
163
164  // Carousel mobile version
165  (function () {
166    $(document).click(function (e) {
167      $(".mobile-owl-nav").removeClass('expanded');
168    });
169
170    $(".mobile-owl-nav").find('.helper').click(function (e) {
171      e.stopPropagation();
172      $(this).parent().toggleClass('expanded');
173    });
174  })();
175
176
177  //Prepopulate tracking field 
178  if (typeof (Marionette) != 'undefined') {
179
180    // Create a new object for custom validation of a custom field.
181    var myNameSpaceController = Marionette.Object.extend({
182
183      initialize: function () {
184        this.listenTo(nfRadio.channel('form'), 'render:view', this.prefillFormFields);
185      },
186
187      prefillFormFields: function (view) {
188        var formModel = view.model;
189        var url_string = window.location.search;
190        if (formModel.id == '4') {
191          //contact form
192          if (url_string) {
193            $('#nf-field-99').val(url_string).change();
194          }
195        } else if (formModel.id == '6') {
196          //header form
197          if (url_string) {
198            $('#nf-field-100').val(url_string).change();
199          }
200        } else if (formModel.id == '7') {
201          //footer form
202          if (url_string) {
203            $('#nf-field-101').val(url_string).change();
204          }
205        } else if (formModel.id == '5') {
206          //Popup form
207          if (url_string) {
208            $('#nf-field-102').val(url_string).change();
209          }
210        }
211      },
212
213    });
214
215  }
216
217  // Instantiate our custom controller, defined above.
218  new myNameSpaceController();
219
220  //Mobile menu setup
221  (function () {
222    var body = $('body');
223    var menu = $('#menu-mobile-3');
224    var backButton = $('<div class="back">Accueil</div>');
225    var linksLevel1 = menu.children('.menu-item-has-children');
226
227    function goToMenuHome() {
228      menu.find('.sub-menu').removeClass('submenu-current');
229      body.removeClass('submenu-open');
230    }
231
232    $('.semplice-menu').on('click', function () {
233      goToMenuHome();
234    })
235    backButton.on('click', function () {
236      goToMenuHome();
237    })
238
239    $('#overlay-menu').append(backButton);
240
241    linksLevel1.each(function () {
242      $(this).on('click', function () {
243        $(this).find('.sub-menu').addClass('submenu-current');
244        body.addClass('submenu-open');
245      });
246      $(this).children('a').on('click', function (e) {
247        e.preventDefault();
248      })
249    });
250  })();
251
252  // Custom lightbox
253  (function () {
254    var Lightbox = window.SimpleLightbox;
255    if (Lightbox) {
256
257      function activateDataSrc(el) {
258        if (el) {
259          switch (el.tagName) {
260            case 'DIV':
261              // Look for an iframe inside and get the first one
262              var iframe = el.getElementsByTagName("IFRAME")[0];
263              if (iframe && iframe.dataset.src) {
264                iframe.setAttribute('src', iframe.dataset.src);
265              }
266              break;
267            case 'VIDEO':
268              // Get first source
269              var sourceEl = el.getElementsByTagName('SOURCE')[0];
270              if (sourceEl && sourceEl.dataset.src) {
271                sourceEl.setAttribute('src', sourceEl.dataset.src);
272              }
273              break;
274          }
275        }
276        return el;
277      }
278
279      // Add lightbox to all links pointing to an image
280      var regex = /\.(?:png|jpg|jpeg|gif|webp)$/i;
281      $('a').each(function (index) {
282        if (regex.test($(this).attr('href'))) {
283          $(this).simpleLightbox();
284        }
285      });
286
287      // Add a lightbox to each item that has a data-lightbox attribute
288      var lightboxTriggers = $('[data-lightbox]');
289      lightboxTriggers.on('click', function (e) {
290        e.preventDefault();
291        var id = $(this).attr('data-lightbox');
292        var targetElement = document.getElementById(id);
293        var clonedElement = activateDataSrc(targetElement.cloneNode(true));
294
295        Lightbox.open({ content: clonedElement });
296        if (targetElement.tagName === 'VIDEO') {
297          clonedElement.play();
298        }
299      });
300
301      // Trigger light box based on an url param
302      var urlTrigger = urlParams.searchParams.get("lightbox");
303      if (urlTrigger) {
304        var targetElement = document.getElementById(urlTrigger);
305        var clonedElement = activateDataSrc(targetElement.cloneNode(true));
306        Lightbox.open({ content: clonedElement });
307      }
308
309    }
310
311  })();
312
313  // Allow opening links in fullscreen mode.
314  (function () {
315    var fullscreenLinks = $('.fullscreen-example');
316    window.addEventListener('message', fullScreenLoader.handleMessage);
317    if (document.addEventListener) {
318      document.addEventListener('fullscreenchange', fullScreenLoader.handleNativeClose, false);
319      document.addEventListener('mozfullscreenchange', fullScreenLoader.handleNativeClose, false);
320      document.addEventListener('MSFullscreenChange', fullScreenLoader.handleNativeClose, false);
321      document.addEventListener('webkitfullscreenchange', fullScreenLoader.handleNativeClose, false);
322    }
323
324    if(fullscreenLinks.length > 0 ){
325      fullScreenLoader.createIframe();
326      fullscreenLinks.on('click', function(e){
327        fullScreenLoader.loadIframeFromHref(e);
328      });
329    }
330    
331  })();
332
333  // Tabs functionality
334  (function () {
335    function updateTabs(buttonIndex) {
336      const $tabContainer = $(".p-tabs");
337      const $buttons = $tabContainer.find(".p-tab-button");
338      const $contents = $tabContainer.find(".p-tab-content");
339
340      // Remove "active" class from all buttons and content
341      $buttons.removeClass("active");
342      $contents.removeClass("active");
343
344      // Determine the index of the content to activate
345      const contentIndex = Math.min(buttonIndex, $contents.length - 1);
346
347      // Add "active" class to the clicked button and corresponding content
348      $buttons.eq(buttonIndex).addClass("active");
349      $contents.eq(contentIndex).addClass("active");
350    }
351
352    // Attach click event handler to all buttons
353    $(".p-tabs .p-tab-button").on("click", function () {
354        const buttonIndex = $(this).index();
355        updateTabs(buttonIndex);
356    });
357
358    // Initialize the active state on page load
359    const $tabContainer = $(".p-tabs");
360    if ($tabContainer.find(".p-tab-button.active").length === 0) {
361        updateTabs(0); // Default to the first tab if no active button is set
362    }
363  })();
364
365});//ready
366
367
368jQuery( document ).one( 'nfFormReady', function() {
369
370  (function addFloatingFormLabels() {
371    var inputs = $('.floating-label')
372      .find('input, textarea');
373    inputs.on('focus', function () {
374      $(this).closest('.nf-field-container').addClass('input-active');
375    })
376    inputs.on('blur', function () {
377      if (!$(this).val()) {
378        $(this).closest('.nf-field-container').removeClass('input-active');
379      }
380    })
381  })();
382  
383  (function changeProductBasedOnParam() {
384    var urlParams = new URL(window.location.href);
385    var product = urlParams.searchParams.get("product");
386    if (product) {
387      $('#js-report-issue-form')
388      .find('option[value="' + product + '"]')
389      .attr('selected',true)
390      .trigger('change');
391    }
392  })();
393
394  // Ninja forms conversion tracking
395  nfRadio.channel('forms').on('submit:response', function(form) {
396    window.dataLayer = window.dataLayer||[];
397    dataLayer.push({
398      event: 'ninjaFormSubmission',
399      formID: form.data.form_id,
400      formTitle: form.data.settings.title
401    })
402  })
403
404
405} )

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.