PageSourceSearch

https://droitne.ch/js/droitne/colloque.js?v=1b1790f25aeb317241378bef6574f360

js droitne.ch collected 2026-10-09 01:27:38 UTC 30,346 bytes, 854 lines download raw bytes

1function displayError( message )
2{
3	$('.error-wrapper').html('<div class="alert alert-danger"><span>'+message+'</span></div>');
4}
5
6function clearError()
7{
8	$('.error-wrapper').html('');
9}
10
11function displayAllAdressesInModal() {
12	//defiltrer les adresses affichées
13	$("input.choose_participant").each(function() {
14		var adresse_id = $(this).val();
15		$("label#choose_adresse_bg_"+adresse_id).css('opacity', '1');				
16		$("label#choose_adresse_bg_"+adresse_id).css('height', 'auto');
17		$("label#choose_adresse_bg_"+adresse_id).css('position', 'relative');
18		
19	});
20	
21	//mettre en couleur l'adresse sélectionnée
22	$("input.choose_participant").each(function() {
23		if($(this).is(':checked')) {
24			var adresse_id = $(this).val();
25			$("label#choose_adresse_bg_"+adresse_id).addClass('choose_adresse_preview_selected');				
26		}
27	});
28}
29
30function saveColloqueDefaultPriceOption(option_id, value) {
31	
32	var colloque_id = $("#colloque_id").val();
33	
34	$.ajax({
35	  type: "POST",
36	  url: "/droitne/colloques/inscription/savepriceoption",
37	  data: "&colloque_id="+colloque_id+"&option_id="+option_id+"&value="+value	  
38	})
39	.done(function() {
40		clearError();
41	})
42    .fail(function() {
43		displayError('Une erreur inconnue s’est produite (code J-101). Veuillez réessayer. Si le problème persiste, merci de nous contacter au 032 718 12 22.');
44  	});
45  	
46}
47
48function saveColloqueParticipantPriceOption(adresse_id, option_id, value) {
49	
50	var colloque_id = $("#colloque_id").val();
51	
52	$.ajax({
53	  type: "POST",
54	  url: "/droitne/colloques/inscription/savepriceoption",
55	  data: "&colloque_id="+colloque_id+"&adresse_id="+adresse_id+"&option_id="+option_id+"&value="+value	  
56	})
57	.done(function() {
58		clearError();
59	})
60    .fail(function() {
61		displayError('Une erreur inconnue s’est produite (code J-102). Veuillez réessayer. Si le problème persiste, merci de nous contacter au 032 718 12 22.');
62  	});
63  	
64}
65
66function saveColloqueNewParticipant(adresse_id) {
67	
68	var colloque_id = $("#colloque_id").val();
69	
70	$.ajax({
71	  type: "POST",
72	  url: "/droitne/colloques/inscription/saveparticipant",
73	  data: "&colloque_id="+colloque_id+"&adresse_id="+adresse_id+"&action=new"  
74	})
75	.done(function() {
76		clearError();
77	})
78    .fail(function() {
79		displayError('Une erreur inconnue s’est produite (code J-103). Veuillez réessayer. Si le problème persiste, merci de nous contacter au 032 718 12 22.');
80  	});
81  	
82}
83
84function colloqueRemoveParticipant(adresse_id) {
85	
86	var colloque_id = $("#colloque_id").val();
87	
88	$.ajax({
89	  type: "POST",
90	  url: "/droitne/colloques/inscription/saveparticipant",
91	  data: "&colloque_id="+colloque_id+"&adresse_id="+adresse_id+"&action=remove"  	  
92	})
93	.done(function() {
94		clearError();
95	})
96    .fail(function() {
97		displayError('Une erreur inconnue s’est produite (code J-104). Veuillez réessayer. Si le problème persiste, merci de nous contacter au 032 718 12 22.');
98  	});
99  	
100}
101
102function colloqueChangeAdresse(old_adresse_id, new_adresse_id, type='facturation') {
103	
104	var colloque_id = $("#colloque_id").val();
105	
106	$.ajax({
107	  type: "POST",
108	  url: "/droitne/colloques/inscription/saveadresse",
109	  data: "&colloque_id="+colloque_id+"&old_adresse_id="+old_adresse_id+"&new_adresse_id="+new_adresse_id+"&type="+type  
110	})
111	.done(function() {
112		clearError();
113	})
114    .fail(function() {
115		displayError('Une erreur inconnue s’est produite (code J-105). Veuillez réessayer. Si le problème persiste, merci de nous contacter au 032 718 12 22.');
116  	});
117  	
118}
119
120/**
121 * Évalue les conditions d'affichage des options.
122 * Logique : (prix OU ...) ET (option OU ...) ET (groupe OU ...)
123 * Scope : conteneur parent (step-options ou participant block)
124 */
125function evaluateOptionConditions(scope) {
126	var $scope = $(scope);
127	var maxPasses = 10;
128
129	for (var pass = 0; pass < maxPasses; pass++) {
130		var selectedPrice = parseInt($scope.find('.colloque_price_value:checked').val()) || 0;
131
132		var checkedOptions = [];
133		$scope.find('.colloque_option_value[type="checkbox"]:checked').each(function() {
134			checkedOptions.push(parseInt($(this).data('optionid')));
135		});
136
137		var selectedGroupes = [];
138		$scope.find('.colloque_option_value[type="radio"]:checked').each(function() {
139			var gid = $(this).data('groupeid');
140			if (gid) selectedGroupes.push(parseInt(gid));
141		});
142
143		var changed = false;
144
145		$scope.find('.option-conditional').each(function() {
146			var $el = $(this);
147			var conditions = $el.data('conditions');
148			if (!conditions || $.isEmptyObject(conditions)) {
149				$el.data('condition-visible', true);
150				return;
151			}
152
153			var visible = true;
154			if (conditions.price && conditions.price.length > 0) {
155				visible = visible && conditions.price.indexOf(selectedPrice) !== -1;
156			}
157			if (conditions.option && conditions.option.length > 0) {
158				var found = false;
159				for (var i = 0; i < conditions.option.length; i++) {
160					if (checkedOptions.indexOf(conditions.option[i]) !== -1) { found = true; break; }
161				}
162				visible = visible && found;
163			}
164			if (conditions.groupe && conditions.groupe.length > 0) {
165				var found = false;
166				for (var i = 0; i < conditions.groupe.length; i++) {
167					if (selectedGroupes.indexOf(conditions.groupe[i]) !== -1) { found = true; break; }
168				}
169				visible = visible && found;
170			}
171
172			var wasVisible = $el.data('condition-visible');
173			$el.data('condition-visible', visible);
174
175			if (!visible && wasVisible !== false) {
176				var hadChecked = $el.find('input[type="checkbox"]:checked').length > 0;
177				var hadRadio = $el.find('input[type="radio"]:checked').length > 0;
178				$el.find('input[type="checkbox"]').prop('checked', false);
179				$el.find('input[type="radio"]').prop('checked', false);
180				$el.find('textarea').val('');
181				$el.find('input[type="file"]').val('');
182				if (hadChecked || hadRadio) changed = true;
183			}
184		});
185
186		if (!changed) break;
187	}
188
189	$scope.find('.option-conditional').each(function() {
190		var $el = $(this);
191		if ($el.data('condition-visible')) {
192			$el.slideDown(200);
193		} else {
194			$el.slideUp(200);
195		}
196	});
197
198	$scope.find('.option-type-section').each(function() {
199		var $section = $(this);
200		var hasVisible = false;
201		$section.find('.option-conditional').each(function() {
202			if ($(this).data('condition-visible')) {
203				hasVisible = true;
204				return false;
205			}
206		});
207		if (hasVisible) {
208			$section.slideDown(200);
209		} else {
210			$section.slideUp(200);
211		}
212	});
213}
214
215/**
216 * Met à jour le récapitulatif des options d'un participant.
217 * formScope : le conteneur du formulaire interactif (modale ou step-options)
218 * resumeScope : le conteneur du récapitulatif (participant preview)
219 */
220function updateOptionResume(formScope, resumeScope) {
221	var $form = $(formScope);
222	var $resume = $(resumeScope);
223
224	var selectedPrice = parseInt($form.find('.colloque_price_value:checked').val()) || 0;
225
226	var checkedOptions = [];
227	$form.find('.colloque_option_value[type="checkbox"]:checked').each(function() {
228		checkedOptions.push(parseInt($(this).data('optionid')));
229	});
230
231	var selectedGroupes = [];
232	$form.find('.colloque_option_value[type="radio"]:checked').each(function() {
233		var gid = $(this).data('groupeid');
234		if (gid) selectedGroupes.push(parseInt(gid));
235	});
236
237	$resume.find('.option-resume-conditional').each(function() {
238		var $el = $(this);
239		var conditions = $el.data('conditions');
240		var visible = true;
241
242		if (conditions && !$.isEmptyObject(conditions)) {
243			if (conditions.price && conditions.price.length > 0) {
244				visible = visible && conditions.price.indexOf(selectedPrice) !== -1;
245			}
246			if (conditions.option && conditions.option.length > 0) {
247				var found = false;
248				for (var i = 0; i < conditions.option.length; i++) {
249					if (checkedOptions.indexOf(conditions.option[i]) !== -1) { found = true; break; }
250				}
251				visible = visible && found;
252			}
253			if (conditions.groupe && conditions.groupe.length > 0) {
254				var found = false;
255				for (var i = 0; i < conditions.groupe.length; i++) {
256					if (selectedGroupes.indexOf(conditions.groupe[i]) !== -1) { found = true; break; }
257				}
258				visible = visible && found;
259			}
260		}
261
262		if (visible) {
263			$el.show();
264		} else {
265			$el.hide();
266		}
267	});
268
269	$resume.find('.option-resume-section').each(function() {
270		var $section = $(this);
271		var hasVisible = false;
272		$section.find('.option-resume-conditional').each(function() {
273			if ($(this).css('display') !== 'none') {
274				hasVisible = true;
275				return false;
276			}
277		});
278		if (hasVisible) {
279			$section.show();
280		} else {
281			$section.hide();
282		}
283	});
284}
285
286/**
287 * Construit dynamiquement les champs d'upload fichiers par participant
288 * dans le formulaire de confirmation (step 3).
289 */
290/**
291 * Construit les champs d'upload par participant et retourne true s'il y en a.
292 */
293function buildFileUploadsSection() {
294	if (typeof colloqueFileOptions === 'undefined' || !colloqueFileOptions.length) return false;
295
296	var $list = $('#file-uploads-list');
297	$list.empty();
298	var hasAnyFile = false;
299
300	$('#colloque_participants > .colloque_participant_data').each(function() {
301		var $p = $(this);
302		var num = $p.attr('id') ? $p.attr('id').replace('colloque_participant_', '') : '';
303		if (num === '[xxx]') return;
304
305		var $modal = $p.find('.choose_participant_options');
306		var $form = $modal.length ? $modal : $('#colloque-inscription-step-options');
307
308		var selectedPrice = parseInt($form.find('.colloque_price_value:checked').val()) || 0;
309		var checkedOptions = [];
310		$form.find('.colloque_option_value[type="checkbox"]:checked').each(function() {
311			checkedOptions.push(parseInt($(this).data('optionid')));
312		});
313		var selectedGroupes = [];
314		$form.find('.colloque_option_value[type="radio"]:checked').each(function() {
315			var gid = $(this).data('groupeid');
316			if (gid) selectedGroupes.push(parseInt(gid));
317		});
318
319		var adresseId = $p.find('.participant_hidden').val();
320		var participantName = $p.data('participant-name') || ('Participant ' + num);
321
322		var visibleFiles = [];
323		for (var i = 0; i < colloqueFileOptions.length; i++) {
324			var opt = colloqueFileOptions[i];
325			var visible = true;
326			var c = opt.conditions;
327			if (c && !$.isEmptyObject(c)) {
328				if (c.price && c.price.length > 0) {
329					visible = visible && c.price.indexOf(selectedPrice) !== -1;
330				}
331				if (c.option && c.option.length > 0) {
332					var found = false;
333					for (var j = 0; j < c.option.length; j++) {
334						if (checkedOptions.indexOf(c.option[j]) !== -1) { found = true; break; }
335					}
336					visible = visible && found;
337				}
338				if (c.groupe && c.groupe.length > 0) {
339					var found = false;
340					for (var j = 0; j < c.groupe.length; j++) {
341						if (selectedGroupes.indexOf(c.groupe[j]) !== -1) { found = true; break; }
342					}
343					visible = visible && found;
344				}
345			}
346			if (visible) visibleFiles.push(opt);
347		}
348
349		if (visibleFiles.length === 0) return;
350		hasAnyFile = true;
351
352		var html = '<div class="mb-3 p-3 border rounded">';
353		html += '<div class="fw-bold mb-2">' + $('<span>').text(participantName).html() + '</div>';
354		for (var i = 0; i < visibleFiles.length; i++) {
355			var f = visibleFiles[i];
356			html += '<div class="mb-2">';
357			html += '<label class="form-label">' + $('<span>').text(f.title).html();
358			if (f.required) html += ' <span class="text-danger">*</span>';
359			html += '</label>';
360			html += '<input type="file" class="form-control colloque-file-input" name="files[' + adresseId + '][' + f.id + ']"' + (f.required ? ' required' : '') + '>';
361			html += '</div>';
362		}
363		html += '</div>';
364		$list.append(html);
365	});
366
367	return hasAnyFile;
368}
369
370/*************** Page initializazion *************************/
371$(document).ready(function() {
372	
373		
374	/*********************************************************************/ 
375	/****************** colloque inscription *****************************/
376	/*********************************************************************/
377		
378	//manage url param
379	var query_params = new URL(document.location).searchParams;
380	if(query_params.get("step") == "data") {
381		$("#colloque-inscription-step-options").hide();	
382		$("#colloque-inscription-step-confirm").hide();	
383		$("#colloque-inscription-step-data").show();
384		$("#colloque-inscription-header-options").removeClass("text-secondary");
385		$("#colloque-inscription-header-confirm").removeClass("text-secondary");
386		$("#colloque-inscription-header-data").addClass("text-secondary");
387		$('html, body').scrollTop($("#colloque-inscription-steps").offset().top);
388	}
389	if(query_params.get("step") == "confirm") {
390		$("#colloque-inscription-step-options").hide();
391		$("#colloque-inscription-step-data").hide();
392		$("#colloque-inscription-step-confirm").show();
393		$("#colloque-inscription-header-options").removeClass("text-secondary");
394		$("#colloque-inscription-header-data").removeClass("text-secondary");
395		$("#colloque-inscription-header-confirm").addClass("text-secondary");
396		$('html, body').scrollTop($("#colloque-inscription-steps").offset().top);
397	}
398	
399	/*************** changement steps *************************/
400	
401	//step 1 -> step 2
402	$("#colloque-subscribtion-tologin").on('click', function(event) {
403		event.preventDefault();
404		
405		//** valider que toutes les options aient une valeur sélectionnée
406		if (!$( "#colloque_subscription_options" ).valid()) {
407			
408			Swal.fire({
409                    title: "Attention",
410                    text : 'Merci de choisir une valeur pour chaque option',
411                    type : "warning",
412                    showConfirmButton: true
413            });
414            
415            return false;
416			
417		}
418		
419		
420		//**** setter les données par défaut aux options de l'étape suivante
421		
422			//Récupère le prix et set le	
423			var selected_price = $("#colloque-inscription-step-options input.colloque_price_value:checked").val();
424			$("#colloque-inscription-step-data input.colloque_price_value[value='"+selected_price+"']").prop('checked',true);
425			//var pricePreview = '<span class="fw-bold">Prix: </span><span class="" id="colloque_price_label_{{ $num }}">{{ $price->description }}</span><span class="d-block text-nowrap">CHF <span id="colloque_price_amount_{{ $num }}">{{ $price->price_cents }}</span></span>';
426			var price_label = $("#colloque-inscription-step-options input.colloque_price_value:checked").next("label").find("#price-label_").html();
427			var price_amount = $("#colloque-inscription-step-options input.colloque_price_value:checked").next("label").find("#price-amount_").html();
428			$("#colloque-inscription-step-data .option_price_descr").html(price_label);
429			$("#colloque-inscription-step-data .option_price_amount_to_calc").html(price_amount);
430			
431			//Boucle sur les options et set les
432			$("#colloque-inscription-step-options .colloque_option_value:checked").each(function () {
433				var option_id = $(this).data('optionid');
434				var value = $(this).val();
435				var label = $(this).next("label").html();
436				$("#colloque-inscription-step-data input[data-optionid='"+option_id+"']").each(function() {				
437					if($(this).val() == value) {
438						$(this).prop('checked',true);				
439					}
440				});		
441			$(".option_" + option_id + "_label").each(function() {
442				$(this).html(label);
443				});	
444			});
445
446			$('.colloque_participant_data').each(function() {
447				var $p = $(this);
448				updateOptionResume('#colloque-inscription-step-options', $p);
449			});
450
451		//affichage du step
452		if ($("#colloque-inscription-step-login").length) {		 
453		    $("#colloque-inscription-step-login").show();
454		    $(".colloque-inscription-header-login").addClass("text-primary");
455		} else {			
456			$("#colloque-inscription-step-data").show();
457			$(".colloque-inscription-header-data").addClass("text-primary");
458			$("#bar-step-2").css('background-color', "var(--bs-primary)");
459		}
460		$("#colloque-inscription-step-options").hide();	
461		//$(".colloque-inscription-header-options").removeClass("text-primary");	
462	});
463	
464	//step 2 -> step files ou step confirm
465	$("#colloque-subscription-toconfirm").on('click', function(event) {
466
467		event.preventDefault();
468
469		$('#colloque_participants > .colloque_participant_data').each(function() {
470			var $p = $(this);
471			var num = $p.attr('id') ? $p.attr('id').replace('colloque_participant_', '') : '';
472			if (num === '[xxx]') return;
473			var $modal = $p.find('.choose_participant_options');
474			if ($modal.length) {
475				updateOptionResume($modal, $p);
476			}
477		});
478
479		var hasFiles = buildFileUploadsSection();
480
481		if (hasFiles) {
482			$("#colloque-inscription-step-data").hide();
483			$("#colloque-inscription-step-files").show();
484			$("#bar-step-3").css('background-color', "var(--bs-primary)");
485			$(".colloque-inscription-header-confirm").addClass("text-primary");
486		} else {
487			showConfirmStep();
488		}
489	});
490
491	function showConfirmStep() {
492		//récupérer liste participants et options de step2 pour affichage dans step3
493		var html = $("#colloque_participants").html();
494		$("#confirm_participants_list").html(html);
495		$("#confirm_participants_list .btn").remove();
496		$("#confirm_participants_list .modal").remove();
497		$("#confirm_participants_list input, #confirm_participants_list textarea, #confirm_participants_list select").removeAttr('required');
498
499		//ajouter les noms de fichiers sélectionnés au récapitulatif
500		$('#file-uploads-list input[type="file"]').each(function() {
501			if (this.files && this.files.length > 0) {
502				var name = $(this).attr('name');
503				var match = name.match(/files\[(\d+)\]/);
504				if (match) {
505					var adresseId = match[1];
506					var fileName = this.files[0].name;
507					var $participant = $('#confirm_participants_list').find('.participant_hidden[value="' + adresseId + '"]').closest('.colloque_participant_data');
508					if ($participant.length) {
509						var $resume = $participant.find('.colloque_price').parent();
510						$resume.append('<div class="mt-1"><small class="text-muted"><i class="fa fa-paperclip"></i> ' + $('<span>').text(fileName).html() + '</small></div>');
511					}
512				}
513			}
514		});
515
516		//récupérer l'adresse de facturation
517		html = $("#adresse_facturation_preview").html();
518		$("#confirmation_facturation_adresse").html(html);
519
520		//récupérer le montant total
521		var total = 0;
522		$("#colloque-inscription-step-data .option_price_amount_to_calc").each(function() {
523			var num = $(this).data('num');
524			if(num != "[xxx]") {
525				var val = $(this).html();
526				val = val.replace('CHF','');
527				val = val.replace('.-','');
528				val = val.replace(' ','');
529				total += parseFloat(val);
530			}
531		});
532		$("#resume-total-price").html("CHF " + total + ".-");
533
534		//affichage du step
535		$("#colloque-inscription-step-files").hide();
536		$("#colloque-inscription-step-data").hide();
537		$("#colloque-inscription-step-confirm").show();
538		$(".colloque-inscription-header-confirm").addClass("text-primary");
539		$("#bar-step-3").css('background-color', "var(--bs-primary)");
540	}
541
542	//step files -> step confirm
543	$("#colloque-subscription-files-toconfirm").on('click', function(event) {
544		event.preventDefault();
545		showConfirmStep();
546	});
547
548	//step files -> step 2
549	$("#colloque-subscription-files-todata").on('click', function(event) {
550		event.preventDefault();
551		event.stopPropagation();
552		$("#colloque-inscription-step-files").hide();
553		$("#colloque-inscription-step-data").show();
554		$(".colloque-inscription-header-confirm").removeClass("text-primary");
555		$("#bar-step-3").css('background-color', 'gray');
556	});
557
558	//step confirm -> step 2 (ou step files)
559	$("#colloque-subscription-todata").on('click', function(event) {
560
561		event.preventDefault();
562		event.stopPropagation();
563
564		var hasFiles = (typeof colloqueFileOptions !== 'undefined' && colloqueFileOptions.length > 0 && $('#file-uploads-list').children().length > 0);
565
566		if (hasFiles) {
567			$("#colloque-inscription-step-confirm").hide();
568			$("#colloque-inscription-step-files").show();
569		} else {
570			$("#colloque-inscription-step-confirm").hide();
571			$("#colloque-inscription-step-data").show();
572			$(".colloque-inscription-header-confirm").removeClass("text-primary");
573			$("#bar-step-3").css('background-color', 'gray');
574		}
575	});
576	
577	//blocage double soumission du formulaire final
578	$('#colloque-inscription-final-form').on('submit', function() {
579		var $btn = $('#colloque-subscription-send');
580		$btn.prop('disabled', true);
581		$btn.html('<i class="fa fa-spinner fa-spin"></i> Envoi en cours…');
582	});
583
584	//step 2 -> step 1
585	$("#colloque-subscription-tooptions").on('click', function(event) {
586		event.preventDefault();		
587
588		//affichage du step
589		$("#colloque-inscription-step-options").show();
590		$("#colloque-inscription-step-data").hide();
591		
592		//mise à jour du header 
593		$(".colloque-inscription-header-options").addClass("text-primary");	
594		$(".colloque-inscription-header-data").removeClass("text-primary");
595		$(".colloque-inscription-header-data").addClass("text-gray");		
596		$("#bar-step-2").css('background-color', 'gray');
597	});
598	
599	//login -> step 1
600	$("#colloque-subscribtion-tochoice").on('click', function(event) {
601		event.preventDefault();		
602
603		//affichage du step
604		$("#colloque-inscription-step-options").show();
605		$("#colloque-inscription-step-login").hide();
606		
607		//mise à jour du header 
608		$(".colloque-inscription-header-options").addClass("text-primary");	
609	});
610	
611	/*************** step1 : options et prix par défaut *************************/
612	
613	//ajax save selected options default price
614	$("#colloque-inscription-step-options .colloque_price_value").on('change', function() {		
615		var value = $(this).val();
616		saveColloqueDefaultPriceOption('price', value);
617		evaluateOptionConditions('#colloque-inscription-step-options');
618	});
619	
620	//ajax save selected options default option
621	$("#colloque-inscription-step-options .colloque_option_value").on('change', function() {
622		var option_id = $(this).data('optionid');		
623		var value = $(this).val();
624		saveColloqueDefaultPriceOption(option_id, value);
625		evaluateOptionConditions('#colloque-inscription-step-options');
626	});
627
628	// Initial evaluation on page load
629	if ($('#colloque-inscription-step-options .option-conditional').length > 0) {
630		evaluateOptionConditions('#colloque-inscription-step-options');
631	}
632	$('.colloque_participant_data').each(function() {
633		var $p = $(this);
634		var $modal = $p.find('.choose_participant_options');
635		if ($modal.length) {
636			evaluateOptionConditions($modal);
637			updateOptionResume($modal, $p);
638		}
639	});
640	
641	/*************** step2 : choix adresse et participants *************************/
642	
643	/* choix de l'adresse de facturation : ouverture modale */
644	$("#select_adresse_facturation_btn").on('click',function () {	
645		
646		//toutes les adresses existantes doivent être diponible comme adresse de facturation	
647		displayAllAdressesInModal();		
648		
649		//sélectionne l'adresse actuellement sélectionnée
650		var adresse_id = $("#adresse_facturation_id").val();
651        $(".choose_adresse_bg").removeClass("choose_adresse_preview_selected");
652        $("#choose_adresse_bg_"+adresse_id).addClass("choose_adresse_preview_selected");
653        var $radios = $('#choose_participant input:radio[name=choose_participant]');
654        $radios.filter('[value='+adresse_id+']').prop('checked', true);        
655        
656        
657	});
658	
659	/* choix de l'adresse de facturation : selection */
660	$("#choose_adresse_facturation .select_adresse_btn").on('click', function() {
661		
662		
663		var old_adresse_id = $("#adresse_facturation_id").val(); 
664		var new_adresse_id = $("#choose_adresse_facturation .choose_adresse_facturation:checked").val();
665		
666		//ajax save
667		colloqueChangeAdresse(old_adresse_id, new_adresse_id);
668		
669		//set le champ hidden
670		$("#adresse_facturation_id").val(new_adresse_id);
671		
672		//set le preview de l'adresse
673		var preview_html = $("#choose_adresse_facturation #adresse_preview_"+new_adresse_id).html();
674		$("#adresse_facturation_preview").html(preview_html);
675	});
676	
677	/* choix de l'adresse d'un participant : ouverture modale */
678	$("#colloque_participants").on('click','.select_participant_adresse_btn',function () {
679		
680		//affiche toutes les adresses existantes avant de filtrer
681		displayAllAdressesInModal();
682		
683		//filtrer les adresses affichées en fonction des participants déjà présents
684		$("input.choose_participant").each(function() {
685			var adresse_id = $(this).val();
686			if($("#colloque_participants .participant_hidden[value='"+adresse_id+"']").length > 0) {
687				$("label#choose_adresse_bg_"+adresse_id).css('opacity', '0');				
688				$("label#choose_adresse_bg_"+adresse_id).css('height', '0');
689				$("label#choose_adresse_bg_"+adresse_id).css('position', 'absolute');
690		
691			}			
692		})
693		
694        var num = $(this).data('num');
695        var adresse_id = $(this).data('adresse_id');
696        
697        //indique le num de participant concerné à la modal
698        $("#num_adresse_to_update").val(num);
699        
700        //sélectionne l'adresse actuellement sélectionnée
701        $(".choose_adresse_bg").removeClass("choose_adresse_preview_selected");
702        $("#choose_adresse_bg_"+adresse_id).addClass("choose_adresse_preview_selected");
703        var $radios = $('#choose_participant input:radio[name=choose_participant]');
704        $radios.filter('[value='+adresse_id+']').prop('checked', true);        
705    });
706	
707	/* choix de l'adresse d'un participant : selection */
708	$("#choose_participant .select_adresse_btn").on('click', function() {
709		
710		var num = $("#num_adresse_to_update").val();		
711		var new_adresse_id = $("#choose_participant .choose_participant:checked").val();
712		var old_adresse_id = $("#adresse_participant_"+num).val();
713		
714		//ajax save
715		colloqueChangeAdresse(old_adresse_id, new_adresse_id, 'participant');
716		
717		//mise à jour du champ hidden
718		$("#adresse_participant_"+num).val(new_adresse_id);
719		
720		//mise à jour du preview de l'adresse
721		var preview_html = $("#choose_participant #adresse_preview_"+new_adresse_id).html();
722		$("#adresse_participant_"+num+"_preview").html(preview_html);
723			
724	});
725	
726	/* ajouter un participant : ouverture modale */
727	$("#add_participant_link").on('click', function () {
728		
729		//affiche toutes les adresses existantes avant de filtrer
730		displayAllAdressesInModal();
731		
732		//filtrer les adresses affichées en fonction des participants déjà présents
733		$("input.choose_participant").each(function() {
734			var adresse_id = $(this).val();
735			if($("#colloque_participants .participant_hidden[value='"+adresse_id+"']").length > 0) {
736				$("label#choose_adresse_bg_"+adresse_id).css('opacity', '0');				
737				$("label#choose_adresse_bg_"+adresse_id).css('height', '0');				
738				$("label#choose_adresse_bg_"+adresse_id).css('position', 'absolute');
739			}			
740		})
741		        
742    });
743	
744	/* ajouter un participant : selection */
745	$("#add_participant .select_adresse_btn").on('click', function() {
746		
747		//determine le numero du nouveau participant
748		var num = 1;
749		$(".colloque_participant_data").each(function() {
750			if($(this).data('num') > num) {
751				num = $(this).data('num');
752			}
753		});		
754		num++
755		
756		var adresse_id = $("#add_participant .add_participant:checked").val();		
757		var preview_html = $("#add_participant #adresse_preview_"+adresse_id).html();				
758
759		if( $('#colloque_participants input.participant_hidden[value=' + adresse_id + ']').length > 0 )
760			return;
761
762		//ajax save new participant
763		saveColloqueNewParticipant(adresse_id);
764		
765		//préparation d'une ligne de participant		
766		var htmlToInject = $("#colloque_participant_model").html();
767		htmlToInject = htmlToInject.replaceAll("[xxx]", num);
768		htmlToInject = htmlToInject.replaceAll("[adresse_id]", adresse_id);
769		htmlToInject = htmlToInject.replaceAll('style="display:none;"', "");
770		
771		//Insertion de la nouvelle ligne
772		$("#colloque_participants").append( htmlToInject );
773		
774		//Mise à jour de l'adresse en fonction de l'adresse sélectionnée 
775		$("#adresse_participant_"+num+"_preview").html(preview_html);
776		
777		//Mise à jour de l'id de l'adresse du participant
778		$("#adresse_participant_"+num).val(adresse_id);
779		
780		//rendre tous les boutons "retirer" visibles
781		$(".remove_participant_btn").show();	
782	});
783	
784	/* retirer un participant */
785	$("body").on('click','.remove_participant_btn', function() {
786		
787		var num = $(this).data("num");	
788		var adresse_id = $("#adresse_participant_"+num).val();
789		
790		//ajax save new participant
791		colloqueRemoveParticipant(adresse_id);
792		
793		//retirer la ligne du participant
794		$("#colloque_participant_"+num).remove();
795		
796		//si plus qu'un seul participant, masquer tous les boutons "retirer"
797		if($(".colloque_participant_data").length == 2) { //2 parce qu'il y a celui caché qui sert de model lors de l'ajout		
798			$(".remove_participant_btn").hide();
799		}
800		
801	});
802	
803	
804	/* options d'un participant : selection */
805	$('#colloque_participants').on('click', '.choose_participant_options_btn', function() {
806		
807		var num = $(this).data('num');		
808				
809		//mise à jour du preview du participant
810		
811		//options ->  boucle sur les radios cochées		
812		$(".colloque_option_value_"+num+":checked").each(function () {
813			var option_id = $(this).data('optionid');
814			var value_txt = $(this).next('label').html();
815			$("#option_"+num+"_"+option_id).html(value_txt);
816		})
817					
818		//prix ->  boucle sur les radios cochées		
819		$(".colloque_price_value_"+num+":checked").each(function () {			
820			
821			var label_txt = $(this).next("label").find('#price-label_'+num, this).html();
822			var amount_txt = $(this).next("label").find('#price-amount_'+num, this).html();
823			
824			$("#colloque_price_label_"+num).html(label_txt);
825			$("#colloque_price_amount_"+num).html(amount_txt);
826		})
827
828		var $modal = $('#chooseOptions_' + num);
829		var $participant = $('#colloque_participant_' + num);
830		updateOptionResume($modal, $participant);
831	});
832	
833	//ajax save selected options participant price
834	$("#colloque-inscription-step-data .colloque_price_value").on('change', function() {		
835		var value = $(this).val();
836		var adresse_id = $(this).closest('.colloque_participant_data').find(".participant_hidden").val();
837		saveColloqueParticipantPriceOption(adresse_id, 'price', value);
838		var $participantBlock = $(this).closest('.colloque_participant_data');
839		if ($participantBlock.length) evaluateOptionConditions($participantBlock);
840	});
841	
842	//ajax save selected options participant option
843	$("#colloque-inscription-step-data .colloque_option_value").on('change', function() {
844		var option_id = $(this).data('optionid');		
845		var value = $(this).val();
846		var adresse_id = $(this).closest('.colloque_participant_data').find(".participant_hidden").val();
847		saveColloqueParticipantPriceOption(adresse_id, option_id, value);
848		var $participantBlock = $(this).closest('.colloque_participant_data');
849		if ($participantBlock.length) evaluateOptionConditions($participantBlock);
850	});
851	
852	
853	
854});

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.