PageSourceSearch

https://www.thalgo.co.uk/site/templates/defaut/front/javascript/basket_index.js?v=1757085531

js thalgo.co.uk collected 2026-10-04 13:32:41 UTC 11,411 bytes, 278 lines download raw bytes

1$(document).ready(function() {
2
3
4	// ---------- Partie questionnement bénéficiaires : ---------------
5	/*var cadeau_text = $('.question_cadeau a').first().text();
6	var cadeau_reverse = $('.question_cadeau a').attr('data-reverse');
7	var mail_text = $('.question_reception a').first().text();
8	var mail_reverse = $('.question_reception a').attr('data-reverse');*/
9	var mode_reception_text = $('.mode_reception').first().text();
10	var mode_reception_reverse = $('.mode_reception').attr('data-reverse');
11	var cadeau = [];
12	var mail = [];
13
14	$('.beneficiaire_formulaire').each(function(i) {
15		if ($(this).find('.beneficiaire_champs[name=beneficiaire_cadeau]').attr('data-actif') == 'true') {cadeau[$(this).attr('id')]=true;} else {cadeau[$(this).attr('id')]=false;}
16		if (cadeau[$(this).attr('id')]){
17			$(this).find('.question_cadeau a.oui .fa').addClass('fa-check-square-o');
18			$(this).find('.question_cadeau a.oui .fa').removeClass('fa-square-o');
19			$(this).find('.question_cadeau a.non .fa').addClass('fa-square-o');
20			$(this).find('.question_cadeau a.non .fa').removeClass('fa-check-square-o');
21		}
22		if ($(this).find('.beneficiaire_champs[name=beneficiaire_reception]').attr('data-actif') == 'true') {mail[$(this).attr('id')]=true;} else {mail[$(this).attr('id')]=false;}
23		if (mail[$(this).attr('id')]){
24			$(this).find('.question_reception a.oui .fa').addClass('fa-check-square-o');
25			$(this).find('.question_reception a.oui .fa').removeClass('fa-square-o');
26			$(this).find('.question_reception a.non .fa').addClass('fa-square-o');
27			$(this).find('.question_reception a.non .fa').removeClass('fa-check-square-o');
28		}
29		test_logique($(this).attr('id'));
30	});
31
32	$('.question_cadeau a').on('click', function(e) {
33		e.preventDefault();
34		var id_form = $(this).parents('.beneficiaire_formulaire').attr('id');
35		if (cadeau[id_form]){
36			cadeau[id_form] = false;
37			$('#'+id_form+' .beneficiaire_champs').each(function(i) {
38	            if ($(this).attr('name')=='beneficiaire_cadeau' || $(this).attr('name')=='beneficiaire_reception'){
39				} else {
40					$(this).val('');
41				}
42			});
43
44			$('#'+id_form).find('.question_cadeau a .oui.fa').addClass('fa-square-o');
45			$('#'+id_form).find('.question_cadeau a .oui.fa').removeClass('fa-check-square-o');
46			$('#'+id_form).find('.question_cadeau a .non.fa').addClass('fa-check-square-o');
47			$('#'+id_form).find('.question_cadeau a .non.fa').removeClass('fa-square-o');
48
49			$('#'+id_form+' .beneficiaire_champs[name=beneficiaire_cadeau]').val('non');
50		} else {
51			cadeau[id_form] = true;
52			//Si on a déja renseigné un bénéficiaire
53			var isset_beneficiaire = false;
54			$('#'+id_form+' .beneficiaire_select .stay').nextAll().remove()
55			var noms = [];
56			$('.beneficiaire_champs[name=beneficiaire_cadeau]').each(function(){
57				var id_form_actuel = $(this).parents('.beneficiaire_formulaire').attr('id');
58				var nom_actuel = $(this).parent().find('.beneficiaire_champs[name=beneficiaire_nom]').val();
59				var deja_en_liste = false;
60				if (noms.length > 0){
61					$.each( noms, function( index, nom ){
62					    if (nom == nom_actuel){
63							deja_en_liste = true;
64						}
65					});
66				}
67				if(cadeau[id_form_actuel] == true && id_form_actuel != id_form && !deja_en_liste){
68					$('#'+id_form+' .beneficiaire_select').append('<option value="'+$(this).parent().attr('id')+'">'+$(this).parent().find('.beneficiaire_champs[name=beneficiaire_nom]').val()+'</option>');
69					isset_beneficiaire = true;
70				}
71				noms.push($(this).parent().find('.beneficiaire_champs[name=beneficiaire_nom]').val());
72			})
73			if (isset_beneficiaire){$('#'+id_form+' .beneficiaire_select').parent().slideDown();}
74			$('#'+id_form).find('.question_cadeau a .oui.fa').addClass('fa-check-square-o');
75			$('#'+id_form).find('.question_cadeau a .oui.fa').removeClass('fa-square-o');
76			$('#'+id_form).find('.question_cadeau a .non.fa').addClass('fa-square-o');
77			$('#'+id_form).find('.question_cadeau a .non.fa').removeClass('fa-check-square-o');
78			$('#'+id_form+' .beneficiaire_champs[name=beneficiaire_cadeau]').val('oui');
79		}
80		test_logique(id_form);
81	});
82
83	$('.question_reception a').on('click', function(e) {
84		var id_form = $(this).parents('.beneficiaire_formulaire').attr('id');
85		e.preventDefault();
86		if (mail[id_form]){
87			mail[id_form] = false;
88			$('#'+id_form).find('.question_reception a .oui.fa').addClass('fa-square-o');
89			$('#'+id_form).find('.question_reception a .oui.fa').removeClass('fa-check-square-o');
90			$('#'+id_form).find('.question_reception a .non.fa').addClass('fa-check-square-o');
91			$('#'+id_form).find('.question_reception a .non.fa').removeClass('fa-square-o');
92
93			$('#'+id_form+' .beneficiaire_champs[name=beneficiaire_reception]').val('email');
94			$('#'+id_form+' .question_livraison .beneficiaire_champs').each(function(i) {
95				$(this).val('');
96			});
97		} else {
98			mail[id_form] = true;
99			$('#'+id_form).find('.question_reception a .oui.fa').addClass('fa-check-square-o');
100			$('#'+id_form).find('.question_reception a .oui.fa').removeClass('fa-square-o');
101			$('#'+id_form).find('.question_reception a .non.fa').addClass('fa-square-o');
102			$('#'+id_form).find('.question_reception a .non.fa').removeClass('fa-check-square-o');
103			$('#'+id_form+' .beneficiaire_champs[name=beneficiaire_reception]').val('livraison');
104			$('#'+id_form+' .question_mail .beneficiaire_champs').each(function(i) {
105				$(this).val('');
106			});
107		}
108		test_logique(id_form);
109	});
110
111	$('.beneficiaire_select').on('change', function() {
112		var id_formulaire_choisi = this.value;
113		var id_form_actuel = $(this).parents('.beneficiaire_formulaire').attr('id');
114		if (id_formulaire_choisi == 'clear'){
115			$('#'+id_form_actuel+' .beneficiaire_champs').val('');
116		} else {
117			$('#'+id_form_actuel+' .beneficiaire_champs').each(function() {
118				$(this).val($('#'+id_formulaire_choisi+' .beneficiaire_champs[name='+$(this).attr('name')+']').val());
119			});
120		}
121	})
122
123	function test_logique(id_form) {
124		//Si nous sommes sur un soin, on popose l'envoi par mail d'office
125		//Si non on propose l'adresse de livraison
126		if ($('#'+id_form).attr('data-produittype') == '1'){
127			if (cadeau[id_form] == true && mail[id_form] == true){
128				$('#'+id_form+' .question_beneficiaire').slideDown();
129				$('#'+id_form+' .question_mail').slideUp();
130				$('#'+id_form+' .question_livraison').slideDown();
131			} else if (cadeau[id_form] == true && mail[id_form] == false){
132				$('#'+id_form+' .question_beneficiaire').slideDown();
133				$('#'+id_form+' .question_mail').slideDown();
134				$('#'+id_form+' .question_livraison').slideUp();
135			} else if (cadeau[id_form] == false && mail[id_form] == true){
136				$('#'+id_form+' .question_beneficiaire').slideUp();
137				$('#'+id_form+' .question_mail').slideUp();
138				$('#'+id_form+' .question_livraison').slideUp();
139			} else {
140				$('#'+id_form+' .question_beneficiaire').slideUp();
141				$('#'+id_form+' .question_mail').slideUp();
142				$('#'+id_form+' .question_livraison').slideUp();
143			}
144		} else {
145			if (cadeau[id_form] == true && mail[id_form] == true){
146				$('#'+id_form+' .question_beneficiaire').slideDown();
147				$('#'+id_form+' .question_mail').slideDown();
148				$('#'+id_form+' .question_livraison').slideUp();
149			} else if (cadeau[id_form] == true && mail[id_form] == false){
150				$('#'+id_form+' .question_beneficiaire').slideDown();
151				$('#'+id_form+' .question_mail').slideUp();
152				$('#'+id_form+' .question_livraison').slideDown();
153			} else if (cadeau[id_form] == false && mail[id_form] == true){
154				$('#'+id_form+' .question_beneficiaire').slideUp();
155				$('#'+id_form+' .question_mail').slideUp();
156				$('#'+id_form+' .question_livraison').slideUp();
157			} else {
158				$('#'+id_form+' .question_beneficiaire').slideUp();
159				$('#'+id_form+' .question_mail').slideUp();
160				$('#'+id_form+' .question_livraison').slideUp();
161			}
162		}
163	}
164	// ---------- Fin de la Partie questionnement : -------------------
165
166
167	$('.article_prix_vente a.btn-thalgo').on('click', function(e) {
168		$('.article_prix_vente a.btn-thalgo').each(function() {
169			$(this).hide();
170		});
171	});
172
173	// Validation du panier
174	$('.basket_valid a.btn-cmd.hasbilling').on('click', function(e) {
175		if ($('.article_prix_vente a.btn-thalgo').length > 0) {
176			var message = $('.article_prix_vente a.btn-thalgo').first().data('name');
177			var box = bootbox.alert({
178				title : "Echantillons Thalgo",
179				message: message});
180
181				box.find('.modal-title').css({'color': '#006072'}); 
182			return false;
183		}
184		e.preventDefault();
185		var param = '';
186        $('.beneficiaire_formulaire').each(function(i) {
187            var produit_id = $(this).attr('id').split('-')[1];
188            $(this).find('.beneficiaire_champs').each(function(i) {
189                if ($(this).val().length > 0 && $(this).val() != 'vide') {
190                    param = param + '&' + $(this).attr('name') + '-' + produit_id + '=' + $(this).val();
191    			}
192            });
193		});
194        var url='';
195        if(lang_path) url='/'+lang_path;
196        url+='/basket/beneficiaire/index.html?lien=' + $(this).data('url') + param+'#23';//hl()
197		location.href = correctUrl(url);
198	});
199
200	var width = $(window).width(); 
201
202	if (width <= 768) {
203		$('.bloc-cadeaux').insertAfter('.box-resume');
204		$('.bloc-fidelite').insertAfter('.bloc-cadeaux');
205	}
206
207	window.onresize = function() {
208	var win = $(this); //this = window
209    if (win.width() > 768) {
210		$('.bloc-cadeaux').appendTo('.basket-container');
211		$('.bloc-fidelite').appendTo('.basket-container') 
212	} else if (win.width() <= 768) {
213		$('.bloc-cadeaux').insertAfter('.box-resume');
214		$('.bloc-fidelite').insertAfter('.bloc-cadeaux');
215	}
216	};
217
218	if (!(document.getElementById('popup_echantillon') === null)) { 
219		// Affichage la popup validation echantillon
220		popup_echantillon();
221	}
222
223	function popup_echantillon() {
224		var message = $('#popup_echantillon').data('name');
225		var accepter = $('#popup_echantillon').data('accepter');
226		var refuser = $('#popup_echantillon').data('refuser');
227		var box = bootbox.dialog({
228			title: 'Echantillons THALGO',
229			 message: message,
230			  buttons: {
231				ignore: {
232					  label: refuser,
233					className	: 'btn-return',
234					  callback: function() {
235						  $.ajax({
236							type	: 'GET',
237							url		: lang_path + '/basket/supprimer_echantillons/index.html',
238							error	: function(msg) {
239								alert("Une erreur s'est produite.");
240							},
241							success	: function(data) {
242								location.reload();
243							}
244						});
245					}
246				},
247				join: {
248					  label: accepter,
249					  callback: function(e) {
250						$.ajax({
251							type	: 'GET',
252							url		: lang_path + '/basket/accepter_echantillons/index.html',
253							error	: function(msg) {
254								alert("Une erreur s'est produite.");
255							},
256							success	: function(data) {
257								if ($(window).width() < 768) {
258									$([document.documentElement, document.body]).animate({
259										scrollTop: $(".bloc-cadeaux").offset().top
260									}, 2000);
261								}	
262							}
263						});
264					  }
265				}
266			  }
267		});
268		box.find('.modal-title').css({'color': '#006072'}); 
269		box.find('.btn-primary').css({'background-color': '#006072'});
270		return false;
271	}
272
273});
274
275/**
276 * Fonctions relatives à la modification de la quantité
277 */
278

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.