PageSourceSearch

https://csmnatation-marseille.fr/js/common.js?tm=1791275549

js csmnatation-marseille.fr collected 2026-10-06 14:04:54 UTC 96,569 bytes, 2,313 lines download raw bytes

1/******/ (() => { // webpackBootstrap
2/*!***************************************!*\
3  !*** ./resources/assets/js/common.js ***!
4  \***************************************/
vendor: 9,379 bytes, lines 4-7
4
5function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
6function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
7function 
7_createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
8function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
9function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
10function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
11function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
12$(document).ready(function () {
13  ini_header();
14  init_a2hs();
15  ini_menu();
16  ini_footer();
17  ini_stats_analyser();
18  ini_filtres();
19  ini_video("");
20  ini_formulaire_commentaires();
21  ini_commentaires();
22  ini_forum();
23  ini_giphy();
24  ini_livredor();
25  ini_partage();
26  ini_menu_sections();
27  ini_widget_a_la_une();
28  ini_widgets_evenements();
29  ini_widget_reservations();
30  ini_widget_rss();
31  ini_widget_calendrier();
32  ini_widget_flux();
33  ini_widget_recherche();
34  ini_widgets_avec_zooms();
35  ini_evenement();
36  ini_newsletter();
37  ini_liste_equipes();
38  ini_recherche_partenaire();
39  ini_panier();
40  if ($('#choix_livraison input[name=mode_de_livraison]').length) maj_mode_livraison();
41  ini_moyens_paiements();
42  ini_printable();
43  ini_contact();
44
45  // Tipsy
46
47  $('[data-bs-toggle="tooltip"]').tooltip();
48
49  // Fancybox
50
51  Fancybox.bind("[data-fancybox]", {
52    // Your custom options
53  });
54
55  // Recherche de mots clés
56
57  if ($('#rechercheheader').length) init_form('rechercheheader');
58  if (termes_recherche) surligneMotsCles(termes_recherche);
59
60  // Contrôle de l'age
61
62  $('.add_age').on('click', add_age);
63
64  // Open As Popup
65
66  $(".open_as_popup").each(function () {
67    init_open_as_popup($(this));
68  });
69
70  //  https://stackoverflow.com/questions/69269449/ckeditors-popup-input-fields-dont-work-when-used-with-bootstrap-5-modal-ckedit
71  // bootstrap.Modal.prototype._initializeFocusTrap = function () { return { activate: function () { }, deactivate: function () { } } };
72});
73$.fn.pulse = function (options) {
74  // S'efface puis se rallume
75
76  var options = $.extend({
77    times: 3,
78    duration: 1000
79  }, options);
80  var period = function period(callback) {
81    $(this).animate({
82      opacity: 0
83    }, options.duration, function () {
84      $(this).animate({
85        opacity: 1
86      }, options.duration, callback);
87    });
88  };
89  return this.each(function () {
90    var i = +options.times,
91      self = this,
92      repeat = function repeat() {
93        --i && period.call(self, repeat);
94      };
95    period.call(this, repeat);
96  });
97};
98$.fn.unpulse = function (options) {
99  // s'allume puis se ré-éteint
100
101  var options = $.extend({
102    times: 3,
103    duration: 1000
104  }, options);
105  var period = function period(callback) {
106    $(this).animate({
107      opacity: 1
108    }, options.duration, function () {
109      $(this).animate({
110        opacity: 0
111      }, options.duration, callback);
112    });
113  };
114  return this.each(function () {
115    var i = +options.times,
116      self = this,
117      repeat = function repeat() {
118        --i && period.call(self, repeat);
119      };
120    period.call(this, repeat);
121  });
122};
123
124/*****************************************************************************************/
125/*      Header                                                                           */
126/*****************************************************************************************/
127
128// Gestion du bandeau responsive
129
130function ini_header() {
131  height_header();
132  $(window).on('resize', height_header);
133}
134function height_header() {
135  var w = $('#conteneur_bandeau').width();
136  $('#conteneur_bandeau').height(w * 200 / 1140);
137  $('#bandeau-et-titre').height(w * 200 / 1140);
138  $('#lien-bandeau img').height(w * 200 / 1140);
139}
140var deferredPrompt_a2hs;
141function init_a2hs() {
142  var a2hs = document.getElementById("a2hs");
143  a2hs.style.display = "none";
144  //$('body').addClass('with-a2hs');
145  window.addEventListener("beforeinstallprompt", function (e) {
146    // Prevent Chrome 67 and earlier from automatically showing the prompt
147    e.preventDefault();
148    // Stash the event so it can be triggered later.
149    deferredPrompt_a2hs = e;
150    // Update UI to notify the user they can add to home screen
151    a2hs.style.display = "block";
152    $('body').addClass('with-a2hs');
153  });
154}
155
156/*****************************************************************************************/
157/*      Gestion des menus et navigation                                                  */
158/*****************************************************************************************/
159
160// Gestion du menu
161
162var dropdown_menu_do_once = 0;
163function ini_menu() {
164  // Préparation du menu en version sélecteur
165
166  $('#mainmenu > ul').each(function (e) {
167    $('#navigation-select').append(ul_to_options($(this)));
168  });
169  $('#navigation-select').change(function () {
170    if ($('#navigation-select').val() != '') go($('#navigation-select').val());
171  });
172
173  // Préparation du menu en onglet en version sélecteur
174
175  $('ul.nav.onglets > li').each(function (e) {
176    $('#onglet-select').append(ul_onglet_to_options($(this)));
177  });
178  $('#onglet-select').change(function () {
179    if ($('#onglet-select').val() != '') go($('#onglet-select').val());
180  });
181
182  // Gestion des intitulés de menus trop longs (D1)
183
184  $('#mainmenu a.long').each(function (e) {
185    if ($(this).height() > 40) {
186      $(this).parent().addClass('parent_troplong');
187      $(this).removeClass('long').addClass('troplong');
188    }
189  });
190
191  // Gestion des menus trop longs pour la taille d'écran
192
193  show_and_hide_menu();
194  show_and_hide_menu();
195  $(window).on('resize', function () {
196    show_and_hide_menu();
197    dropdown_menu_do_once = 1;
198    change_menu_position();
199  });
200  $('#mainmenu .dropdown').on('click', function () {
201    if (!$(this).hasClass('show')) dropdown_menu_do_once = 1;
202  });
203  $('#mainmenu .dropdown').on('shown.bs.dropdown', function () {
204    change_menu_position();
205  });
206}
207function ul_to_options(ul) {
208  var retour = '';
209  ul.children('li').each(function () {
210    var href = $(this).children('a').attr('href');
211    var text = $(this).children('a').text();
212    var uldiv = $(this).children('div');
213    if (uldiv.length == 0) {
214      retour = retour + '<option value="' + href + '"' + ($(this).hasClass('current') ? 'selected="selected" ' : '') + '>
214' + text + '</option>';
215    } else {
216      if ($(this).find('ul div').length == 0) {
217        var text = $(this).children('button').text();
218        retour = retour + '<optgroup label="' + text + '">';
219        uldiv.children('a').each(function () {
220          var href = $(this).attr('href');
221          var text = $(this).text();
222          retour = retour + '<option value="' + href + '"' + ($(this).hasClass('current') ? 'selected="selected" ' : '') + '>' + text + '</option>';
223        });
224        retour = retour + '</optgroup>';
225      } else {
226        //	retour = retour +  ul_to_options( uldiv );
227      }
228    }
229  });
230  return retour;
231}
232function ul_onglet_to_options(li) {
233  var retour = '';
234
235  // le niveau 1
236
237  var a = $(li).children('a').clone();
238  var href = a.attr('href');
239  var active = a.hasClass('active');
240  var nb = a.children('.badge').text();
241  a.find('.badge').remove();
242  var text = a.text();
243  text += nb ? ' (' + nb + ')' : '';
244  if ($(li).children('ul').length == 0) {
245    retour += '<option value="' + href + '"' + (active ? 'selected="selected" ' : '') + '>
245' + text + '</option>';
246  } else {
247    var page_parente_accessible = false;
248    retour_enfants = '';
249    active_enfant = false;
250    $(li).children('ul').children('li').each(function () {
251      var a = $(this).children('a').clone();
252      var href_enfant = a.attr('href');
253      var is_active = a.hasClass('active');
254      var nb_enfant = a.children('.badge').text();
255      a.find('.badge').remove();
256      var text_enfant = a.text();
257      text_enfant += nb_enfant ? ' (' + nb_enfant + ')' : '';
258      if (is_active) active_enfant = true;
259      retour_enfants += '<option value="' + href_enfant + '"' + (is_active ? 'selected="selected" ' : '') + '>' + (page_parente_accessible ? text + ' &gt; ' : '') + text_enfant + '</option>';
260    });
261    if (page_parente_accessible) {
262      retour += '<option value="' + href + '"' + (active && !retour_enfants ? 'selected="selected" ' : '') + '>' + text + '</option>';
263      retour += retour_enfants;
264    } else {
265      retour += '<optgroup label="' + text + '">' + retour_enfants + '</optgroup>';
266    }
267  }
268  return retour;
269}
270function menu_fail(max_height, classnameIfFail) {
271  var actual_h = $("#mainmenu > ul").height();
272  if (actual_h > max_height) {
273    $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
274    $("#mainmenu").addClass(classnameIfFail);
275    return true;
276  }
277  return false;
278}
279function show_and_hide_menu() {
280  $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
281  $("#mainmenu > ul").css("display", "flex");
282  $("#mainmenu form").css("display", "none");
283
284  // On vérifie que cela tient sur une ligne
285
286  if ($('#mainmenu').hasClass('allow2lines')) {
287    if (menu_fail(50, 'taille2')) if (menu_fail(50, 'taille3')) if (menu_fail(50, 'taille4')) if (menu_fail(50, 'taille5')) if (menu_fail(50, '')) {
288      $("#mainmenu").removeClass('taille1').removeClass('taille2').removeClass('taille3').removeClass('taille4').removeClass('taille5').removeClass('taille6');
289      if (menu_fail(100, 'taille2')) if (menu_fail(100, 'taille3')) if (menu_fail(100, 'taille4')) if (menu_fail(100, 'taille5')) if (menu_fail(100, '')) {
290        $("#mainmenu > ul").css("display", "none");
291        $("#mainmenu form").css("display", "block");
292      }
293    }
294  } else {
295    if (menu_fail(100, 'taille2')) if (menu_fail(100, 'taille3')) if (menu_fail(100, 'taille4')) if (menu_fail(100, 'taille5')) if (menu_fail(100, 'taille6')) if (menu_fail(100, '')) {
296      $("#mainmenu > ul").css("display", "none");
297      $("#mainmenu form").css("display", "block");
298    }
299  }
300  $("ul.nav.onglets").css("display", "flex");
301  $("#onglet-select").css("display", "none");
302  var actual_h = $("ul.nav.onglets").height();
303  if (actual_h > 50) {
304    $("ul.nav.onglets").css("display", "none");
305    $("#onglet-select").css("display", "inline-block");
306  }
307}
308function change_menu_position() {
309  // Sur un menu positionné à gauche, et dont un élément est ouvert pendant que l'on redimentionne la fenêtre, on regarde pour changer la position du dropdown pour que le menu ouvert reste visible.
310
311  if (dropdown_menu_do_once == 0) return;
312  dropdown_menu_do_once = 0;
313  var element_parent = $('#mainmenu .dropdown.show');
314  var element_ouvert = $('#mainmenu .dropdown-menu.show');
315  if (element_parent.length && element_ouvert.length) {
316    var right = parseInt(element_parent.offset().left) + parseInt(element_ouvert.width());
317    var width_body = parseInt($('body').width());
318
319    // Doit-on changer la direction du sous-menu ?
320
321    var changedir = false;
322    if (right >= width_body) {
323      if (!element_ouvert.hasClass('dropdown-menu-end')) {
324        changedir = true;
325      }
326    } else {
327      if (element_ouvert.hasClass('dropdown-menu-end')) {
328        changedir = true;
329      }
330    }
331    if (changedir) {
332      element_ouvert.toggleClass('dropdown-menu-end');
333      element_ouvert.dropdown('toggle');
334      element_ouvert.dropdown('toggle');
335      element_ouvert.dropdown('dispose');
336    }
337  }
338}
339function go(url) {
340  window.location = url;
341}
342
343/*****************************************************************************************/
344/*      Module sections                                                                  */
345/*****************************************************************************************/
346
347function ini_menu_sections() {
348  $('.openSectionContent').on('click', openSectionContent);
349}
350function openSectionContent() {
351  var etat = $(this).parent().find('.niveau1').css("display");
352  $("#barre-selection-section .niveau1").css("display", "none");
353  $("#barre-selection-section .fa-angle-up").removeClass('fa-angle-up').addClass('fa-angle-down');
354  if (etat != "block") {
355    $(this).parent().find('.niveau1').toggle();
356    $(this).find('.fa-angle-down').removeClass('fa-angle-down').addClass('fa-angle-up');
357  } else {
358    $(this).find('.fa-angle-up').removeClass('fa-angle-up').addClass('fa-angle-down');
359  }
360}
361
362/*****************************************************************************************/
363/*      Footer                                                                           */
364/*****************************************************************************************/
365
366function ini_footer() {
367  // Compteur dans le footer
368
369  $.ajax({
370    type: 'POST',
371    url: '/visites',
372    headers: {
373      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
374    },
375    data: {
376      association_id: association_id
377    },
378    success: function success(response) {
379      $("#nb-visites").html(response);
380    }
381  });
382  ini_footer_finalite();
383  $('#footer_name, #footer_firstname, #footer_email_contact, #footer_objet, #footer_message').on('keyup', ini_footer_finalite);
384}
385function ini_footer_finalite() {
386  if ($('#footer_name').val() && $('#footer_firstname').val() && $('#footer_email_contact').val() && $('#footer_objet').val() && $('#footer_message').val()) $('#block_finalite_footer_contact').show();else $('#block_finalite_footer_contact').hide();
387}
388function ini_stats_analyser() {
389  if (!('ab' in window)) {
390    window.ab = true;
391  }
392  if (window.ab) $('#stats_analyser').append('<img src="/home/imagecpt1.gif?' + Math.random() + '" alt="">');else $('#stats_analyser').append('<img src="/home/imagecpt2.gif?' + Math.random() + '" alt="">');
393  return 1;
394}
395
396/*****************************************************************************************/
397/*      Partage                                                                          */
398/*****************************************************************************************/
399
400function ini_partage() {
401  $('.facebookShare').on('click', function () {
402    var url = $(this).attr('url');
403    var descr = $(this).attr('text');
404    facebookShare(url, "", descr, "", 520, 350);
405  });
406  $('.twitterShare').on('click', function () {
407    var url = $(this).attr('url');
408    var descr = $(this).attr('text');
409    twitterShare(url, descr, 520, 350);
410  });
411}
412function facebookShare(url, title, descr, image, winWidth, winHeight) {
413  var winTop = screen.height / 2 - winHeight / 2;
414  var winLeft = screen.width / 2 - winWidth / 2;
415  window.open('https://www.facebook.com/sharer.php?u=' + url, 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
416}
417function twitterShare(url, descr, winWidth, winHeight) {
418  var winTop = screen.height / 2 - winHeight / 2;
419  var winLeft = screen.width / 2 - winWidth / 2;
420  window.open('https://twitter.com/intent/tweet?text=' + encodeURIComponent(descr + (descr && url ? ' ' : '') + url), 'sharer', 'top=' + winTop + ',left=' + winLeft + ',toolbar=0,status=0,width=' + winWidth + ',height=' + winHeight);
421}
422
423/*****************************************************************************************/
424/*      Filtres                                                                          */
425/*****************************************************************************************/
426
427function ini_filtres() {
428  // Filtrages dans les listes en mode "selecteur"
429
430  $('select.filtre').on('change', do_filtrage);
431  $('input.filtre').on('change', do_search_filtre);
432  $('.filter .recherche .btn, #barre-de-filtrage .recherche .btn').on('click', function () {
433    $(this).parent().find('input').each(do_search_filtre);
434  });
435}
436function do_filtrage() {
437  window.location = $(this).val();
438}
439function do_search_filtre() {
440  var parser = new URL(window.location);
441  parser.searchParams.set($(this).attr('id'), $(this).val());
442  window.location = parser.href;
443}
444
445/*****************************************************************************************/
446/*      Vidéos                                                                           */
447/*****************************************************************************************/
448
449var video_iframe_intervalID = new Array();
450function ini_video(racine) {
451  if ($((racine ? racine + " " : "") + ".elastic > div").length || $((racine ? racine + " " : "") + ".elastic > iframe").length) {
452    $((racine ? racine + " " : "") + ".elastic").each(function () {
453      var aspectRatio = $(this).attr("infoheight") / $(this).attr("infowidth");
454      $(this).data("aspectRatio", aspectRatio).removeAttr("height").removeAttr("width");
455    });
456    video_iframe_intervalID[racine] = window.setInterval(function () {
457      if ($((racine ? racine + " " : "") + ".elastic iframe").length) {
458        video_resize(racine);
459        $(window).on("resize", function () {
460          video_resize(racine);
461        });
462        window.clearInterval(video_iframe_intervalID[racine]);
463      }
464    }, 1000);
465  }
466}
467function video_resize(racine) {
468  $((racine ? racine + " " : "") + ".elastic").each(function () {
469    var maxHeight = 600;
470    var newWidth = $(this).attr("elasticwidth") ? $($(this).attr("elasticwidth")).width() : $(this).width();
471    if (newWidth > 1000) newWidth = 1000;
472    var aspectRatio = $(this).data("aspectRatio");
473    if (!aspectRatio) aspectRatio = 1;
474    var newHeight = newWidth * parseFloat(aspectRatio);
475
476    /*
477    if( newHeight>maxHeight )
478    {
479        newHeight = maxHeight;
480        newWidth = newHeight / parseFloat( aspectRatio );
481    }
482    */
483
484    var el = $(this).find("iframe");
485    el.width(newWidth + "px").height(newHeight + "px");
486  });
487}
488
489/*****************************************************************************************/
490/*      Commentaires et forum                                                            */
491/*****************************************************************************************/
492
493function ini_formulaire_commentaires() {
494  init_form('formulaire_commentaire');
495  $('#formulaire_commentaire button[type=submit]').on('click', post_message_commentaire);
496  init_form('formulaire_message_forum');
497  $('#formulaire_message_forum button[type=submit]').on('click', post_message_forum);
498  $('#fakeform').on('click', affiche_formulaire_commentaire);
499}
500function affiche_formulaire_commentaire() {
501  $('#fakeform').hide();
502  $('.note-editor').show();
503}
504function ini_commentaires() {
505  $('.modifier_commentaire').each(function () {
506    $(this).attr('rel', $(this).attr('href'));
507    $(this).attr('href', 'javascript:void(0);');
508    $(this).on('click', function () {
509      popup_modifier_commentaire($(this).attr('rel'));
510    });
511  });
512  $('.supprimer_commentaire').each(function () {
513    $(this).attr('rel', $(this).attr('href'));
514    $(this).attr('href', 'javascript:void(0);');
515    $(this).on('click', function () {
516      supprimer_commentaire($(this).attr('rel'));
517    });
518  });
519}
520function ini_forum() {
521  // Sujets du forum
522
523  $('.nouveau_sujet').each(function () {
524    $(this).attr('rel', $(this).attr('href'));
525    $(this).attr('href', 'javascript:void(0);');
526    $(this).on('click', function () {
527      popup_nouveau_sujet($(this).attr('rel'));
528    });
529  });
530  $('.modifier_sujet_forum').each(function () {
531    $(this).attr('rel', $(this).attr('href'));
532    $(this).attr('href', 'javascript:void(0);');
533    $(this).on('click', function () {
534      popup_modifier_sujet($(this).attr('rel'));
535    });
536  });
537  $('.supprimer_sujet_forum').each(function () {
538    $(this).attr('rel', $(this).attr('href'));
539    $(this).attr('href', 'javascript:void(0);');
540    $(this).on('click', function () {
541      supprimer_sujet($(this).attr('rel'));
542    });
543  });
544
545  // Messages du forum
546
547  $('.modifier_message_forum').each(function () {
548    $(this).attr('rel', $(this).attr('href'));
549    $(this).attr('href', 'javascript:void(0);');
550    $(this).on('click', function () {
551      popup_modifier_message_forum($(this).attr('rel'));
552    });
553  });
554  $('.supprimer_message_forum').each(function () {
555    $(this).attr('rel', $(this).attr('href'));
556    $(this).attr('href', 'javascript:void(0);');
557    $(this).on('click', function () {
558      supprimer_message($(this).attr('rel'));
559    });
560  });
561  $('.liste.forum-message .moderable .modifier_message_forum').each(function () {
562    popup_modifier_message_forum($(this).attr('rel'));
563  });
564}
565
566// Création d'un commentaire
567
568function post_message_commentaire() {
569  ajax_post('formulaire_commentaire', "Commentaire", refresh_commentaires);
570  return false;
571}
572
573// Création d'un message du forum
574
575function post_message_forum() {
576  ajax_post('formulaire_message_forum', "Message du forum", refresh_forum);
577  return false;
578}
579
580// Création d'un sujet de forum
581
582function popup_nouveau_sujet(url) {
583  $.ajax({
584    url: url,
585    success: function success(response) {
586      $("#multi_modal").html(response);
587      $('#multi_modal .modal-footer .btn-success').on('click', do_nouveau_sujet);
588      add_nested_modal('multi_modal');
589      init_form('form_nouveau_sujet');
590    }
591  });
592}
593function do_nouveau_sujet() {
594  ajax_post('form_nouveau_sujet', 'Nouveau sujet', function () {
595    remove_nested_modal('multi_modal');
596    refresh_forum();
597  });
598}
599
600// Modification d'un sujet de forum
601
602function popup_modifier_sujet(url) {
603  $.ajax({
604    url: url,
605    success: function success(response) {
606      $("#multi_modal").html(response);
607      $('#multi_modal .modal-footer .btn-success').on('click', do_edit_sujet);
608      add_nested_modal('multi_modal');
609      init_form('form_edit_sujet');
610    }
611  });
612}
613function do_edit_sujet() {
614  ajax_post('form_edit_sujet', "Modification d'un sujet", function () {
615    remove_nested_modal('multi_modal');
616    refresh_forum();
617  });
618}
619
620// Modification d'un commentaire
621
622function popup_modifier_commentaire(url) {
623  $.ajax({
624    url: url,
625    success: function success(response) {
626      $("#multi_modal").html(response);
627      $('#multi_modal .modal-footer .btn-success').on('click', do_modifier_commentaire);
628      add_nested_modal('multi_modal');
629      init_form('form_edit_message');
630    }
631  });
632}
633function do_modifier_commentaire() {
634  ajax_post('form_edit_message', "Modification d'un commentaire", function () {
635    remove_nested_modal('multi_modal');
636    refresh_commentaires();
637  });
638}
639
640// Modification d'un message de forum
641
642function popup_modifier_message_forum(url) {
643  $.ajax({
644    url: url,
645    success: function success(response) {
646      $("#multi_modal").html(response);
647      $('#multi_modal .modal-footer .btn-success').on('click', do_modifier_confirmation_forum);
648      add_nested_modal('multi_modal');
649      init_form('form_edit_message');
650    }
651  });
652}
653function do_modifier_confirmation_forum(url, texte, rubrique_id, refresh_fn) {
654  ajax_post('form_edit_message', "Modification d'un message du forum", function () {
655    remove_nested_modal('multi_modal');
656    refresh_forum();
657  });
658}
659
660// Suppression d'un commentaire, d'un sujet de forum, d'un message de forum
661
662function supprimer_commentaire(url) {
663  showConfirmMessage('Suppression d\'un message', 'Etes-vous sûr de vouloir supprimer ce message ?', function () {
664    supprimer_confirmation_forum_do(url, refresh_commentaires);
665  });
666}
667function supprimer_message(url) {
668  showConfirmMessage('Suppression d\'un message', 'Etes-vous sûr de vouloir supprimer ce message ?', function () {
669    supprimer_confirmation_forum_do(url, refresh_forum);
670  });
671}
672function supprimer_sujet(url) {
673  showConfirmMessage('Suppression d\'un sujet', 'Etes-vous sûr de vouloir supprimer ce sujet ?<br/>Tout les messages seront définitivement perdus.', function () {
674    supprimer_confirmation_forum_do(url, refresh_forum);
675  });
676}
677function supprimer_confirmation_forum_do(url, refresh_fn) {
678  $.ajax({
679    type: "POST",
680    url: url,
681    headers: {
682      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
683    },
684    data: {},
685    dataType: 'json',
686    success: function success(response) {
687      remove_nested_modal('confirmPop');
688      if (response.status == 200) {
689        refresh_fn();
690      } else {
691        showInformationMessage("Suppression", response.message);
692      }
693    }
694  });
695}
696function refresh_commentaires() {
697  var url = $('#messages_commentaires').attr('rel');
698  $.ajax({
699    url: url,
700    success: function success(response) {
701      $('#messages_commentaires').html(response);
702      $('#nouveau_commentaire').summernote('reset');
703      ini_commentaires();
704    }
705  });
706}
707function refresh_forum() {
708  location.reload();
709}
710
711/*****************************************************************************************/
712/*      Commentaires GIPHY                                                               */
713/*****************************************************************************************/
714
715function ini_giphy() {
716  $('#selectionne_commentaire').on('click', function () {
717    $('#selectionne_commentaire').addClass("actif");
718    $('#selectionne_giphy').removeClass("actif");
719    $('#formulaire_commentaire, #formulaire_message_forum').css('display', 'block');
720    $('#formulaire_giphy').css('display', 'none');
721  });
722  $('#selectionne_giphy').on('click', function () {
723    $('#selectionne_commentaire').removeClass("actif");
724    $('#selectionne_giphy').addClass("actif");
725    $('#formulaire_commentaire, #formulaire_message_forum').css('display', 'none');
726    $('#formulaire_giphy').css('display', 'block');
727  });
728  $('button.add_giphy').on('click', function () {
729    var sujet_id = $(this).parents('form').attr('rel');
730    add_giphy(sujet_id);
731  });
732}
733function add_giphy(sujet_id) {
734  $.ajax({
735    type: "POST",
736    url: "/forum/explorateur_giphy/" + sujet_id,
737    headers: {
738      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
739    },
740    data: {},
741    success: function success(response) {
742      $("#multi_modal").html(response);
743      add_nested_modal('multi_modal');
744      init_giphy_buttons(sujet_id);
745    }
746  });
747}
748function set_giphy(sujet_id, keyword, title, page) {
749  $.ajax({
750    type: "POST",
751    url: "/forum/get_giphy/" + sujet_id,
752    headers: {
753      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
754    },
755    data: {
756      keyword: keyword,
757      title: title,
758      page: page
759    },
760    success: function success(response) {
761      if (page == 1) {
762        $('#giphy_liste_medias').html(response);
763        $('#giphy_pop').animate({
764          scrollTop: 0
765        }, 'slow');
766      } else {
767        $('.giphy_more').remove();
768        $('#liste_medias_giphy').append(response);
769      }
770      init_giphy_buttons(sujet_id);
771    }
772  });
773}
774function init_giphy_buttons(sujet_id) {
775  $('#giphy_retour').on('click', function () {
776    set_giphy(sujet_id, "", "", 1);
777  });
778  $('.theme_giphy').on('click', function () {
779    var mot_clef = $(this).attr('rel').substring(0, $(this).attr('rel').indexOf(","));
780    var title = $(this).attr('rel').substring($(this).attr('rel').indexOf(",") + 1);
781    set_giphy(sujet_id, mot_clef, title, 1);
782  });
783  $('#giphy_search').on('click', function () {
784    var mot_clef = $('#giphy_sujet').val();
785    set_giphy(sujet_id, mot_clef, "", 1);
786  });
787  $('.preview_giphy').on('click', add_giphy_gif);
788  $('.giphy_more').on('click', function () {
789    var sujet_id = $('#forum_sujet_id').val();
790    var mot_clef = $('#giphy_sujet').val();
791    var title = $('#giphy_title').val();
792    var page = parseInt($('#giphy_page').val()) + 1;
793    $('#giphy_page').val(page);
794    set_giphy(sujet_id, mot_clef, title, page);
795  });
796}
797function add_giphy_gif() {
798  var query = $('#giphy_sujet').val();
799  var title = $(this).attr('alt');
800  var url = $(this).attr('src');
801  var id = $(this).attr('rel');
802  var html = "<p>Ajout de l'image en cours...</p>" + "<div class='text-center my-5'><div class='progress' role='progressbar' aria-valuenow='100' aria-valuemin='0' aria-valuemax='100'>" + "<div class='progress-bar progress-bar-striped progress-bar-animated' style='width: 100%'></div>" + "</div></div>";
803  $("#giphy_liste_medias").html(html);
804  $('#giphy_query').val(query);
805  $('#giphy_title').val(title);
806  $('#giphy_id').val(id);
807  $('#giphy_url').val(url);
808  $('#formulaire_giphy [name=messagepourletest2]').val(Date.now()); // anti-robot : rempli uniquement par le JS
809  $('#formulaire_giphy').submit();
810}
811
812/*****************************************************************************************/
813/*      Livre d'or                                                                       */
814/*****************************************************************************************/
815
816function ini_livredor() {
817  var form_racine = 'message_livre_form';
818  $('#' + form_racine + ' button').on('click', post_message_livredor);
819  init_form(form_racine);
820}
821function post_message_livredor() {
822  ajax_post('message_livre_form', "Message du livre d'or", refresh_livredor);
823  return false;
824}
825function refresh_livredor() {
826  var form_racine = 'message_livre_form';
827  $('#' + form_racine).find('input, textarea').val("");
828  location.reload();
829}
830
831/*****************************************************************************************/
832/*      Widget A La Une                                                                  */
833/*****************************************************************************************/
834
835function ini_widget_a_la_une() {
836  if ($(".widget_a_la_une.vertical").length) {
837    $(".widget_a_la_une").each(function () {
838      ini_widget_slidant($(this), widget_a_la_une_direction, widget_a_la_une_defilement_auto);
839    });
840  }
841}
842
843/*****************************************************************************************/
844/*      Widgets Evenement                                                                */
845/*****************************************************************************************/
846
847function ini_widgets_evenements() {
848  if ($(".grand_widget.widget_evenement.defilant").length) {
849    $(".grand_widget.widget_evenement").each(function () {
850      ini_widget_slidant($(this), 1, false);
851    });
852  }
853}
854
855/*****************************************************************************************/
856/*      Widgets Evenement                                                                */
857/*****************************************************************************************/
858
859function ini_widget_recherche() {
860  $('.widget_recherche form').each(function () {
861    init_form($(this).attr('id'));
862  });
863}
864
865/*****************************************************************************************/
866/*      Widget réservations                                                              */
867/*****************************************************************************************/
868
869function ini_widget_reservations() {
870  $('.widget_reservations').each(function () {
871    var identifiant = $(this).attr('id');
872    maj_infos_creneaux_widget_reservation(identifiant);
873    $("#" + identifiant + "_date, #" + identifiant + "_type_equipement").on('change', function () {
874      maj_infos_creneaux_widget_reservation($(this).parents('.widget_reservations').attr('id'));
875    });
876    $(this).find('form').each(function () {
877      init_form($(this).attr('id'));
878    });
879  });
880}
881function maj_infos_creneaux_widget_reservation(identifiant) {
882  $.ajax({
883    type: "POST",
884    url: '/widgets/creneaux-disponibles',
885    dataType: "json",
886    data: {
887      date: $("#" + identifiant + "_date").val(),
888      type: $("#" + identifiant + "_type_equipement").val()
889    },
890    headers: {
891      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
892    },
893    success: function success(response) {
894      if (response.nb == 0) $("#" + identifiant + " .infos_creneau").html("<p>Aucun créneau disponible</p>");else $("#" + identifiant + " .infos_creneau").html("<p><strong>" + response.nb + "</strong> créneau" + (response.nb > 1 ? "x" : "") + " disponible" + (response.nb > 1 ? "s" : "") + "</p>");
895    }
896  });
897}
898
899/*****************************************************************************************/
900/*      Widget RSS                                                                       */
901/*****************************************************************************************/
902
903function ini_widget_rss() {
904  $('.widget_rss, .widget_rss_fede').each(function () {
905    var identifiant = $(this).attr('id');
906    var association_widget_id = $(this).attr('data-id');
907    var section_id = $(this).attr('data-section_id');
908    var discipline_id = $(this).attr('data-discipline_id');
909    var groupe_id = $(this).attr('data-groupe_id');
910    var saison_id = $(this).attr('data-saison_id');
911    var taille = 'PETIT';
912    if ($(this).hasClass('grand_widget')) taille = 'GRAND';
913    $.ajax({
914      type: "POST",
915      url: '/widgets/rss-content',
916      data: {
917        association_widget_id: association_widget_id,
918        section_id: section_id,
919        discipline_id: discipline_id,
920        groupe_id: groupe_id,
921        saison_id: saison_id,
922        taille: taille
923      },
924      headers: {
925        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
926      },
927      success: function success(response) {
928        $('#' + identifiant + " .content").html(response);
929      }
930    });
931  });
932}
933
934/*****************************************************************************************/
935/*      Widget Calendrier                                                                */
936/*****************************************************************************************/
937
938function ini_widget_calendrier() {
939  $('.widget_calendrier').each(function () {
940    var date = $(this).attr('data-date');
941    show_calendrier($(this), date);
942  });
943}
944function ini_calendrier(calendrier) {
945  $(calendrier).find('[data-date]').on('click', function () {
946    var calendrier = $(this).parents('.widget_calendrier');
947    var date = $(this).attr('data-date');
948    show_calendrier(calendrier, date);
949  });
950  $(calendrier).find('[data-illuminate]').on('mouseover', function () {
951    var calendrier = $(this).parents('.widget_calendrier');
952    var days = $(this).attr('data-illuminate').split(', ');
953    illuminate_calendrier(calendrier, days);
954  });
955  $(calendrier).find('[data-illuminate]').on('mouseleave', function () {
956    var calendrier = $(this).parents('.widget_calendrier');
957    var days = $(this).attr('data-illuminate').split(', ');
958    stop_illuminate_calendrier(calendrier, days);
959  });
960}
961function show_calendrier(calendrier, date) {
962  var identifiant = $(calendrier).attr('id');
963  var association_widget_id = $(calendrier).attr('data-id');
964  var section_id = $(calendrier).attr('data-section_id');
965  var discipline_id = $(calendrier).attr('data-discipline_id');
966  var groupe_id = $(calendrier).attr('data-groupe_id');
967  var saison_id = $(calendrier).attr('data-saison_id');
968  var taille = 'PETIT';
969  if ($(calendrier).hasClass('grand_widget')) taille = 'GRAND';
970  $.ajax({
971    type: "POST",
972    url: '/widgets/calendrier-content',
973    data: {
974      association_widget_id: association_widget_id,
975      date: date,
976      section_id: section_id,
977      discipline_id: discipline_id,
978      groupe_id: groupe_id,
979      saison_id: saison_id,
980      taille: taille
981    },
982    headers: {
983      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
984    },
985    success: function success(response) {
986      $('#' + identifiant + ' [data-bs-toggle="tooltip"]').each(function () {
987        var tooltip = bootstrap.Tooltip.getOrCreateInstance($(this));
988        tooltip.dispose();
989      });
990      $('#' + identifiant + " .content").html(response);
991      ini_calendrier($(calendrier));
992      $('#' + identifiant + ' [data-bs-toggle="tooltip"]').tooltip();
993    }
994  });
995}
996function illuminate_calendrier(calendrier, days) {
997  var str = '';
998  for (var i = 0; i < days.length; i++) {
999    str += (str ? ',' : '') + '[data-jour=' + days[i] + "]";
1000  }
1001  $(calendrier).find(str).addClass('illuminate');
1002}
1003function stop_illuminate_calendrier(calendrier, days) {
1004  var str = '';
1005  for (var i = 0; i < days.length; i++) {
1006    str += (str ? ',' : '') + '[data-jour=' + days[i] + "]";
1007  }
1008  $(calendrier).find(str).removeClass('illuminate');
1009}
1010
1011/*****************************************************************************************/
1012/*      Widget Flux                                                                      */
1013/*****************************************************************************************/
1014
1015function ini_widget_flux() {
1016  $('.widget_flux').each(widget_flux);
1017}
1018function widget_flux() {
1019  var identifiant = $(this).attr('id');
1020  var association_widget_id = $(this).attr('data-id');
1021  var section_id = $(this).attr('data-section_id');
1022  var discipline_id = $(this).attr('data-discipline_id');
1023  var groupe_id = $(this).attr('data-groupe_id');
1024  var saison_id = $(this).attr('data-saison_id');
1025  var page = $(this).attr('data-page');
1026  var taille = 'PETIT';
1027  if ($(this).hasClass('grand_widget')) taille = 'GRAND';
1028  var div_widget = $(this);
1029  page = parseInt(page) + 1;
1030  $.ajax({
1031    type: "POST",
1032    url: '/widgets/flux-content',
1033    data: {
1034      association_widget_id: association_widget_id,
1035      section_id: section_id,
1036      discipline_id: discipline_id,
1037      groupe_id: groupe_id,
1038      saison_id: saison_id,
1039      page: page,
1040      taille: taille
1041    },
1042    headers: {
1043      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1044    },
1045    success: function success(response) {
1046      div_widget.attr('data-page', page);
1047      $('#' + identifiant + " .content .suite_widget_flux").remove();
1048      $('#' + identifiant + " .content").append(response);
1049      $('#' + identifiant + " .content .suite_widget_flux").on('click', function () {
1050        $(this).parents('.widget_flux').each(widget_flux);
1051      });
1052      ini_video('#' + identifiant + ' .page-' + page);
1053    }
1054  });
1055}
1056
1057/*****************************************************************************************/
1058/*      Widgets avec section zoomable (Partenaires, pubs)                                */
1059/*****************************************************************************************/
1060
1061function ini_widgets_avec_zooms() {
1062  $('.liste-avec-zoom').each(function () {
1063    widget_avec_zoom($(this));
1064  });
1065}
1066function widget_avec_zoom(widget) {
1067  var i = 0;
1068  $(widget).find('.element-zoomable').each(function () {
1069    $(this).data("numero", i++);
1070    $(this).bind('click', function () {
1071      var bloc = $(this).parents('.liste-avec-zoom');
1072      widget_zoom_change_photo($(bloc), $(this).data("numero"));
1073      var timer = $(bloc).data("timer");
1074      clearInterval(timer);
1075      return false;
1076    });
1077  });
1078  $(widget).data("actual", 0);
1079  var timer = setInterval(function () {
1080    $(widget).data("actual", $(widget).data("actual") + 1);
1081    widget_zoom_change_photo($(widget), $(widget).data("actual"));
1082  }, 4000);
1083  $(widget).data("timer", timer);
1084}
1085function widget_zoom_change_photo(bloc, numero) {
1086  var agrandie = $(bloc).find('.agrandie');
1087  numero = numero % $(bloc).find('.liste_photos a').length;
1088  var element_choisi = $(bloc).find('.liste_photos a')[numero];
1089  $(bloc).find('.liste_photos img').addClass('desaturate');
1090  $(element_choisi).find('img').removeClass('desaturate');
1091  $(agrandie).attr('href', $(element_choisi).attr('href'));
1092  $(agrandie).attr('title', $(element_choisi).attr('title'));
1093  $(agrandie).find('img').attr('src', $(element_choisi).attr('rel'));
1094}
1095
1096/*****************************************************************************************/
1097/*      Widget slidant (A la une, évènements)                                            */
1098/*****************************************************************************************/
1099
1100function ini_widget_slidant(widget, direction, auto) {
1101  var nb_defilement = $(widget).find(".defilement").length;
1102  $(widget).data("nb_defilement", nb_defilement);
1103  $(widget).data("direction", direction);
1104  $(widget).data("auto", auto);
1105  init_scroll($(widget));
1106  height_scroll($(widget));
1107  timer2 = setInterval(function () {
1108    height_scroll($(widget));
1109  }, 1000);
1110  $(window).bind('resize', function () {
1111    height_scroll($(widget));
1112  });
1113  if (nb_defilement > 1) {
1114    if (auto) {
1115      if (direction == 1) var timer = setInterval(function () {
1116        right_scroll($(widget));
1117      }, 7000);else var timer = setInterval(function () {
1118        bottom_scroll($(widget));
1119      }, 7000);
1120      $(widget).data("timer", timer);
1121    }
1122    if (direction == 1) {
1123      $(widget).find(".defilement_gauche").show();
1124      $(widget).find(".defilement_droite").show();
1125    } else {
1126      $(widget).find(".defilement_haut").show();
1127      $(widget).find(".defilement_bas").show();
1128    }
1129    $(widget).hover(function () {
1130      if (auto) {
1131        var timer = $(widget).data("timer");
1132        clearInterval(timer);
1133      }
1134    }, function () {
1135      if (auto) {
1136        var timer = $(widget).data("timer");
1137        if (direction == 1) timer = setInterval(function () {
1138          right_scroll($(widget));
1139        }, 7000);else timer = setInterval(function () {
1140          bottom_scroll($(widget));
1141        }, 7000);
1142        $(widget).data("timer", timer);
1143      }
1144    });
1145  }
1146}
1147function block_scroll_buttons(widget) {
1148  $(widget).find(".defilement_bas img, .defilement_haut img, .defilement_gauche img, .defilement_droite img").unbind("click");
1149}
1150function allow_scroll_buttons(widget) {
1151  // au click sur la flèche de défilement gauche
1152  $(widget).find(".defilement_gauche img").bind("click", function (event) {
1153    event.stopPropagation();
1154    left_scroll($(widget));
1155  });
1156
1157  // au click sur la flèche de défilement droite
1158  $(widget).find(".defilement_droite img").bind("click", function (event) {
1159    event.stopPropagation();
1160    right_scroll($(widget));
1161  });
1162
1163  // au click sur la flèche de défilement gauche
1164  $(widget).find(".defilement_haut img").bind("click", function (event) {
1165    event.stopPropagation();
1166    top_scroll($(widget));
1167  });
1168
1169  // au click sur la flèche de défilement droite
1170  $(widget).find(".defilement_bas img").bind("click", function (event) {
1171    event.stopPropagation();
1172    bottom_scroll($(widget));
1173  });
1174}
1175function init_scroll(widget) {
1176  var nb_defilement = $(widget).data("nb_defilement");
1177  var direction = $(widget).data("direction");
1178  allow_scroll_buttons($(widget));
1179
1180  // déplace la derniere liste de défilement en premiere position
1181  if (nb_defilement > 2) {
1182    move_last_scroll($(widget));
1183  } else if (nb_defilement < 2) {
1184    $(widget).find(".defilement_gauche img, .defilement_droite img, .defilement_haut img, .defilement_bas img").hide();
1185    $(widget).find(".liste_defilement").css("left", 0).css("top", 0);
1186  } else {
1187    var last_scroll = $(widget).find(".liste_defilement .defilement:last");
1188    var clone_last_scroll = last_scroll.clone();
1189    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
1190  }
1191
1192  // défini la taille du bloc contenant toutes les div de défilement
1193  if (nb_defilement < 2) {
1194    $(widget).find(".liste_defilement").css("width", "100%").css("height", "100%");
1195    $(widget).find(".liste_defilement .defilement").css("width", "100%").css("height", "100%");
1196  } else {
1197    if (direction == 1) {
1198      $(widget).find(".liste_defilement").css("width", "300%").css("left", "-100%");
1199      $(widget).find(".liste_defilement .defilement").css("width", "33.333%");
1200    } else {
1201      $(widget).find(".liste_defilement").css("height", "300%").css("top", "-100%");
1202      $(widget).find(".liste_defilement .defilement").css("height", "33.333%");
1203    }
1204  }
1205}
1206function height_scroll(widget) {
1207  var nb_defilement = $(widget).data("nb_defilement");
1208  var direction = $(widget).data("direction");
1209  $(widget).find(".defilement, .a_la_une").css('height', 'auto');
1210  var heights = $(widget).find(".defilement").map(function () {
1211    return $(this).height();
1212  }).get();
1213  var maxHeight = Math.max.apply(null, heights);
1214  if (direction == 1 || nb_defilement < 2) $(widget).find(".liste_defilement").height(maxHeight);else {
1215    $(widget).find(".liste_defilement").height(3 * maxHeight);
1216    $(widget).find(".contenu_defilement").height(maxHeight);
1217  }
1218  $(widget).find(".defilement, .a_la_une").css('height', maxHeight + 'px');
1219}
1220function move_last_scroll(widget) {
1221  var nb_defilement = $(widget).data("nb_defilement");
1222  var last_scroll = "";
1223  var clone_last_scroll = "";
1224  if (nb_defilement > 2) {
1225    last_scroll = $(widget).find(".liste_defilement .defilement:last");
1226    clone_last_scroll = last_scroll.clone();
1227    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
1228    last_scroll.remove();
1229  } else {
1230    last_scroll = $(widget).find(".liste_defilement .defilement:last");
1231    last_scroll.remove();
1232    last_scroll = $(widget).find(".liste_defilement .defilement:last");
1233    clone_last_scroll = last_scroll.clone();
1234    $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0).before(clone_last_scroll);
1235  }
1236}
1237function move_first_scroll(widget) {
1238  var nb_defilement = $(widget).data("nb_defilement");
1239  var first_scroll = "";
1240  var clone_first_scroll = "";
1241  if (nb_defilement > 2) {
1242    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
1243    clone_first_scroll = first_scroll.clone();
1244    $(widget).find(".liste_defilement .defilement:last").after(clone_first_scroll);
1245    first_scroll.remove();
1246  } else {
1247    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
1248    first_scroll.remove();
1249    first_scroll = $(widget).find(".liste_defilement .defilement:first").css("margin-left", 0).css("margin-top", 0);
1250    clone_first_scroll = first_scroll.clone();
1251    $(widget).find(".liste_defilement .defilement:last").after(clone_first_scroll);
1252  }
1253}
1254
1255// Animations
1256
1257function left_scroll(widget) {
1258  block_scroll_buttons($(widget));
1259  var w = $(widget).find(".liste_defilement .defilement:first").width() + "px";
1260  $(widget).find(".liste_defilement .defilement:first").animate({
1261    marginLeft: w
1262  }, 500, function () {
1263    move_last_scroll($(widget));
1264    allow_scroll_buttons(widget);
1265  });
1266}
1267function right_scroll(widget) {
1268  block_scroll_buttons($(widget));
1269  var w = $(widget).find(".liste_defilement .defilement:first").width() + "px";
1270  $(widget).find(".liste_defilement .defilement:first").animate({
1271    marginLeft: "-" + w
1272  }, 500, function () {
1273    move_first_scroll($(widget));
1274    allow_scroll_buttons(widget);
1275  });
1276}
1277function top_scroll(widget) {
1278  block_scroll_buttons($(widget));
1279  var heights = $(widget).find(".defilement").map(function () {
1280    return $(this).height();
1281  }).get();
1282  var h = Math.max.apply(null, heights) + "px";
1283  $(widget).find(".liste_defilement .defilement:first").animate({
1284    marginTop: h
1285  }, 500, function () {
1286    move_last_scroll($(widget));
1287    allow_scroll_buttons(widget);
1288  });
1289}
1290function bottom_scroll(widget) {
1291  block_scroll_buttons($(widget));
1292  var heights = $(widget).find(".defilement").map(function () {
1293    return $(this).height();
1294  }).get();
1295  var h = Math.max.apply(null, heights) + "px";
1296  $(widget).find(".liste_defilement .defilement:first").animate({
1297    marginTop: "-" + h
1298  }, 500, function () {
1299    move_first_scroll($(widget));
1300    allow_scroll_buttons(widget);
1301  });
1302}
1303
1304/*****************************************************************************************/
1305/*      Newsletter                                                                       */
1306/*****************************************************************************************/
1307function ini_newsletter() {
1308  if ($('#newsletter_form').length) init_form('newsletter_form');
1309}
1310
1311/*****************************************************************************************/
1312/*      Contact                                                                          */
1313/*****************************************************************************************/
1314function ini_contact() {
1315  if ($('#contact_form').length) init_form('contact_form');
1316  if ($('#footer_contact_form').length) {
1317    init_form('footer_contact_form');
1318    $('#footer_contact_form button[type=submit]').on('click', function () {
1319      ajax_post('footer_contact_form', "Contact", function () {
1320        showInformationMessage('Contact', "Merci, c'est envoyé !");
1321      });
1322      return false;
1323    });
1324  }
1325}
1326
1327/*****************************************************************************************/
1328/*      Convocations et covoiturage                                                      */
1329/*****************************************************************************************/
1330
1331function ini_evenement() {
1332  if ($('.evenement_inscription input[name^=covoiturage]').length) {
1333    mise_a_jour_covoiturage();
1334    $('.evenement_inscription input[name^=covoiturage]').bind('click', function () {
1335      mise_a_jour_covoiturage();
1336      sauve_covoiturage($(this));
1337    });
1338    $('.evenement_inscription select[name^=nombre_places_besoin], .evenement_inscription select[name^=nombre_places_proposees]').bind('change', function () {
1339      sauve_covoiturage($(this));
1340    });
1341  }
1342  if ($('input[name=covoiturage_type_covoiturage]').length) {
1343    mise_a_jour_covoiturage();
1344    $('.formulaire_covoiturage input[name=covoiturage_type_covoiturage]').bind('click', function () {
1345      mise_a_jour_covoiturage();
1346    });
1347  }
1348  $('.convocation_oui').on('click', convocation_oui);
1349  $('.convocation_non').on('click', convocation_non);
1350  $('.convocation_Annulation').on('click', convocation_Annulation);
1351}
1352function convocation_oui() {
1353  do_reponse_convocation($(this), 1);
1354}
1355function convocation_non() {
1356  do_reponse_convocation($(this), 0);
1357}
1358function convocation_Annulation() {
1359  do_reponse_convocation($(this), -1);
1360}
1361function do_reponse_convocation(e, reponse) {
1362  var evenement_id = e.attr('data-evenement_id');
1363  var membre_id = e.attr('data-membre_id');
1364  var convoques = e.attr('data-convoques');
1365  var post = {
1366    evenement_id: evenement_id,
1367    membre_id: membre_id,
1368    reponse: reponse
1369  };
1370  if ($('input#ual').length) post.ual = $('input#ual').val();
1371  $.ajax({
1372    type: 'POST',
1373    url: '/evenements/valide-presence',
1374    headers: {
1375      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1376    },
1377    data: post,
1378    dataType: 'JSON',
1379    success: function success(response) {
1380      if (response.errors && response.errors.length) {
1381        showInformationMessage("Inscription", response.errors.join("<br>"));
1382      } else if (response.message) {
1383        mise_a_jour_covoiturage();
1384        if (convoques == true) {
1385          mise_a_jour_convocations_evenement();
1386          mise_a_jour_liste_convoques();
1387        }
1388      }
1389    }
1390  });
1391}
1392function mise_a_jour_covoiturage() {
1393  $('.covoiturage_boutons').each(function () {
1394    if ($(this).find('input[name^=covoiturage]:checked').length) {
1395      switch ($(this).find('input[name^=covoiturage]:checked').val()) {
1396        case 'non':
1397          $(this).find('select[name^=nombre_places_besoin], select[name^=nombre_places_proposees]').prop('disabled', true);
1398          break;
1399        case 'besoin':
1400          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', false);
1401          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', true);
1402          break;
1403        case 'propose':
1404          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', true);
1405          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', false);
1406          break;
1407      }
1408    }
1409
1410    // Dans le formulaire
1411    if ($(this).find('input[name^=covoiturage_type_covoiturage]:checked').length) {
1412      switch ($(this).find('input[name^=covoiturage_type_covoiturage]:checked').val()) {
1413        case 'non':
1414          $(this).find('select[name^=nombre_places_besoin], select[name^=nombre_places_proposees]').prop('disabled', true);
1415          break;
1416        case 'besoin':
1417          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', false);
1418          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', true);
1419          break;
1420        case 'propose':
1421          $(this).find('select[name^=nombre_places_besoin]').prop('disabled', true);
1422          $(this).find('select[name^=nombre_places_proposees]').prop('disabled', false);
1423          break;
1424      }
1425    }
1426  });
1427}
1428function mise_a_jour_convocations_evenement() {
1429  $('#presence').load(page_courante + ' #presence > div', function () {
1430    ini_evenement();
1431  });
1432}
1433function mise_a_jour_liste_convoques() {
1434  $('#participants').load(page_courante + ' #participants > *');
1435}
1436function sauve_covoiturage(bt) {
1437  var racine = $(bt).parents('.covoiturage_boutons');
1438  var evenement_id = $('.evenement_inscription #covoiturage_evenement_id').val();
1439  var ual = $('#covoiturage_autoconnectkey').val();
1440  var membre_id = racine.attr('rel');
1441  if (!ual) ual = $('input#ual').val();
1442  if ($(racine).find('input[name^=covoiturage]:checked').length) {
1443    var bt = $(racine).find('input[name^=covoiturage]:checked').val();
1444    switch (bt) {
1445      case 'non':
1446        var propose = 0;
1447        var besoin = 0;
1448        break;
1449      case 'besoin':
1450        var propose = 0;
1451        var besoin = $(racine).find('select[name^=nombre_places_besoin]').val();
1452        break;
1453      case 'propose':
1454        var propose = $(racine).find('select[name^=nombre_places_proposees]').val();
1455        var besoin = 0;
1456        break;
1457    }
1458    $.ajax({
1459      type: 'POST',
1460      url: '/evenements/valide-covoiturage',
1461      headers: {
1462        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1463      },
1464      data: {
1465        evenement_id: evenement_id,
1466        membre_id: membre_id,
1467        besoin: besoin,
1468        propose: propose,
1469        ual: ual
1470      },
1471      dataType: 'JSON',
1472      success: function success(response) {
1473        if (response.errors && response.errors.length) {
1474          showInformationMessage("Covoiturage", response.errors.join("<br>"));
1475        } else if (response.message) {
1476          $('#flash_alert_' + bt + "_" + membre_id).unpulse({
1477            times: 2,
1478            duration: 500
1479          });
1480          maj_detail_covoiturage();
1481        }
1482      }
1483    });
1484  }
1485}
1486function maj_detail_covoiturage() {
1487  if ($('#detail_covoiturage').length) {
1488    $('#detail_covoiturage').fadeOut("normal").load(page_courante + " #detail_covoiturage > *").fadeIn("normal");
1489  }
1490}
1491
1492/*****************************************************************************************/
1493/*      Recherches de partenaires                                                        */
1494/*****************************************************************************************/
1495
1496function ini_recherche_partenaire() {
1497  $('.creer_annonce').on('click', function () {
1498    creer_annonce($(this).attr('data-evenementid'));
1499  });
1500  $('.modifier_annonce').on('click', function () {
1501    modifier_annonce($(this).attr('data-annonceid'));
1502  });
1503  $('.supprimer_annonce').on('click', function () {
1504    supprimer_annonce($(this).attr('data-annonceid'));
1505  });
1506  $('.repondre_annonce').on('click', function () {
1507    repondre_annonce($(this).attr('data-annonceid'));
1508  });
1509}
1510
1511/* Création et modification d'annonce */
1512
1513function creer_annonce(evenement_id) {
1514  modifier_annonces_do(null, evenement_id);
1515}
1516function modifier_annonce(annonce_id) {
1517  modifier_annonces_do(annonce_id, null);
1518}
1519function modifier_annonces_do(annonce_id, evenement_id) {
1520  $.ajax({
1521    type: "POST",
1522    url: "/recherche-de-partenaires/edit-annonce-popup",
1523    data: {
1524      annonce_id: annonce_id,
1525      evenement_id: evenement_id
1526    },
1527    headers: {
1528      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1529    },
1530    success: function success(response) {
1531      $("#multi_modal").html(response);
1532      $('#multi_modal .modal-footer .btn-success').on('click', post_edit_annonce);
1533      add_nested_modal('multi_modal');
1534      var config = {
1535        height: 120,
1536        lang: 'fr-FR',
1537        toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
1538      };
1539      $("#edit_annonce_description").summernote(config);
1540      // $("#edit_annonce_description").on('summernote.paste', summernote_onPaste );
1541
1542      $('#multi_modal input, #multi_modal textarea').focus(function () {
1543        $('#multi_modal input, #multi_modal textarea').removeClass('is-invalid');
1544      });
1545      $('#multi_modal input, #multi_modal textarea').blur(function () {
1546        $('#multi_modal input, #multi_modal textarea').removeClass('is-invalid');
1547      });
1548    }
1549  });
1550}
1551function post_edit_annonce() {
1552  if ($('#edit_annonce_titre').val() == '') {
1553    $('#edit_annonce_titre').addClass('is-invalid');
1554  } else {
1555    modifier_confirmation_annonces_do($('#edit_annonce_id').val(), $('#edit_annonce_titre').val(), $('#edit_annonce_description').val(), $('#edit_annonce_type').val(), $('#edit_annonce_intention').val(), $('#edit_annonce_niveau').val(), $('#edit_annonce_evenement_id').val(), $('#edit_annonce_action_id').val(), $('#edit_annonce_membre_id').val(), refresh_annonces);
1556  }
1557}
1558function modifier_confirmation_annonces_do(annonce_id, titre, description, type, intention, niveau, evenement_id, action_id, membre_id, refresh_fn) {
1559  $.ajax({
1560    type: "POST",
1561    url: "/recherche-de-partenaires/edit-annonce",
1562    data: {
1563      annonce_id: annonce_id ? annonce_id : null,
1564      titre: titre,
1565      description: description,
1566      type: type,
1567      intention: intention,
1568      niveau: niveau,
1569      evenement_id: evenement_id,
1570      action_id: action_id,
1571      membre_id: membre_id,
1572      messagepourletest: $('#messagepourletest').val()
1573    },
1574    headers: {
1575      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1576    },
1577    'dataType': 'JSON',
1578    success: function success(response) {
1579      remove_nested_modal('multi_modal');
1580      if (response.status == 200) {
1581        refresh_fn();
1582      } else {
1583        showInformationMessage("Modification", response.message + "<br>" + response.errors.join("<br>"));
1584      }
1585    }
1586  });
1587}
1588
1589/* Suppression d'annonce */
1590
1591var annonce_a_supprimer = -1;
1592function supprimer_annonce(annonce_id) {
1593  annonce_a_supprimer = annonce_id;
1594  showConfirmMessage('Suppression d\'une recherche de partenaire', 'Etes-vous sûr de vouloir supprimer cette annonce ?', supprimer_annonce_confirmation);
1595}
1596function supprimer_annonce_confirmation() {
1597  supprimer_confirmation_annonce_do(refresh_annonces);
1598}
1599function supprimer_confirmation_annonce_do(refresh_fn) {
1600  $.ajax({
1601    type: "POST",
1602    url: "/recherche-de-partenaires/delete-annonce",
1603    data: {
1604      annonce_id: annonce_a_supprimer
1605    },
1606    headers: {
1607      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1608    },
1609    'dataType': 'JSON',
1610    success: function success(response) {
1611      remove_nested_modal('confirmPop');
1612      if (response.status == 200) {
1613        refresh_fn();
1614      } else {
1615        showInformationMessage("Suppression d'une annonce", response.message + "<br>" + response.errors.join("<br>"));
1616      }
1617    }
1618  });
1619}
1620
1621/* Répondre à une annonce */
1622
1623function repondre_annonce(annonce_id) {
1624  $.ajax({
1625    type: "POST",
1626    url: "/recherche-de-partenaires/reponse-annonce-popup",
1627    data: {
1628      annonce_id: annonce_id
1629    },
1630    headers: {
1631      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1632    },
1633    success: function success(response) {
1634      $("#multi_modal").html(response);
1635      $('#multi_modal .modal-footer .btn-success').on('click', post_repondre_annonce);
1636      add_nested_modal('multi_modal');
1637      var config = {
1638        height: 120,
1639        lang: 'fr-FR',
1640        toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
1641      };
1642      $("#edit_annonce_description").summernote(config);
1643      // $("#edit_annonce_description").on('summernote.paste', summernote_onPaste );
1644
1645      $('#multi_modal input, #multi_modal textarea').focus(function () {
1646        $('#multi_modal input').removeClass('is-invalid');
1647      });
1648      $('#multi_modal input, #multi_modal textarea').blur(function () {
1649        $('#multi_modal input').removeClass('is-invalid');
1650      });
1651    }
1652  });
1653}
1654function post_repondre_annonce() {
1655  if ($('#edit_annonce_description').val() == '') {
1656    // $('#cke_edit_annonce_description').addClass('is-invalid');
1657  } else {
1658    repondre_confirmation_annonces_do($('#edit_annonce_id').val(), $('#edit_annonce_description').val(), $('#edit_annonce_membre_id').val(), refresh_annonces);
1659  }
1660}
1661function repondre_confirmation_annonces_do(annonce_id, description, membre_id, refresh_fn) {
1662  $.ajax({
1663    type: "POST",
1664    url: "/recherche-de-partenaires/reponse-annonce",
1665    data: {
1666      annonce_id: annonce_id,
1667      description: description,
1668      membre_id: membre_id,
1669      messagepourletest: $('#messagepourletest').val()
1670    },
1671    headers: {
1672      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1673    },
1674    'dataType': 'JSON',
1675    success: function success(response) {
1676      remove_nested_modal('multi_modal');
1677      if (response.status == 200) {
1678        refresh_fn();
1679      } else {
1680        showInformationMessage("Reponse a une annonce", response.message + "<br>" + response.errors.join("<br>"));
1681      }
1682    }
1683  });
1684}
1685
1686/* Refresh */
1687
1688function refresh_annonces() {
1689  $('#messages_annonces_container').fadeOut("normal").load(page_courante + " #messages_annonces", function () {
1690    $('#messages_annonces_container').fadeIn("normal");
1691    ini_recherche_partenaire();
1692  });
1693}
1694
1695/*****************************************************************************************/
1696/*      Page liste des equipes                                                           */
1697/*****************************************************************************************/
1698
1699function ini_liste_equipes() {
1700  if ($('.liste.equipes').length) {
1701    set_height_element_liste_equipe();
1702    $(window).on('resize', set_height_element_liste_equipe);
1703  }
1704}
1705function set_height_element_liste_equipe() {
1706  var rule = '.liste.equipes .element-inline > div';
1707  normalize_height(rule, 16);
1708}
1709
1710/*****************************************************************************************/
1711/*      Page panier                                                                      */
1712/*****************************************************************************************/
1713
1714function ini_panier() {
1715  if ($('#panier').length) {
1716    init_form('panier');
1717    $('#panier .panier_zero').each(function () {
1718      $(this).bind('click', function () {
1719        $(this).parents('td').find('input.quantite').val(0);
1720        $('#panier').submit();
1721      });
1722    });
1723    $('#panier .quantite').each(function () {
1724      $(this).bind('change', function () {
1725        $('#panier').submit();
1726      });
1727    });
1728  }
1729  $('#facturation_rue, #facturation_codepostal, #facturation_ville').each(function () {
1730    verifie_regex($(this));
1731    $(this).on('keyup', function () {
1732      verifie_regex($(this));
1733    });
1734    $(this).on('change', function () {
1735      verifie_regex($(this));
1736    });
1737  });
1738  $('#form_adresses').bind('submit', function () {
1739    var erreur = 0;
1740    $('input.obligatoire, textarea.obligatoire, select.obligatoire').each(function () {
1741      if ($(this).val() == '') erreur = 1;
1742    });
1743    if (erreur == 1) {
1744      alert('Merci de saisir toutes les informations de facturation');
1745      return false;
1746    }
1747    $('#facturation_rue, #facturation_codepostal, #facturation_ville').each(function () {
1748      var regex_test = new RegExp($(this).attr('regex'));
1749      val = $(this).val();
1750      if (val && !regex_test.test(val)) {
1751        erreur = "Le champ \"" + $(this).parents('.form-group').find('label').text() + "\" est incorrect ou comporte des caractères interdits.";
1752      }
1753    });
1754    if (erreur) {
1755      alert(erreur);
1756      return false;
1757    }
1758    if (!is_email_valid($('#facturation_email').val())) {
1759      alert("L'email saisi dans l'adresse de facturation n'est pas valide");
1760      return false;
1761    }
1762    if ($('#livraison_email').length && $('#livraison_email').val() != '' && !is_email_valid($('#livraison_email').val())) {
1763      alert("L'email saisi dans l'adresse de livraison n'est pas valide");
1764      return false;
1765    }
1766  });
1767}
1768function is_email_valid(email) {
1769  var email_regex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1770  return email_regex.test(email);
1771}
1772function verifie_regex(input) {
1773  var regex_test = new RegExp(input.attr('regex'));
1774  val = input.val();
1775  if (val && !regex_test.test(val)) {
1776    // console.log( '"' + val + '" ne passe pas la REGEX ' + input.attr('regex'));
1777    input.addClass('is-invalid');
1778  } else {
1779    input.removeClass('is-invalid');
1780  }
1781}
1782
1783/*****************************************************************************************/
1784/*      Tunnel de commande                                                               */
1785/*****************************************************************************************/
1786
1787function ini_moyens_paiements() {
1788  maj_moyens_paiements();
1789  $('#choix_livraison input[name=mode_de_livraison]').on('change', function () {
1790    maj_mode_livraison();
1791  });
1792  $('#moyen_paiement input[name="moyen_de_paiement"]').on('change', function () {
1793    maj_moyens_paiements();
1794  });
1795}
1796function bouton_coupon() {}
1797function maj_moyens_paiements() {
1798  $('#moyen_paiement input[name="moyen_de_paiement"]').each(function () {
1799    if ($(this).is(':checked')) {
1800      $(this).parents('.groupe').find('.paiements_successifs').show();
1801      $(this).parents('.moyen').find('.modalites_paiements_fractionnes').show();
1802    } else {
1803      $(this).parents('.groupe').find('.paiements_successifs').hide();
1804      $(this).parents('.moyen').find('.modalites_paiements_fractionnes').hide();
1805    }
1806  });
1807  $('.popup_coupon').on('click', function () {
1808    popup_coupon($(this).attr('rel'));
1809  });
1810  $('.delete_coupon').on('click', function () {
1811    delete_coupon($(this));
1812  });
1813}
1814function maj_mode_livraison() {
1815  var modedelivraison_id = 0;
1816  var moyendepaiement_id = 0;
1817  var moyendepaiement_paiement_multiple = 0;
1818  var moyendepaiement_coupons_id = [];
1819  var moyendepaiement_coupons_montants = [];
1820  var moyendepaiement_coupons_codes = [];
1821  var moyendepaiement_coupons_codes_complementaires = [];
1822  if ($('#choix_livraison input[name=mode_de_livraison]:checked').length) modedelivraison_id = $('#choix_livraison input[name=mode_de_livraison]:checked').val();
1823  if ($('#moyen_paiement input[name=moyen_de_paiement]:checked').length) {
1824    var moyen_de_paiement = $('#moyen_paiement input[name=moyen_de_paiement]:checked').val();
1825    moyendepaiement_id = moyen_de_paiement.substring(0, moyen_de_paiement.indexOf('_'));
1826    moyendepaiement_paiement_multiple = moyen_de_paiement.substring(moyen_de_paiement.indexOf('_') + 1);
1827  }
1828  $('input[name^=moyendepaiement_coupons_id]').each(function () {
1829    moyendepaiement_coupons_id[moyendepaiement_coupons_id.length] = $(this).val();
1830  });
1831  $('input[name^=moyendepaiement_coupons_montants]').each(function () {
1832    moyendepaiement_coupons_montants[moyendepaiement_coupons_montants.length] = $(this).val();
1833  });
1834  $('input[name^=moyendepaiement_coupons_codes]:not([name^=moyendepaiement_coupons_codes_complementaires])').each(function () {
1835    moyendepaiement_coupons_codes[moyendepaiement_coupons_codes.length] = $(this).val();
1836  });
1837  $('input[name^=moyendepaiement_coupons_codes_complementaires]').each(function () {
1838    moyendepaiement_coupons_codes_complementaires[moyendepaiement_coupons_codes_complementaires.length] = $(this).val();
1839  });
1840  var parameters = {
1841    modedelivraison_id: modedelivraison_id,
1842    moyendepaiement_id: moyendepaiement_id,
1843    moyendepaiement_paiement_multiple: moyendepaiement_paiement_multiple,
1844    moyendepaiement_coupons_id: moyendepaiement_coupons_id,
1845    moyendepaiement_coupons_montants: moyendepaiement_coupons_montants,
1846    moyendepaiement_coupons_codes: moyendepaiement_coupons_codes,
1847    moyendepaiement_coupons_codes_complementaires: moyendepaiement_coupons_codes_complementaires
1848  };
1849  $.ajax({
1850    type: "POST",
1851    url: '/commande/paiement-et-livraison/choix',
1852    headers: {
1853      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
1854    },
1855    data: parameters,
1856    success: function success(response) {
1857      $('#choix_commande_paiement_livraison').html(response);
1858      ini_moyens_paiements();
1859    }
1860  });
1861}
1862function popup_coupon(moyendepaiement_coupons_id) {
1863  $.ajax({
1864    type: "GET",
1865    url: '/commande/paiement-et-livraison/popup-coupon',
1866    data: {
1867      moyendepaiement_id: moyendepaiement_coupons_id
1868    },
1869    success: function success(response) {
1870      $('#confirmPop').html(response);
1871      add_nested_modal('confirmPop');
1872      $('#confirmPop .modal-footer .btn[rel=success]').bind('click', add_coupon);
1873    }
1874  });
1875}
1876function add_coupon() {
1877  var moyendepaiement_coupon_id = $('#moyendepaiement_coupon_id').val();
1878  var moyendepaiement_coupon_value = parseFloat($('#moyendepaiement_coupon_value').val());
1879  var moyendepaiement_coupon_code = $('#moyendepaiement_coupon_code').val();
1880  var moyendepaiement_coupon_code_obligatoire = $('#moyendepaiement_coupon_code').hasClass('obligatoire');
1881  var moyendepaiement_coupon_code_complementaire = $('#moyendepaiement_coupon_code_complementaire').val();
1882  var moyendepaiement_coupon_code_complementaire_nom = $('#moyendepaiement_coupon_code_complementaire').attr('rel');
1883  var moyendepaiement_coupon_code_complementaire_obligatoire = $('#moyendepaiement_coupon_code_complementaire').hasClass('obligatoire');
1884  if (moyendepaiement_coupon_value > 0) {
1885    if (moyendepaiement_coupon_code_obligatoire && !moyendepaiement_coupon_code) {
1886      alert("Il est obligatoire de saisir la référence du coupon");
1887    } else if (moyendepaiement_coupon_code_complementaire_obligatoire && !moyendepaiement_coupon_code_complementaire) {
1888      alert("Il est obligatoire de compléter la case " + moyendepaiement_coupon_code_complementaire_nom);
1889    } else {
1890      remove_nested_modal('confirmPop');
1891      $('#coupons').append('<input type="hidden" name="moyendepaiement_coupons_id[]" value="' + moyendepaiement_coupon_id + '" >' + '<input type="hidden" name="moyendepaiement_coupons_montants[]" value="' + moyendepaiement_coupon_value + '">' + '<input type="hidden" name="moyendepaiement_coupons_codes[]" value="' + moyendepaiement_coupon_code + '">' + '<input type="hidden" name="moyendepaiement_coupons_codes_complementaires[]" value="' + moyendepaiement_coupon_code_complementaire + '">');
1892      maj_mode_livraison();
1893    }
1894  } else {
1895    alert("Le coupon doit avoir un montant supérieur à 0€");
1896  }
1897}
1898function delete_coupon(e) {
1899  $(e).parents('.coupon').remove();
1900  maj_mode_livraison();
1901}
1902
1903/*****************************************************************************************/
1904/*      Fonctions utilitaires                                                            */
1905/*****************************************************************************************/
1906function summernote_onPaste(_x, _x2) {
1907  return _summernote_onPaste.apply(this, arguments);
1908}
1909function _summernote_onPaste() {
1910  _summernote_onPaste = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e, ne) {
1911    var _this = this;
1912    var formatHTML, value, clipboardContents, _iterator, _step, item;
1913    return _regeneratorRuntime().wrap(function _callee$(_context) {
1914      while (1) switch (_context.prev = _context.next) {
1915        case 0:
1916          _context.prev = 0;
1917          formatHTML = false;
1918          value = '';
1919          _context.next = 5;
1920          return navigator.clipboard.read();
1921        case 5:
1922          clipboardContents = _context.sent;
1923          _iterator = _createForOfIteratorHelper(clipboardContents);
1924          _context.prev = 7;
1925          _iterator.s();
1926        case 9:
1927          if ((_step = _iterator.n()).done) {
1928            _context.next = 21;
1929            break;
1930          }
1931          item = _step.value;
1932          if (!item.types.includes("text/html")) {
1933            _context.next = 19;
1934            break;
1935          }
1936          formatHTML = true;
1937          _context.next = 15;
1938          return item.getType("text/html");
1939        case 15:
1940          value = _context.sent;
1941          _context.next = 18;
1942          return value.text();
1943        case 18:
1944          value = _context.sent;
1945        case 19:
1946          _context.next = 9;
1947          break;
1948        case 21:
1949          _context.next = 26;
1950          break;
1951        case 23:
1952          _context.prev = 23;
1953          _context.t0 = _context["catch"](7);
1954          _iterator.e(_context.t0);
1955        case 26:
1956          _context.prev = 26;
1957          _iterator.f();
1958          return _context.finish(26);
1959        case 29:
1960          if (!formatHTML) {
1961            _context.next = 34;
1962            break;
1963          }
1964          ne.preventDefault();
1965          setTimeout(function () {
1966            value = value.replace(/^<html>\r?\n<body>\r?\n/, "").replace(/\r?\n<\/body>\r?\n<\/html>$/, "");
1967            $(_this).summernote('pasteHTML', '<span>' + value + '</span>');
1968          }, 10);
1969          _context.next = 39;
1970          break;
1971        case 34:
1972          _context.next = 36;
1973          return navigator.clipboard.readText();
1974        case 36:
1975          value = _context.sent;
1976          ne.preventDefault();
1977          setTimeout(function () {
1978            value = value.replace(/\r?\n/g, '<br>');
1979            $(_this).summernote('pasteHTML', value);
1980          }, 10);
1981        case 39:
1982          _context.next = 44;
1983          break;
1984        case 41:
1985          _context.prev = 41;
1986          _context.t1 = _context["catch"](0);
1987          console.log(_context.t1.message);
1988        case 44:
1989        case "end":
1990          return _context.stop();
1991      }
1992    }, _callee, null, [[0, 41], [7, 23, 26, 29]]);
1993  }));
1994  return _summernote_onPaste.apply(this, arguments);
1995}
1996function init_form(form) {
1997  $('#' + form).find('input, textarea, select').on('focus', function () {
1998    $(this).removeClass('is-invalid');
1999  });
2000  var config = {
2001    height: 120,
2002    lang: 'fr-FR',
2003    toolbar: [['style', ['bold', 'italic', 'underline']], ['link', ['linkDialogShow', 'unlink']]]
2004  };
2005  $('#' + form).find(".with-summernote").each(function () {
2006    $(this).summernote(config);
2007    // $(this).on('summernote.paste', summernote_onPaste );
2008  });
2009  if ($('#' + form).hasClass('with-messagepourletest2')) init_messagepourletest2(form);
2010}
2011function init_messagepourletest2(form) {
2012  $('#' + form).on('mouseover', function (event) {
2013    $('#' + form).find('[name=messagepourletest2]').val(event.timeStamp);
2014  });
2015  $('#' + form).find('[type=submit]').on('focus', function (event) {
2016    $('#' + form).find('[name=messagepourletest2]').val(event.timeStamp);
2017  });
2018}
2019function ajax_post(form, action_type, refresh_fn) {
2020  $.ajax({
2021    type: $('#' + form).attr('method'),
2022    url: $('#' + form).attr('action'),
2023    headers: {
2024      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
2025    },
2026    data: $('#' + form).serialize(),
2027    dataType: 'json',
2028    success: function success(response) {
2029      if (response.errors && response.errors.length) {
2030        var m = '';
2031        for (var i = 0; i < response.errors.length; i++) {
2032          if (response.errors[i].error) m += (m ? '<br>' : '') + '<i class="fa-solid fa-circle-exclamation text-danger"></i>&nbsp;' + response.errors[i].error;
2033          if (response.errors[i].field) $('#' + form).find('[name=' + response.errors[i].field + ']').addClass('is-invalid');
2034        }
2035        if (m) showInformationMessage(action_type, m);
2036      } else {
2037        refresh_fn();
2038      }
2039    },
2040    complete: function complete() {
2041      // Le code du captcha n'est valable qu'une fois : on en affiche un nouveau après chaque envoi
2042      refresh_captcha(form);
2043    }
2044  });
2045}
2046function refresh_captcha(form) {
2047  $('#' + form).find('img[src*="captcha"]').each(function () {
2048    $(this).attr('src', $(this).attr('src').split('?')[0] + '?t=' + Date.now());
2049  });
2050  $('#' + form).find('input[name=verif_code]').val('');
2051}
2052function normalize_height(rule) {
2053  var padding = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2054  $(rule).css('height', 'auto');
2055  var heights = $(rule).map(function () {
2056    return $(this).height();
2057  }).get();
2058  var maxHeight = Math.max.apply(null, heights);
2059  maxHeight += padding;
2060  $(rule).css('height', maxHeight + 'px');
2061}
2062
2063/*****************************************************************************************/
2064/*      Imprimer un DIV                                                                  */
2065/*****************************************************************************************/
2066
2067function ini_printable() {
2068  $('button.print-button').off('click');
2069  $('button.print-button').on('click', function () {
2070    if ($(this).data("div")) PrintElem($(this).data("div"), $(this).data("title"));else if ($(this).data("url")) PrintUrl($(this).data("url"), $(this).data("title"));
2071  });
2072}
2073function PrintElem(elem, titre) {
2074  var html = $(elem).html();
2075  $(elem).find('input').each(function () {
2076    html = html.replace('id="' + $(this).attr('id') + '"', 'id="' + $(this).attr('id') + '" value="' + $(this).val() + '"');
2077    html = html.replace("id='" + $(this).attr('id') + "'", "id='" + $(this).attr('id') + "' value='" + $(this).val() + "'");
2078  });
2079  $(elem).find('input[type=checkbox], input[type=radio]').each(function () {
2080    if ($(this).is(':checked')) {
2081      html = html.replace('id="' + $(this).attr('id') + '"', 'id="' + $(this).attr('id') + '" checked');
2082      html = html.replace("id='" + $(this).attr('id') + "'", "id='" + $(this).attr('id') + "' checked");
2083    }
2084  });
2085  Popup(html, titre);
2086}
2087function Popup(data, titre) {
2088  var base = document.head.querySelector("base").href;
2089  var mywindow = window.open('', titre, 'height=400,width=600');
2090  var html = '<!DOCTYPE html><html lang="fr"><head>';
2091  html = html + '<base href="' + base + '">';
2092  html = html + '<meta charset="utf-8">';
2093  html = html + '<title>' + titre + '</title>';
2094  html = html + '<link type="text/css" rel="stylesheet" href="/css/common.css">';
2095  html = html + '</head><body style="background:white;">';
2096  html = html + data;
2097  html = html + '</body></html>';
2098  mywindow.document.write(html);
2099  mywindow.document.close();
2100  mywindow.focus();
2101  setTimeout(function () {
2102    mywindow.print();
2103    mywindow.close();
2104  }, 2000);
2105  return true;
2106}
2107function PrintUrl(url, titre) {
2108  var mywindow = window.open(url, titre, 'height=400,width=600');
2109  mywindow.focus();
2110  setTimeout(function () {
2111    mywindow.print();
2112    mywindow.close();
2113  }, 2000);
2114  return true;
2115}
2116
2117/*****************************************************************************************/
2118/*      Recherche                                                                        */
2119/*****************************************************************************************/
2120
2121function getTextNodesIn(node, includeWhitespaceNodes, onlyWithClass) {
2122  var textNodes = [],
2123    whitespace = /^\s*$/;
2124  function getTextNodes(node, parentNode, onlyWithClass) {
2125    if (node.nodeType == Node.TEXT_NODE) {
2126      if ((includeWhitespaceNodes || !whitespace.test(node.nodeValue)) && (!onlyWithClass || parentNode.classList.contains(onlyWithClass))) {
2127        textNodes.push(node);
2128      }
2129    } else {
2130      for (var i = 0, len = node.childNodes.length; i < len; ++i) {
2131        getTextNodes(node.childNodes[i], node, onlyWithClass);
2132      }
2133    }
2134  }
2135  getTextNodes(node, null, onlyWithClass);
2136  return textNodes;
2137}
2138function surligneMotsCles(motClefs) {
2139  var motClef = motClefs.split(' ');
2140  var nodes, e, patt;
2141  nodes = getTextNodesIn(document.getElementById('main'), false, 'surlignable');
2142
2143  // Pour tous les mots clefs
2144
2145  for (var j = 0; j < motClef.length; ++j) {
2146    patt = new RegExp(motClef[j], "i");
2147
2148    // Pour tous les textes du site
2149
2150    for (var i = 0; i < nodes.length; ++i) {
2151      if (nodes[i]) {
2152        if ('textContent' in nodes[i]) {
2153          var t = nodes[i].textContent;
2154        } else {
2155          var t = nodes[i].nodeValue;
2156        }
2157
2158        // Le mot clef est présent dans le paragraphe
2159        if (patt.test(t)) {
2160          var longueur = 0;
2161
2162          // je coupe le paragraphe en plusieurs morceaux séparés par le mot recherché
2163          var tab = t.split(patt);
2164          for (var k = 0; k < tab.length; k++) {
2165            if (tab[k].length) {
2166              e = document.createTextNode(tab[k]);
2167              nodes[i].parentNode.insertBefore(e, nodes[i]);
2168              nodes.push(e);
2169              longueur += tab[k].length;
2170            }
2171            if (k < tab.length - 1) {
2172              e = document.createElement('strong');
2173              e.className = "spot" + j;
2174              e.innerHTML = t.substring(longueur, longueur + motClef[j].length);
2175              nodes[i].parentNode.insertBefore(e, nodes[i]);
2176              longueur += motClef[j].length;
2177            }
2178          }
2179          nodes[i].parentNode.removeChild(nodes[i]);
2180          nodes[i] = null;
2181        }
2182      }
2183    }
2184  }
2185}
2186
2187/*****************************************************************************************/
2188/*      Contrôle de l'age                                                                */
2189/*****************************************************************************************/
2190
2191function add_age(ageMin) {
2192  var ageMin = $(this).data('agemin');
2193  $.ajax({
2194    type: "GET",
2195    url: "/add-age/popup",
2196    data: {
2197      ageMin: ageMin
2198    },
2199    headers: {
2200      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
2201    },
2202    success: function success(response) {
2203      $("#multi_modal").html(response);
2204      $('#multi_modal .modal-footer .btn-success').on('click', post_add_age);
2205      add_nested_modal('multi_modal');
2206      $('#multi_modal input').focus(function () {
2207        $('#multi_modal input').removeClass('is-invalid');
2208      });
2209      $('#multi_modal input').blur(function () {
2210        $('#multi_modal input').removeClass('is-invalid');
2211      });
2212    }
2213  });
2214}
2215function post_add_age() {
2216  $.ajax({
2217    type: "POST",
2218    url: "/add-age/popup",
2219    data: {
2220      date_naissance: $('#complete_date_naissance').val(),
2221      messenger_validation_conditions: $('#messenger_validation_conditions').is(':checked') ? 1 : 0
2222    },
2223    headers: {
2224      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
2225    },
2226    success: function success(response) {
2227      location.reload();
2228    }
2229  });
2230}
2231
2232/*****************************************************************************************/
2233/*      Open as popup                                                                */
2234/*****************************************************************************************/
2235
2236function init_open_as_popup(link) {
2237  if (!link.attr("rel")) {
2238    link.attr("rel", link.prop('href'));
2239    link.prop("href", "javascript:void(0);");
2240    link.on("click", function () {
2241      do_open_as_popup(link);
2242    });
2243  }
2244}
2245function init_replace_as_popup(link) {
2246  if (!link.attr("rel")) {
2247    link.attr("rel", link.prop('href'));
2248    link.prop("href", "javascript:void(0);");
2249    link.on("click", function () {
2250      do_replace_as_popup(link);
2251    });
2252  }
2253}
2254function do_open_as_popup(link) {
2255  var only_information = false;
2256  var large = false;
2257  if (link.hasClass('only_information')) only_information = true;
2258  if (link.hasClass('large')) large = true;
2259  open_as_popup(link.attr("rel"), link.prop('title'), only_information, large);
2260}
2261function do_replace_as_popup(link) {
2262  replace_content_popup(link.attr("rel"));
2263}
2264function open_as_popup(url, titre, only_information, large) {
2265  var headers = {};
2266  if (typeof crypted_id !== 'undefined') {
2267    headers = {
2268      'crypted_id': crypted_id,
2269      'X-Requested-With': 'xmlhttprequest'
2270    };
2271  }
2272  $.ajax({
2273    type: "GET",
2274    url: url,
2275    headers: headers,
2276    success: function success(response) {
2277      var html = '<div class="modal-dialog modal-dialog-scrollable modal-dialog-centered' + (large ? ' modal-xl' : '') + '" role="document">' + '<div class="modal-content">' + '<div class="modal-header">' + '<h5 class="modal-title">' + titre + '</h5>' + '<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>' + '</div>' + '<div class="modal-body">' + response + '</div>' + (!only_information ? '<div class="modal-footer"></div>' : '') + '</div>' + '</div>';
2278      remove_nested_modal('multi_modal');
2279      $("#multi_modal").html(html);
2280      $("#multi_modal").attr('rel', titre);
2281
2282      /*
2283      if (only_information)
2284          init_popup_bootstrap_automatique($("#multi_modal"), '');
2285      else
2286          init_popup_bootstrap_automatique($("#multi_modal"));
2287      */
2288      $('#multi_modal .replace_as_popup').each(function () {
2289        init_replace_as_popup($(this));
2290      });
2291      m = document.getElementById('multi_modal');
2292      add_nested_modal('multi_modal');
2293
2294      /*
2295      m.addEventListener('shown.bs.modal', event => {
2296           if ($('#multi_modal form').length) {
2297              var fields = $('#multi_modal input[type=text], #multi_modal textarea');
2298              if (fields.length) {
2299                  fields.first().trigger('focus');
2300              }
2301          }
2302           $("#multi_modal").find('textarea').each(function () {
2303              if ( ! $(this).attr('withckeditor')) {
2304                  $(this).elastic();
2305              }
2306          });
2307      });
2308      */
2309    }
2310  });
2311}
2312/******/ })()
2313;

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.