PageSourceSearch

https://www.malbert.fr/js/commun.js

js malbert.fr collected 2026-10-04 02:59:01 UTC 15,815 bytes, 440 lines download raw bytes

1jQuery(document).ready(function() {
2	initPlugin('');
3});
4
5jQuery(document).on('click', '.form-field .form-field-file input[type=text]', function() {
6	var $formField = $(this).closest('.form-field-file');
7	$formField.find('input[type=file]').click();
8});
9
10
11function capitalize(str){
12	return str.replace(/^(.{1})(.*)$/,function(m,c,d){
13		return c.toUpperCase()+d;
14	});
15}
16
17String.prototype.capitalize = function() {
18    return this.charAt(0).toUpperCase() + this.slice(1);
19}
20
21$(document).on('focusout','.majuscule', function() {
22	$(this).val($(this).val().toUpperCase());
23});
24
25$(document).on('focusout','.ucfirst', function() {
26	$(this).val($(this).val().capitalize());
27});
28
29$(document).on('keypress','.disabled', function() {
30	return false;
31});
32
33$(document).ajaxSuccess(function(event, xhr, settings) {
34	initPlugin('#theModal');
35});
36
37jQuery(document).on('change', '.form-field select, .form-field textarea', function(){
38	$(this).removeClass('error');
39	if($(this).val() != ""){
40		$(this).closest('.form-field').addClass('animation');
41	} else {
42		$(this).closest('.form-field').removeClass('animation');
43	}
44});
45
46jQuery(document).on('change', '.form-field .form-field-file input[type=file]', function() {
47	var $formField = $(this).closest('.form-field-file');
48	var val = document.querySelector('.form-field-file input[type=file]').value.split('\\').pop();
49	$formField.find('input[type=text]').val(val);
50	if($(this).val() != ""){
51		$(this).closest('.form-field').addClass('animation');
52	} else {
53		$(this).closest('.form-field').removeClass('animation');
54	}
55});
56
57$(document).on('click', '#boutonBurgerMenu, #closeBurgerMenu', function() {
58	$('#nav').toggleClass('show');
59});
60
61$(document).on('click', '.form-field label', function() {
62	$(this).closest('.form-field').find('input[type=text], input[type=email], input[type=password], select, textarea').focus();
63});
64
65$(document).on('change', '.form-field input[type=text], .form-field input[type=email], .form-field input[type=password],  .form-field select, .form-field textarea', function() {
66	if($(this).val() != ""){
67		$(this).closest('.form-field').addClass('animation');
68	}
69});
70
71function initPlugin(regleElt) {
72	$(regleElt+' .tabs').tabs();
73
74	jQuery('.form-field input:is([type=text], [type=email], [type=password]), .form-field select, .form-field textarea').each(function(){
75		if($(this).val() != ""){
76			$(this).closest('.form-field').addClass('animation');
77		}
78	});
79
80	jQuery(document).on('mouseleave', '.form-field.radio-checkbox', function(){
81		$(this).removeClass('hover');
82	});
83
84	$(regleElt+' .number-phone').formatter({
85	  'pattern': '{{99}}.{{99}}.{{99}}.{{99}}.{{99}}'
86	});
87
88	$(regleElt+' .codePostal').formatter({
89	  'pattern': '{{99999}}'
90	});
91
92	$(regleElt+' .dateFormat').attr('autocomplete','off');
93	$(regleElt+' .dateFormat').prop('autocomplete','off');
94	$(regleElt+' .dateFormat').formatter({
95	  'pattern': '{{99}}/{{99}}/{{9999}}'
96	});
97
98	$(regleElt+' .numeroSS').formatter({
99	  'pattern': '{{2}} {{99}} {{99}} {{9I}} {{999}} {{999}} {{99}}'
100	});
101
102	$(regleElt+' .siret').formatter({
103	  'pattern': '{{999}} {{999}} {{999}} {{99999}}'
104	});
105
106	$(regleElt+' .bic').formatter({
107	  'pattern': '{{********}} {{***}}'
108	});
109
110	$(regleElt+' .iban').formatter({
111	  'pattern': '{{cc99}} {{****}} {{****}} {{****}} {{****}} {{****}} {{***}}'
112	});
113
114	$(regleElt+' .numeric').format({precision: 2,decimal:".",allow_negative:false,autofix:true});
115	$(regleElt+' .1decimal').format({precision: 1,decimal:".",allow_negative:false,autofix:true});
116	$(regleElt+' .integer').format({precision: 0,allow_negative:false,autofix:true});
117	$(regleElt+' .integer-neg').format({precision: 0,allow_negative:true,autofix:true});
118	$(regleElt+' .numeric-neg').format({precision: 2,decimal:".",allow_negative:true,autofix:true});
119
120
121	$(regleElt+' .table-datamanagement').each(function() {
122		$(this).dataManagement({
123			'textNoData' : $(this).attr('data-textNoData'),
124			'positionIndice' : $(this).attr('data-positionIndice'),
125			'actionAdd' : ($(this).attr('data-actionAdd') == 'true'),
126			'actionDelete' : ($(this).attr('data-actionDelete') == 'true'),
127			'totalLine' : ($(this).attr('data-totalLine') == 'true'),				// Créer une ligne total
128			'calcultateColumn' : $(this).attr('data-calcultateColumn'),			// Indice de la colonne à calculer (1er = 0, 2ieme = 1, ...)
129			'fieldType' : $(this).attr('data-fieldType'),				// Type de champs qui contient les données à additioner
130		});
131	});
132
133
134
135	$('#tabs-caracteristiques '+regleElt+' .select2.carac').on("select2-selecting", function(e) {
136		var $selectValeur = $('#tabs-caracteristiques .'+e.choice.css+' select.val');
137		$.post('/admin-malbert/includes/ajax.produit-caracteristique-valeurs-option.php', { Id: e.choice.id }, function(html) {
138			$selectValeur.find('option').remove();
139			$selectValeur.select2('destroy');
140			$selectValeur.html(html);
141			$selectValeur.select2({
142				allowClear: true,
143				width: "element",
144				dropdownAutoWidth: true,
145				selectOnBlur: false,
146				searchBar: true
147			});
148		});
149	});
150
151
152	tinymce.init({
153		selector: regleElt+' textarea.wysiwyg',
154		theme: "modern",
155		language : 'fr_FR',
156		plugins: [
157			 "importcss advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
158			 "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
159			 "save table contextmenu directionality emoticons template paste textcolor moxiemanager"
160	   ],
161	   toolbar: "undo redo| bold italic underline strikethrough | alignleft aligncenter alignright al
161ignjustify | bullist numlist outdent indent | link image | formatselect | code",
162	   menubar: "",
163	   setup: function (editor) {
164			editor.on('change', function () {
165				editor.save();
166			});
167		}
168	 });
169
170	$(regleElt+' .select2').each(function() {
171		if($(this).closest('tr.hide').length == 0) {
172			$(this).select2({
173				allowClear: true,
174				width: "element",
175				dropdownAutoWidth: true,
176				selectOnBlur: false,
177				searchBar: true
178			});
179		}
180	});
181}
182
183function flash(message, type, where, closable) {
184	if($(where).prev('#alert.alert').length > 0) {
185		$(where).prev('#alert.alert').remove();
186	}
187
188	var aInserer = '<div id="alert" class="alert alert-'+type+' alert-dismissible" role="alert">';
189
190	if(closable) {
191		aInserer += '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
192	}
193
194	aInserer += message+'</div>';
195
196	$(aInserer).insertBefore(where);
197
198	$(where).prev('#alert.alert').hide().delay(300).slideDown(500);
199}
200
201
202function verifForm(form, zoneErreur) {
203	if(zoneErreur == "") {
204		zoneErreur = "#header";
205	}
206	var submitForm = true;
207	var ongletContent = $('body');
208	var message = "";
209
210	form.find('.obligatoire').each(function () {
211		if(!$(this).is(':disabled')) {
212			if($(this).is("select")) {
213				var val = $(this).find("option:selected").val();
214			} else if($(this).is("input[type=radio]")) {
215				var name = $(this).attr('name');
216				if($("input[type=radio][name="+name+"]:checked").length > 0) {
217					var val = $("input[type=radio][name="+name+"]:checked").val();
218				} else {
219					var val = "";
220				}
221			} else if($(this).is("input[type=checkbox]")) {
222				var name = $(this).attr('data-verif');
223				if($("input[type=checkbox]."+name+":checked").length > 0) {
224					var val = "ttt";
225				} else {
226					var val = "";
227				}
228			} else if($(this).is("input") || $(this).is("textarea")) {
229				var val = $(this).val();
230			}
231			if($.trim(val) == "" && val !== undefined)  {
232				var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
233				if(!ongletContent || !ul.is(ongletContent)) {
234					ongletContent = ul;
235					var id = $(this).closest('.ui-tabs-panel').attr('id');
236					ul.find('li[aria-controls='+id+'] a').click();
237				}
238				submitForm = false
239				if($(this).hasClass('.select2-offscreen')) {
240					$(this).prev('.select2-container').addClass('error');
241				} else if($(this).is('textarea') && $(this).attr('aria-hidden') == "true") {
242					$(this).prev('.mce-tinymce').addClass('error');
243				} else if($(this).is("input[type=radio]") || $(this).is("input[type=checkbox]")) {
244					$(this).parent().css('color','red');
245				} else {
246					$(this).addClass('error');
247				}
248			} else {
249				if($(this).hasClass('.select2-offscreen')) {
250					$(this).prev('.select2-container').removeClass('error');
251				} else if($(this).is('textarea') && $(this).attr('aria-hidden') == "true") {
252					$(this).prev('.mce-tinymce').removeClass('error');
253				} else if($(this).is("input[type=radio]") || $(this).is("input[type=checkbox]")) {
254					$(this).parent().css('color','');
255				} else {
256					$(this).removeClass('error');
257				}
258			}
259		}
260	});
261
262	if(!submitForm) {
263		message = "Ces champs sont obligatoires !"+message;
264	} else {
265		form.find('input[type=file]').each(function() {
266			$(this).closest('.form-field-file').removeClass('error');
267			if($(this).val() != "") {
268				var data = $(this).attr('data-extension');
269				var extentions = data.split('-');
270				var parts = $(this).val().split('.');
271				var ext = parts[parts.length-1].toLowerCase();
272
273				if(extentions.indexOf(ext) == -1) {
274					var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
275					if(!ongletContent || !ul.is(ongletContent)) {
276						ongletContent = ul;
277						var id = $(this).closest('.ui-tabs-panel').attr('id');
278						ul.find('li[aria-controls='+id+'] a').click();
279					}
280					submitForm=false;
281					$(this).closest('.form-field-file').addClass('error');
282				}
283			}
284		});
285
286		if(!submitForm) {
287			message = "Ces extensions ne sont pas autoris�es !";
288		} else {
289			var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
290
291			form.find('.email').each(function () {
292				$(this).removeClass('error');
293				if($(this).val() != "") {
294					if(!pattern.test($(this).val())) {
295						var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
296						if(!ongletContent || !ul.is(ongletContent)) {
297							ongletContent = ul;
298							var id = $(this).closest('.ui-tabs-panel').attr('id');
299							ul.find('li[aria-controls='+id+'] a').click();
300						}
301						submitForm=false;
302						$(this).addClass('error');
303					}
304				}
305			});
306
307			if(!submitForm) {
308				message = "Ces e-mails ne sont pas corrects !";
309			} else {
310				var pattern = new RegExp(/^[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}/i);
311				//var pattern2 = new RegExp(/^/+[0-9]{2}[.]{1}[0-9]{1}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}[.]{1}[0-9]{2}/i);
312
313				form.find('.number-phone').each(function () {
314					$(this).removeClass('error');
315					if($(this).val() != "") {
316						if(!pattern.test($(this).val()) /*&& !pattern2.test($(this).val())*/) {
317							var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
318							if(!ongletContent || !ul.is(ongletContent)) {
319								ongletContent = ul;
320								var id = $(this).closest('.ui-tabs-panel').attr('id');
321								ul.find('li[aria-controls='+id+'] a').click();
322							}
323							submitForm=false;
324							$(this).addClass('error');
325						}
326					}
327				});
328
329				if(!submitForm) {
330					message = "Ces num�ros de t�l�phones ne sont pas corrects !";
331				} else {
332					form.find('.codePostal').each(function() {
333						$(this).removeClass('error');
334						if($(this).val() != "") {
335							if(!$.isNumeric($(this).val()) || $(this).val() < 0) {
336								var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
337								if(!ongletContent || !ul.is(ongletContent)) {
338									ongletContent = ul;
339									var id = $(this).closest('.ui-tabs-panel').attr('id');
340									ul.find('li[aria-controls='+id+'] a').click();
341								}
342								submitForm=false;
343								$(this).addClass('error');
344							}
345						}
346					});
347
348					if(!submitForm) {
349						message = "Ces codes postaux ne sont pas corrects !";
350					} else {
351						form.find('.double-element').each(function() {
352							$(this).find('input').removeClass('error');
353							var val1 = $(this).find('input').first().val();
354							var val2 = $(this).find('input').last().val();
355
356							if( val1 != "" && val2 != "" && parseInt(val1) > parseInt(val2)) {
357								var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
358								if(!ongletContent || !ul.is(ongletContent)) {
359									ongletContent = ul;
360									var id = $(this).closest('.ui-tabs-panel').attr('id');
361									ul.find('li[aria-controls='+id+'] a').click();
362								}
363								submitForm=false;
364								$(this).find('input').addClass('error');
365							}
366						});
367
368						if(!submitForm) {
369							message = "Ces valeurs ne sont pas coh�rentes !";
370						} else {
371							form.find('.fourchette-horaire').each(function() {
372								$(this).find('select').removeClass('error');
373								var selects = $(this).find('select');
374								var heure1 = selects.eq(0).find('option:selected').val();
375								var minute1 = selects.eq(1).find('option:selected').val();
376								var heure2 = selects.eq(2).find('option:selected').val();
377								var minute2 = selects.eq(3).find('option:selected').val();
378
379								var horaire1 = heure1+':'+minute1;
380								var horaire2 = heure2+':'+minute2;
381
382								if( horaire1 > horaire2) {
383									var ul = $(this).closest('.ui-tabs').find('.ui-tabs-nav');
384									if(!ongletContent || !ul.is(ongletContent)) {
385										ongletContent = ul;
386										var id = $(this).closest('.ui-tabs-panel').attr('id');
387										ul.find('li[aria-controls='+id+'] a').click();
388									}
389									submitForm=false;
390									$(this).find('select').addClass('error');
391								}
392							});
393
394							if(!submitForm) {
395								message = "Ces horaires ne sont pas cohérents !";
396							} else {
397								form.find('.identique').each(function() {
398									if(submitForm) {
399										var idPaire = $(this).attr('data-identique');
400										var val = $(this).val();
401
402										if($("#"+idPaire).val() != val) {
403											var ul = $(this).closest('.tab-content').prev('.nav-tabs');
404											if(!ongletContent || !ul.is(ongletContent)) {
405												ongletContent = ul;
406												var id = $(this).closest('.tab-pane').attr('id');
407												ul.find('li#nav'+id+' a').click();
408											}
409											submitForm=false;
410										}
411
412										if(!submitForm) {
413											$(this).addClass('error');
414											$("#"+idPaire).addClass('error');
415										} else {
416											$(this).removeClass('error');
417											$("#"+idPaire).removeClass('error');
418										}
419									}
420								});
421
422								if(!submitForm) {
423									message = "Ces valeurs ne sont pas identique !";
424								} else {
425									return true;
426								}
427							}
428						}
429					}
430				}
431			}
432		}
433	}
434	flash(message,'danger',zoneErreur,true);
435
436	$('html, body').animate({scrollTop:0}, 'slow');
437
438	return false;
439}
440

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.