Subversion Repositories eFlore/Applications.cel

Rev

Rev 3292 | Rev 3425 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3292 Rev 3330
Line 38... Line 38...
38
 
38
 
39
	// système de traduction minimaliste
39
	// système de traduction minimaliste
40
	this.msgs = {
40
	this.msgs = {
41
		fr: {
41
		fr: {
-
 
42
			'format-non-supporte': 'Le format de fichier n\'est pas supporté, les formats acceptés sont',
42
			'format-non-supporte': 'Le format de fichier n\'est pas supporté, les formats acceptés sont',
43
			'image-deja-chargee' : 'Cette image a déjà été utilisée',
43
			'date-incomplete': 'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.',
44
			'date-incomplete': 'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.',
44
			'observations-transmises': 'observations transmises',
45
			'observations-transmises': 'observations transmises',
45
			'taxon-ou-image' : 'Veuillez transmettre au moins, soit une image, soit une espèce',
46
			'taxon-ou-image' : 'Veuillez transmettre au moins, soit une image, soit une espèce',
46
			'supprimer-observation-liste': 'Supprimer cette observation de la liste à transmettre',
47
			'supprimer-observation-liste': 'Supprimer cette observation de la liste à transmettre',
Line 59... Line 60...
59
			'lieu-dit' : 'Lieu-dit',
60
			'lieu-dit' : 'Lieu-dit',
60
			'station' : 'Station'
61
			'station' : 'Station'
61
		},
62
		},
62
		en: {
63
		en: {
63
			'format-non-supporte': 'The file format is not supported, the accepted formats are',
64
			'format-non-supporte': 'The file format is not supported, the accepted formats are',
-
 
65
			'image-deja-chargee' : 'This image has already been used',
64
			'date-incomplete': 'Format: dd / mm / yyyy. Incomplete date, use 0, example: 00/12/2011.',
66
			'date-incomplete': 'Format: dd / mm / yyyy. Incomplete date, use 0, example: 00/12/2011.',
65
			'observations-transmises': 'observations transmitted',
67
			'observations-transmises': 'observations transmitted',
66
			'taxon-ou-image' : 'Please transmit at least one image or one species',
68
			'taxon-ou-image' : 'Please transmit at least one image or one species',
67
			'supprimer-observation-liste': 'Delete this observation from the list to be transmitted',
69
			'supprimer-observation-liste': 'Delete this observation from the list to be transmitted',
68
			'milieu': 'Environment',
70
			'milieu': 'Environment',
Line 93... Line 95...
93
 
95
 
94
/**
96
/**
95
 * Initialise le formulaire, les validateurs, les listes de complétion...
97
 * Initialise le formulaire, les validateurs, les listes de complétion...
96
 */
98
 */
97
WidgetSaisie.prototype.initForm = function() {
-
 
98
 
99
WidgetSaisie.prototype.initForm = function() {
Line 99... Line 100...
99
	var lthis = this;
100
	const lthis = this;
Line 100... Line 101...
100
 
101
 
101
	this.chargerStatutSSO();
102
	this.chargerStatutSSO();
Line 153... Line 154...
153
 
154
 
154
/**
155
/**
155
 * Initialise les écouteurs d'événements
156
 * Initialise les écouteurs d'événements
156
 */
157
 */
157
WidgetSaisie.prototype.initEvts = function() {
158
WidgetSaisie.prototype.initEvts = function() {
-
 
159
	const lthis = this;
158
	var lthis = this;
160
 
159
	// Empêcher que le module carto ne bind ses events partout
161
	// Empêcher que le module carto ne bind ses events partout
160
	$( '#tb-geolocation' ).on( 'submit blur click focus mousedown mouseleave mouseup touchend touchstart change', '*', function( event ) {
162
	$( '#tb-geolocation' ).on( 'submit blur click focus mousedown mouseleave mouseup change', '*', function( event ) {
161
		event.preventDefault();
163
		event.preventDefault();
162
		return false;
164
		return false;
-
 
165
	});
Line 163... Line 166...
163
	});
166
	$( '#tb-geolocation' ).on( 'location' , lthis.locationHandler.bind( lthis ) );
164
 
167
 
165
	// identité
168
	// identité
166
	$( '#bouton-inscription' ).attr( 'href', this.urlSiteTb() + 'inscription' );
169
	$( '#bouton-inscription' ).attr( 'href', this.urlSiteTb() + 'inscription' );
Line 192... Line 195...
192
			success: lthis.afficherMiniature.bind( lthis ), // post-submit callback
195
			success: lthis.afficherMiniature.bind( lthis ), // post-submit callback
193
			dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
196
			dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
194
			resetForm: true // reset the form after successful submit
197
			resetForm: true // reset the form after successful submit
195
		};
198
		};
196
		$( '#miniature' ).append( '<img id="miniature-chargement" class="miniature" alt="chargement" src="' + this.chargementImageIconeUrl + '"/>' );
199
		$( '#miniature' ).append( '<img id="miniature-chargement" class="miniature" alt="chargement" src="' + this.chargementImageIconeUrl + '"/>' );
-
 
200
 
197
		$( '#ajouter-obs' ).attr( 'disabled', 'disabled' );
201
		var imgCheminTmp    = $( '#fichier' ).val(),
198
		if( lthis.verifierFormat( $( '#fichier' ).val() ) ) {
202
			formatImgOk     = lthis.verifierFormat( imgCheminTmp ),
-
 
203
			imgNonDupliquee = lthis.verifierDuplication( imgCheminTmp );
-
 
204
 
-
 
205
		if( formatImgOk && imgNonDupliquee ) {
199
			$( '#form-upload' ).ajaxSubmit( options );
206
			$( '#form-upload' ).ajaxSubmit( options );
200
		} else {
207
		} else {
201
			$( '#form-upload' )[0].reset();
208
			$( '#form-upload' )[0].reset();
-
 
209
			if ( !formatImgOk ) {
202
			window.alert( lthis.msgTraduction( 'format-non-supporte' ) + ' ' + $( '#fichier' ).attr( 'accept' ) );
210
				window.alert( lthis.msgTraduction( 'format-non-supporte' ) + ' ' + $( '#fichier' ).attr( 'accept' ) );
-
 
211
			}
-
 
212
			if ( !imgNonDupliquee ) {
-
 
213
				window.alert( lthis.msgTraduction( 'image-deja-chargee' ) );
-
 
214
			}
203
		}
215
		}
204
		return false;
216
		return false;
205
	});
217
	});
Line 206... Line 218...
206
 
218
 
Line 240... Line 252...
240
/**
252
/**
241
 * Interroge le SSO pour connaître le statut de l'utilisateur, et change le menu
253
 * Interroge le SSO pour connaître le statut de l'utilisateur, et change le menu
242
 * à droite de la barre en fonction
254
 * à droite de la barre en fonction
243
 */
255
 */
244
WidgetSaisie.prototype.chargerStatutSSO = function() {
256
WidgetSaisie.prototype.chargerStatutSSO = function() {
-
 
257
	const lthis = this;
-
 
258
	var urlAuth = this.urlBaseAuth + '/identite';
-
 
259
 
245
	$( '#form-observateur' )[0].reset();
260
	$( '#form-observateur' )[0].reset();
246
	var lthis = this;
-
 
Line 247... Line -...
247
 
-
 
Line 248... Line 261...
248
	var urlAuth = this.urlBaseAuth + '/identite';
261
 
249
 
262
 
250
	if( 'local' !== this.mode ) {
263
	if( 'local' !== this.mode ) {
251
		this.connexion( urlAuth, true );
264
		this.connexion( urlAuth, true );
Line 260... Line 273...
260
 
273
 
261
/**
274
/**
262
 * Déconnecte l'utilisateur du SSO
275
 * Déconnecte l'utilisateur du SSO
263
 */
276
 */
-
 
277
WidgetSaisie.prototype.deconnecterUtilisateur = function() {
-
 
278
  var urlAuth = this.urlBaseAuth + '/deconnexion';
264
WidgetSaisie.prototype.deconnecterUtilisateur = function() {
279
 
265
  if( 'local' === this.mode ) {
280
  if( 'local' === this.mode ) {
266
	this.definirUtilisateur();
281
	this.definirUtilisateur();
267
	window.location.reload();
282
	window.location.reload();
268
	return;
283
	return;
269
  }
-
 
270
 
-
 
271
  var urlAuth = this.urlBaseAuth + '/deconnexion';
-
 
272
 
284
  }
273
  this.connexion( urlAuth, false );
285
  this.connexion( urlAuth, false );
Line 274... Line 286...
274
};
286
};
275
 
287
 
-
 
288
WidgetSaisie.prototype.connexion = function( urlAuth, connexionOnOff ) {
276
WidgetSaisie.prototype.connexion = function( urlAuth, connexionOnOff ) {
289
	const lthis = this;
277
	var lthis = this;
290
 
278
  $.ajax({
291
  $.ajax({
279
	url: urlAuth,
292
	url: urlAuth,
280
	type: "GET",
293
	type: "GET",
Line 371... Line 384...
371
  return window.location.origin + urlPart;
384
  return window.location.origin + urlPart;
372
};
385
};
Line 373... Line 386...
373
 
386
 
374
// Identité Observateur par courriel
387
// Identité Observateur par courriel
375
WidgetSaisie.prototype.requeterIdentiteCourriel = function() {
388
WidgetSaisie.prototype.requeterIdentiteCourriel = function() {
-
 
389
	const lthis = this;
376
	var lthis = this;
390
 
377
	var courriel = $( '#courriel' ).val();
391
	var courriel = $( '#courriel' ).val();
-
 
392
	var urlAnnuaire = this.serviceAnnuaireIdUrl + courriel;
378
	var urlAnnuaire = this.serviceAnnuaireIdUrl + courriel;
393
 
379
	if ( valeurOk( courriel ) ) {
394
	if ( valeurOk( courriel ) ) {
380
		$.ajax({
395
		$.ajax({
381
			url : urlAnnuaire,
396
			url : urlAnnuaire,
382
			type : 'GET',
397
			type : 'GET',
Line 439... Line 454...
439
WidgetSaisie.prototype.formaterNom = function() {
454
WidgetSaisie.prototype.formaterNom = function() {
440
	$( this ).val( $( this ).val().toUpperCase() );
455
	$( this ).val( $( this ).val().toUpperCase() );
441
};
456
};
Line 442... Line 457...
442
 
457
 
443
WidgetSaisie.prototype.formaterPrenom = function() {
458
WidgetSaisie.prototype.formaterPrenom = function() {
444
	var prenom = new Array(),
459
	var prenom     = new Array(),
445
			mots = $( this ).val().split( ' ' ),
460
		mots       = $( this ).val().split( ' ' ),
Line 446... Line 461...
446
			motsLength = mots.length;
461
		motsLength = mots.length;
447
 
462
 
448
	for ( var i = 0; i < motsLength; i++ ) {
463
	for ( var i = 0; i < motsLength; i++ ) {
449
		var mot = mots[i];
464
		var mot = mots[i];
450
		if ( 0 <= mot.indexOf( '-' ) ) {
465
		if ( 0 <= mot.indexOf( '-' ) ) {
451
			var prenomCompose = new Array(),
466
			var prenomCompose = new Array(),
452
					motsComposes = mot.split( '-' )
467
				motsComposes = mot.split( '-' )
453
					motsComposesLength = motsComposes.length;
468
				motsComposesLength = motsComposes.length;
454
			for ( var j = 0; j < motsComposesLength; j++ ) {
469
			for ( var j = 0; j < motsComposesLength; j++ ) {
Line 455... Line 470...
455
				var motSimple = motsComposes[j],
470
				var motSimple    = motsComposes[j],
456
						motMajuscule = motSimple.charAt(0).toUpperCase() + motSimple.slice(1);
471
					motMajuscule = motSimple.charAt(0).toUpperCase() + motSimple.slice(1);
457
 
472
 
458
				prenomCompose.push( motMajuscule );
473
				prenomCompose.push( motMajuscule );
Line 471... Line 486...
471
	return false;
486
	return false;
472
};
487
};
Line 473... Line 488...
473
 
488
 
474
// Préchargement des infos-obs ************************************************/
489
// Préchargement des infos-obs ************************************************/
-
 
490
WidgetSaisie.prototype.chargerInfoObs = function() {
-
 
491
	const lthis = this;
475
WidgetSaisie.prototype.chargerInfoObs = function() {
492
 
476
	var urlObs = this.serviceObsUrl + '/' + this.obsId;
-
 
-
 
493
	var urlObs = this.serviceObsUrl + '/' + this.obsId;
477
	var lthis = this;
494
 
478
	$.ajax({
495
	$.ajax({
479
		url: urlObs,
496
		url: urlObs,
480
		type: 'GET',
497
		type: 'GET',
481
		success: function( data, textStatus, jqXHR ) {
498
		success: function( data, textStatus, jqXHR ) {
Line 546... Line 563...
546
					});
563
					});
547
		}
564
		}
548
	}
565
	}
549
};
566
};
Line 550... Line -...
550
 
-
 
551
 
567
 
552
WidgetSaisie.prototype.surChangementValeurTaxon = function() {
568
WidgetSaisie.prototype.surChangementValeurTaxon = function() {
Line 553... Line 569...
553
	var numNomSel = 0;
569
	var numNomSel = 0;
554
 
570
 
Line 582... Line 598...
582
	}
598
	}
583
};
599
};
Line 584... Line 600...
584
 
600
 
585
// Autocompletion taxons ******************************************************/
601
// Autocompletion taxons ******************************************************/
586
WidgetSaisie.prototype.ajouterAutocompletionNoms = function() {
602
WidgetSaisie.prototype.ajouterAutocompletionNoms = function() {
Line 587... Line 603...
587
	var lthis = this;
603
	const lthis = this;
-
 
604
 
588
 
605
	var taxonSelecteur = '#taxon';
589
	var taxonSelecteur = '#taxon';
606
 
590
	if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
607
	if ( valeurOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
591
		taxonSelecteur += '-autre';
608
		taxonSelecteur += '-autre';
592
	}
609
	}
593
	$( taxonSelecteur ).autocomplete({
610
	$( taxonSelecteur ).autocomplete({
Line 616... Line 633...
616
	$( taxonSelecteur ).on( 'autocompleteselect', this.surAutocompletionTaxon );
633
	$( taxonSelecteur ).on( 'autocompleteselect', this.surAutocompletionTaxon );
617
};
634
};
Line 618... Line 635...
618
 
635
 
619
WidgetSaisie.prototype.getUrlAutocompletionNomsSci = function() {
636
WidgetSaisie.prototype.getUrlAutocompletionNomsSci = function() {
-
 
637
	var taxonSelecteur = '#taxon';
620
	var taxonSelecteur = '#taxon';
638
 
621
	if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
639
	if ( valeurOk( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
622
		taxonSelecteur += '-autre';
640
		taxonSelecteur += '-autre';
-
 
641
	}
623
	}
642
 
624
	var mots = $( taxonSelecteur ).val();
643
	var mots = $( taxonSelecteur ).val();
-
 
644
	var url = this.serviceAutocompletionNomSciUrlTpl.replace( '{referentiel}', this.nomSciReferentiel );
625
	var url = this.serviceAutocompletionNomSciUrlTpl.replace( '{referentiel}', this.nomSciReferentiel );
645
 
626
	url = url.replace( '{masque}', mots );
646
	url = url.replace( '{masque}', mots );
627
	return url;
647
	return url;
Line 628... Line 648...
628
};
648
};
629
 
-
 
630
WidgetSaisie.prototype.traiterRetourNomsSci = function( data ) {
649
 
-
 
650
WidgetSaisie.prototype.traiterRetourNomsSci = function( data ) {
631
 
651
	var taxonSelecteur = '#taxon';
632
	var taxonSelecteur = '#taxon';
652
 
633
	if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
653
	if ( valeurOk ( $( '#taxon-liste' ).val(), true, 'autre' ) ) {
634
		taxonSelecteur += '-autre';
654
		taxonSelecteur += '-autre';
635
	}
655
	}
Line 687... Line 707...
687
		if ( ui.item.retenu ) {
707
		if ( ui.item.retenu ) {
688
			$( '#taxon' ).addClass( 'ns-retenu' );
708
			$( '#taxon' ).addClass( 'ns-retenu' );
689
		} else {
709
		} else {
690
			$( '#taxon' ).removeClass( 'ns-retenu' );
710
			$( '#taxon' ).removeClass( 'ns-retenu' );
691
		}
711
		}
692
 
-
 
693
		// Si l'espèce est mal déterminée la certitude est "à déterminer"
712
		// Si l'espèce est mal déterminée la certitude est "à déterminer"
694
		if( !valeurOk( $( '#taxon' ).data( 'numNomSel' ) ) ) {
713
		if( !valeurOk( $( '#taxon' ).data( 'numNomSel' ) ) ) {
695
			$( '#certitude' ).find( 'option' ).each( function() {
714
			$( '#certitude' ).find( 'option' ).each( function() {
696
				if ( $( this ).hasClass( 'aDeterminer' ) ) {
715
				if ( $( this ).hasClass( 'aDeterminer' ) ) {
697
					$( this ).attr( 'selected', true );
716
					$( this ).attr( 'selected', true );
Line 702... Line 721...
702
		}
721
		}
703
	}
722
	}
704
	$( '#taxon' ).trigger( 'change' );
723
	$( '#taxon' ).trigger( 'change' );
705
};
724
};
Line -... Line 725...
-
 
725
 
-
 
726
 
-
 
727
// Géolocalisation *************************************************************/
-
 
728
/**
-
 
729
 * Fonction handler de l'évenement location du module tb-geoloc
-
 
730
 */
-
 
731
WidgetSaisie.prototype.locationHandler = function( location ) {
-
 
732
	var locDatas = location.originalEvent.detail;
-
 
733
 
-
 
734
	if ( valeurOk( locDatas ) ) {
-
 
735
		console.log( locDatas );
-
 
736
		var altitude      = ( valeurOk( locDatas.elevation ) ) ? locDatas.elevation : '';
-
 
737
		var pays          = ( valeurOk( locDatas.osmCountryCode ) ) ? locDatas.osmCountryCode.toUpperCase() : 'FR';
-
 
738
		var latitude      = '';
-
 
739
		var longitude     = '';
-
 
740
		var coordLineaire = '';
-
 
741
		var nomCommune    = '';
-
 
742
		var communeInsee  = '';
-
 
743
 
-
 
744
		if ( valeurOk( locDatas.geometry.coordinates ) ) {
-
 
745
			if ( 'Point' === locDatas.geometry.type ) {
-
 
746
				if ( valeurOk( locDatas.geometry.coordinates[0] ) ) {
-
 
747
					longitude = locDatas.geometry.coordinates[0];
-
 
748
				}
-
 
749
				if ( valeurOk( locDatas.geometry.coordinates[1] ) ) {
-
 
750
					latitude = locDatas.geometry.coordinates[1];
-
 
751
				}
-
 
752
			} else if ( 'LineString' === locDatas.geometry.type ) {// on a besoin que d'un point de la rue
-
 
753
				coordLineaire = JSON.stringify( locDatas.geometry.coordinates );
-
 
754
				if ( valeurOk( locDatas.geometry.coordinates[0][0] ) ) {
-
 
755
					longitude = locDatas.geometry.coordinates[0][0];
-
 
756
				}
-
 
757
				if ( valeurOk( locDatas.geometry.coordinates[0][1] ) ){
-
 
758
					latitude = locDatas.geometry.coordinates[0][1];
-
 
759
				}
-
 
760
			}
-
 
761
		}
-
 
762
		if ( valeurOk( locDatas.inseeData ) ) {
-
 
763
			nomCommune = locDatas.inseeData.nom;
-
 
764
			communeInsee = ( valeurOk( locDatas.inseeData.code ) ) ? locDatas.inseeData.code : '';
-
 
765
		} else if ( valeurOk( locDatas.locality ) ) {
-
 
766
			nomCommune = locDatas.locality;
-
 
767
		} else if ( valeurOk( locDatas.locality ) ) {
-
 
768
			nomCommune = locDatas.osmCounty;
-
 
769
		}
-
 
770
		$( '#coord-lineaire' ).val( coordLineaire );
-
 
771
		$( '#latitude' ).val( latitude );
-
 
772
		$( '#longitude' ).val( longitude );
-
 
773
		$( '#commune-nom' ).val( nomCommune );
-
 
774
		$( '#commune-insee' ).val( communeInsee );
-
 
775
		$( '#altitude' ).val( altitude );
-
 
776
		$( '#pays' ).val( pays );
-
 
777
		if ( valeurOk( $( '#latitude' ).val() ) && valeurOk( $( '#longitude' ).val() ) ) {
-
 
778
			$( '#geoloc' ).closest( '.control-group' ).removeClass( 'error' );
-
 
779
		} else {
-
 
780
			$( '#geoloc' ).closest( '.control-group' ).addClass( 'error' );
-
 
781
		}
-
 
782
	} else {
-
 
783
		console.log( 'Error location' );
-
 
784
	}
-
 
785
}
706
 
786
 
707
// Form Validator *************************************************************/
787
// Form Validator *************************************************************/
708
WidgetSaisie.prototype.configurerFormValidator = function() {
788
WidgetSaisie.prototype.configurerFormValidator = function() {
Line 709... Line 789...
709
	var lthis = this;
789
	const lthis = this;
710
 
790
 
711
	$.validator.addMethod(
791
	$.validator.addMethod(
712
		'dateCel',
792
		'dateCel',
713
		function ( value, element ) {
793
		function ( value, element ) {
714
			return ( valeurOk( value ) && ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( value ) ) );
794
			return ( valeurOk( value ) && ( /^(?:[0-9]{4}-[0-9]{2}-[0-9]{2})|(?:[0-9]{2}\/[0-9]{2}\/[0-9]{4})$/.test( value ) ) );
715
		},
795
		},
716
		lthis.msgTraduction( 'date-incomplete' )
-
 
717
	);
796
		lthis.msgTraduction( 'date-incomplete' )
718
 
797
	);
719
	$.validator.addMethod(
798
	$.validator.addMethod(
720
		'userEmailOk',
799
		'userEmailOk',
721
		function ( value, element ) {
800
		function ( value, element ) {
722
			return ( valeurOk( value ) );
801
			return ( valeurOk( value ) );
723
		},
802
		},
724
		''
-
 
725
	);
803
		''
726
 
804
	);
727
	$.validator.addMethod(
805
	$.validator.addMethod(
728
		'minMaxOk',
806
		'minMaxOk',
729
		function ( value, element, param ) {
807
		function ( value, element, param ) {
730
			$.validator.messages.minMaxOk = lthis.validerMinMax( element ).message;
808
			$.validator.messages.minMaxOk = lthis.validerMinMax( element ).message;
731
			return lthis.validerMinMax( element ).cond;
809
			return lthis.validerMinMax( element ).cond;
732
		},
810
		},
733
		$.validator.messages.minMaxOk
-
 
734
	);
811
		$.validator.messages.minMaxOk
735
 
812
	);
736
	$.validator.addMethod(
813
	$.validator.addMethod(
737
		'listFields',
814
		'listFields',
738
		function ( value, element ) {
815
		function ( value, element ) {
739
			return ( valeurOk( value ) );
816
			return ( valeurOk( value ) );
740
		},
817
		},
741
		''
-
 
742
	);
818
		''
743
 
819
	);
744
	$.extend( $.validator.defaults, {
820
	$.extend( $.validator.defaults, {
745
		errorElement: 'span',
821
		errorElement: 'span',
746
		onfocusout: function( element ) {
822
		onfocusout: function( element ) {
Line 771... Line 847...
771
		}
847
		}
772
	});
848
	});
773
};
849
};
Line 774... Line 850...
774
 
850
 
775
WidgetSaisie.prototype.chpEtendusValidation = function() {
851
WidgetSaisie.prototype.chpEtendusValidation = function() {
-
 
852
	const lthis = this;
776
	var lthis = this;
853
 
777
	var $thisForm = $( '#form-supp' ),
854
	var $thisForm = $( '#form-supp' ),
778
			elements  =
855
		elements  =
779
				'.checkbox,'+
856
			'.checkbox,'+
780
				'.radio,'+
857
			'.radio,'+
781
				'.checkboxes,'+
858
			'.checkboxes,'+
782
				'.select,'+
859
			'.select,'+
783
				'textarea,'+
860
			'textarea,'+
784
				'input[type=text]:not(.collect-other),'+
861
			'input[type=text]:not(.collect-other),'+
785
				'input[type=email],'+
862
			'input[type=email],'+
786
				'input[type=number],'+
863
			'input[type=number],'+
787
				'input[type=range],'+
864
			'input[type=range],'+
788
				'input[type=date]',
865
			'input[type=date]',
789
			speFields = ['checkbox','radio','checkboxes','select'],
866
		speFields = ['checkbox','radio','checkboxes','select'],
790
			spefieldsCount = speFields.length,
867
		spefieldsCount = speFields.length,
791
			chpSuppValidation = {
868
		chpSuppValidation = {
792
				rules : {},
869
			rules : {},
793
				messages : {},
870
			messages : {},
794
				minmax : []
871
			minmax : []
795
			},
872
		},
796
			errors = {},
873
		errors = {},
797
			namesListFields = [],
874
		namesListFields = [],
Line 798... Line 875...
798
			picked = '';
875
		picked = '';
799
 
876
 
800
	$( elements, $thisForm ).each( function() {
877
	$( elements, $thisForm ).each( function() {
-
 
878
		for( var fieldsClass = 0; spefieldsCount > fieldsClass; fieldsClass++ ) {
801
		for( var fieldsClass = 0; spefieldsCount > fieldsClass; fieldsClass++ ) {
879
			if ( valeurOk( $( this ).attr( 'required' ) ) && $( this ).hasClass( speFields[fieldsClass] ) && !valeurOk( chpSuppValidation.rules[ dataName ] ) ) {
Line 802... Line 880...
802
			if ( valeurOk( $( this ).attr( 'required' ) ) && $( this ).hasClass( speFields[fieldsClass] ) && !valeurOk( chpSuppValidation.rules[ dataName ] ) ) {
880
 
803
				var dataName = $( this ).data( 'name' );
881
				var dataName = $( this ).data( 'name' );
804
 
-
 
805
				namesListFields.push( dataName );
882
 
806
				chpSuppValidation.rules[ dataName ] = { required : true };
883
				namesListFields.push( dataName );
807
 
884
				chpSuppValidation.rules[ dataName ] = { required : true };
808
				if ( valeurOk( $( '.other', $( this ) ) ) ) {
885
				if ( valeurOk( $( '.other', $( this ) ) ) ) {
809
					picked = ( 'select' === speFields[fieldsClass] ) ? ':selected' : ':checked';
886
					picked = ( 'select' === speFields[fieldsClass] ) ? ':selected' : ':checked';
Line 819... Line 896...
819
			}
896
			}
820
		}
897
		}
821
		if ( valeurOk( $( this ).attr( 'name' ) ) && valeurOk ( $( this ).attr( 'required' ) ) && 0 > $.inArray( $( this ).attr( 'name' ) , namesListFields ) ) {
898
		if ( valeurOk( $( this ).attr( 'name' ) ) && valeurOk ( $( this ).attr( 'required' ) ) && 0 > $.inArray( $( this ).attr( 'name' ) , namesListFields ) ) {
822
			chpSuppValidation.rules[ $( this ).attr( 'name' ) ] = { required : true, minlength: 1 };
899
			chpSuppValidation.rules[ $( this ).attr( 'name' ) ] = { required : true, minlength: 1 };
823
			if(
900
			if(
824
					( valeurOk( $( this ).attr( 'type' ), true, 'number' ) || valeurOk( $( this ).attr( 'type' ), true, 'range' ) ) &&
901
				( valeurOk( $( this ).attr( 'type' ), true, 'number' ) || valeurOk( $( this ).attr( 'type' ), true, 'range' ) ) &&
825
					( valeurOk( $( this )[0].min ) || valeurOk( $( this )[0].max ) )
902
				( valeurOk( $( this )[0].min ) || valeurOk( $( this )[0].max ) )
826
				) {
903
			) {
827
				chpSuppValidation.rules[ $( this ).attr('name') ]['minMaxOk'] = true;
904
				chpSuppValidation.rules[ $( this ).attr('name') ]['minMaxOk'] = true;
828
				chpSuppValidation.messages[ $( this ).attr('name') ] = lthis.validerMinMax( $( this )[0] ).message;
905
				chpSuppValidation.messages[ $( this ).attr('name') ] = lthis.validerMinMax( $( this )[0] ).message;
829
			}
906
			}
830
		}
907
		}
831
	});
908
	});
Line 843... Line 920...
843
};
920
};
Line 844... Line 921...
844
 
921
 
Line 845... Line 922...
845
WidgetSaisie.prototype.validerMinMax = function( element ) {
922
WidgetSaisie.prototype.validerMinMax = function( element ) {
846
 
923
 
847
	var mMCond      = new Boolean(),
924
	var mMCond      = new Boolean(),
848
			minCond     = parseFloat( element.value ) >= parseFloat( element.min ),
925
		minCond     = parseFloat( element.value ) >= parseFloat( element.min ),
849
			maxCond     = parseFloat( element.value ) <= parseFloat( element.max ),
926
		maxCond     = parseFloat( element.value ) <= parseFloat( element.max ),
Line 850... Line 927...
850
			messageMnMx = 'La valeur entrée doit être',
927
		messageMnMx = 'La valeur entrée doit être',
851
			returnMnMx  = { cond : true , message : '' };
928
		returnMnMx  = { cond : true , message : '' };
852
 
929
 
853
	if(
930
	if(
854
			( valeurOk( element.type, true, 'number' ) || valeurOk( element.type, true, 'range' ) ) &&
931
		( valeurOk( element.type, true, 'number' ) || valeurOk( element.type, true, 'range' ) ) &&
855
			( valeurOk( element.min ) || valeurOk( element.max ) )
932
		( valeurOk( element.min ) || valeurOk( element.max ) )
856
		) {
933
	) {
857
		if ( element.min && element.max ) {
934
		if ( element.min && element.max ) {
858
			messageMnMx += ' comprise entre ' + element.min + ' et ' + element.max;
935
			messageMnMx += ' comprise entre ' + element.min + ' et ' + element.max;
Line 871... Line 948...
871
 
948
 
Line 872... Line 949...
872
};
949
};
-
 
950
 
873
 
951
 
874
 
-
 
Line 875... Line 952...
875
WidgetSaisie.prototype.definirReglesFormValidator = function() {
952
WidgetSaisie.prototype.definirReglesFormValidator = function() {
876
	var formSuppValidation = this.chpEtendusValidation(),
953
	const lthis = this;
877
		lthis = this;
954
	var formSuppValidation = this.chpEtendusValidation();
878
 
955
 
Line 907... Line 984...
907
		rules : formSuppValidation.rules,
984
		rules : formSuppValidation.rules,
908
		messages : formSuppValidation.messages,
985
		messages : formSuppValidation.messages,
909
		errorPlacement : function( error , element ) {
986
		errorPlacement : function( error , element ) {
910
			if ( 0 < Object.keys( formSuppValidation.errors ).length ) {
987
			if ( 0 < Object.keys( formSuppValidation.errors ).length ) {
911
				var errorsKeys = Object.keys( formSuppValidation.errors ),
988
				var errorsKeys = Object.keys( formSuppValidation.errors ),
912
						thisKey = '',
989
					thisKey = '',
913
						errorsFlag = true;
990
					errorsFlag = true;
914
				for ( i = 0 ; i < errorsKeys.length ; i++ ) {
991
				for ( i = 0 ; i < errorsKeys.length ; i++ ) {
915
					thisKey = errorsKeys[i];
992
					thisKey = errorsKeys[i];
916
					if( $( element ).attr( 'name' ) === thisKey ) {
993
					if( $( element ).attr( 'name' ) === thisKey ) {
917
						$( formSuppValidation.errors[thisKey] ).append( error );
994
						$( formSuppValidation.errors[thisKey] ).append( error );
918
						errorsFlag = false;
995
						errorsFlag = false;
Line 924... Line 1001...
924
			} else {
1001
			} else {
925
				error.insertAfter( element );
1002
				error.insertAfter( element );
926
			}
1003
			}
927
		}
1004
		}
928
	});
1005
	});
929
 
-
 
930
	$( '#form-supp .select' ).change( function() {
1006
	$( '#form-supp .select' ).change( function() {
931
		$( this ).valid();
1007
		$( this ).valid();
932
	});
1008
	});
933
 
-
 
934
	$( 'input[type=date]' ).on( 'input', function() {
1009
	$( 'input[type=date]' ).on( 'input', function() {
935
		$( this ).valid();
1010
		$( this ).valid();
936
	});
1011
	});
937
 
-
 
938
	// Validation Taxon si pas de miniature
1012
	// Validation Taxon si pas de miniature
939
	$( '#taxon' ).on( 'change', function() {
1013
	$( '#taxon' ).on( 'change', function() {
940
		var images = valeurOk( $( '#miniatures .miniature' ) );
1014
		var images = valeurOk( $( '#miniatures .miniature' ) );
941
		lthis.validerTaxonImage( valeurOk( $( this ).val() ), images );
1015
		lthis.validerTaxonImage( valeurOk( $( this ).val() ), images );
942
	});
1016
	});
943
 
-
 
944
	// Validation miniatures avec MutationObserver
1017
	// Validation miniatures avec MutationObserver
945
	this.surPresenceAbsenceMiniature();
1018
	this.surPresenceAbsenceMiniature();
946
 
-
 
947
	$( '#form-observation' ).validate({
1019
	$( '#form-observation' ).validate({
948
		rules : {
1020
		rules : {
949
			date_releve : {
1021
			date_releve : {
950
				required : true,
1022
				required : true,
951
				'dateCel' : true
1023
				'dateCel' : true
Line 960... Line 1032...
960
				minlength : 1,
1032
				minlength : 1,
961
				range : [-180, 180]
1033
				range : [-180, 180]
962
			}
1034
			}
963
		}
1035
		}
964
	});
1036
	});
965
 
-
 
966
	$( '#form-observateur' ).validate({
1037
	$( '#form-observateur' ).validate({
967
		rules : {
1038
		rules : {
968
			courriel : {
1039
			courriel : {
969
				required : true,
1040
				required : true,
970
				email : true,
1041
				email : true,
Line 974... Line 1045...
974
				required : true,
1045
				required : true,
975
				equalTo : '#courriel'
1046
				equalTo : '#courriel'
976
			}
1047
			}
977
		}
1048
		}
978
	});
1049
	});
979
 
-
 
980
	$( '#connexion,#bouton-inscription,#bouton-anonyme' ).click( function( event ) {
1050
	$( '#connexion,#bouton-inscription,#bouton-anonyme' ).click( function( event ) {
981
		$( '.nav.control-group' ).removeClass( 'error' );
1051
		$( '.nav.control-group' ).removeClass( 'error' );
982
	});
1052
	});
983
};
1053
};
Line 999... Line 1069...
999
	}
1069
	}
1000
	return ( images || taxon );
1070
	return ( images || taxon );
1001
};
1071
};
Line 1002... Line 1072...
1002
 
1072
 
1003
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
1073
WidgetSaisie.prototype.surPresenceAbsenceMiniature = function() {
Line 1004... Line 1074...
1004
	var lthis = this;
1074
	const lthis = this;
1005
 
1075
 
1006
	// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
1076
	// voir : https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/disconnect
1007
	// Selectionne le noeud dont les mutations seront observées
1077
	// Selectionne le noeud dont les mutations seront observées
1008
	var targetNode = document.getElementById( 'miniatures' );
1078
	var targetNode = document.getElementById( 'miniatures' );
1009
	// Fonction callback à éxécuter quand une mutation est observée
1079
	// Fonction callback à éxécuter quand une mutation est observée
1010
	var callback = function( mutationsList ) {
1080
	var callback = function( mutationsList ) {
-
 
1081
		for( var mutation of mutationsList ) {
1011
		for( var mutation of mutationsList ) {
1082
			var taxon = valeurOk( $( '#taxon' ).val() );
1012
			var taxon = valeurOk( $( '#taxon' ).val() );
1083
 
1013
			images = ( 0 < mutation.target.childElementCount );
1084
			images = ( 0 < mutation.target.childElementCount );
1014
			lthis.validerTaxonImage( taxon, images );
1085
			lthis.validerTaxonImage( taxon, images );
1015
		}
1086
		}
Line 1060... Line 1131...
1060
		$( '.nav.control-group' ).removeClass( 'error' );
1131
		$( '.nav.control-group' ).removeClass( 'error' );
1061
	} else {
1132
	} else {
1062
		this.afficherPanneau( '#dialogue-utilisateur-non-identifie' );
1133
		this.afficherPanneau( '#dialogue-utilisateur-non-identifie' );
1063
		$( '.nav.control-group' ).addClass( 'error' );
1134
		$( '.nav.control-group' ).addClass( 'error' );
1064
	}
1135
	}
1065
 
-
 
1066
	return ( observateur && obs && geoloc && taxonOuImage && chpsSupp );
1136
	return ( observateur && obs && geoloc && taxonOuImage && chpsSupp );
1067
};
1137
};
Line 1068... Line 1138...
1068
 
1138
 
1069
// Fichier Images *************************************************************/
1139
// Fichier Images *************************************************************/
Line 1073... Line 1143...
1073
WidgetSaisie.prototype.afficherMiniature = function( reponse ) {
1143
WidgetSaisie.prototype.afficherMiniature = function( reponse ) {
1074
	if ( this.debug ) {
1144
	if ( this.debug ) {
1075
		var debogage = $( 'debogage', reponse ).text();
1145
		var debogage = $( 'debogage', reponse ).text();
1076
		//console.log( 'Débogage upload : '+debogage);
1146
		//console.log( 'Débogage upload : '+debogage);
1077
	}
1147
	}
-
 
1148
 
1078
	var message = $( 'message', reponse ).text();
1149
	var message = $( 'message', reponse ).text();
-
 
1150
 
1079
	if ( valeurOk( message ) ) {
1151
	if ( valeurOk( message ) ) {
1080
		$( '#miniature-msg' ).append( message );
1152
		$( '#miniature-msg' ).append( message );
1081
	} else {
1153
	} else {
1082
		$( '#miniatures' ).append( this.creerWidgetMiniature( reponse ) );
1154
		$( '#miniatures' ).append( this.creerWidgetMiniature( reponse ) );
1083
	}
1155
	}
Line 1087... Line 1159...
1087
/**
1159
/**
1088
 * Crée la miniature d'une image temporaire (formulaire), avec le bouton pour l'effacer
1160
 * Crée la miniature d'une image temporaire (formulaire), avec le bouton pour l'effacer
1089
 */
1161
 */
1090
WidgetSaisie.prototype.creerWidgetMiniature = function( reponse ) {
1162
WidgetSaisie.prototype.creerWidgetMiniature = function( reponse ) {
1091
	var miniatureUrl = $( 'miniature-url', reponse ).text();
1163
	var miniatureUrl = $( 'miniature-url', reponse ).text();
1092
	var imgNom = $( 'image-nom', reponse ).text();
1164
	var imgNom       = $( 'image-nom', reponse ).text();
1093
	var html =
1165
	var html         =
1094
		'<div class="miniature mb-3 mr-3">'+
1166
		'<div class="miniature mb-3 mr-3">'+
1095
			'<img class="miniature-img" class="miniature img-rounded" alt="' + imgNom + '" src="' + miniatureUrl + '"/>'+
1167
			'<img class="miniature-img" class="miniature img-rounded" alt="' + imgNom + '" src="' + miniatureUrl + '"/>'+
1096
			'<a class="effacer-miniature"><i class="far fa-trash-alt"></i></a>'+
1168
			'<a class="effacer-miniature"><i class="far fa-trash-alt"></i></a>'+
1097
		'</div>';
1169
		'</div>';
-
 
1170
 
1098
	return html;
1171
	return html;
1099
};
1172
};
Line 1100... Line 1173...
1100
 
1173
 
1101
/**
1174
/**
1102
 * Retourne true si l'extension de l'image 'nom' est .jpg ou .jpeg
1175
 * Retourne true si l'extension de l'image 'nom' est .jpg ou .jpeg
1103
 */
1176
 */
1104
WidgetSaisie.prototype.verifierFormat = function( nom ) {
1177
WidgetSaisie.prototype.verifierFormat = function( nom ) {
-
 
1178
	var parts = nom.split( '.' );
1105
	var parts = nom.split( '.' );
1179
 
1106
	extension = parts[ parts.length - 1 ];
1180
	extension = parts[ parts.length - 1 ];
1107
	return ( 'jpeg' === extension.toLowerCase() || 'jpg' === extension.toLowerCase() );
1181
	return ( 'jpeg' === extension.toLowerCase() || 'jpg' === extension.toLowerCase() );
Line 1108... Line 1182...
1108
};
1182
};
-
 
1183
 
-
 
1184
/**
-
 
1185
 * Check les miniatures déjà téléchargées
-
 
1186
 * renvoie false si le même nom est rencontré 2 fois
-
 
1187
 * renvoie true sinon
-
 
1188
 */
-
 
1189
WidgetSaisie.prototype.verifierDuplication = function( cheminTmp ) {
-
 
1190
	var parts        = cheminTmp.split( '\\' ),
-
 
1191
		nomImage     = parts[ parts.length - 1 ],
-
 
1192
		thisSrcParts = [],
-
 
1193
		thisNomImage = '',
-
 
1194
		nonDupliquee = true;
-
 
1195
 
-
 
1196
	$( 'img.miniature-img,img.miniature' ).each( function() {
-
 
1197
		// vérification avec alt de l'image
-
 
1198
		if ( valeurOk( $( this ).attr ( 'alt' ), true, nomImage ) ) {
-
 
1199
			nonDupliquee = false;
-
 
1200
			return false;// Pas besoin de poursuivre la boucle
-
 
1201
		} else { // sinon vérifie aussi avec l'adresse (src) de l'image
-
 
1202
			thisSrcParts = $( this ).attr( 'src' ).split( '/' );
-
 
1203
			thisNomImage = thisSrcParts[ thisSrcParts.length - 1 ].replace( '_min', '' );
-
 
1204
			if ( valeurOk( thisNomImage, true, nomImage ) ) {
-
 
1205
				nonDupliquee = false;
-
 
1206
				return false;
-
 
1207
			}
-
 
1208
		}
-
 
1209
	});
-
 
1210
	return nonDupliquee;
-
 
1211
};
1109
 
1212
 
1110
/**
1213
/**
1111
 * Efface une miniature (formulaire)
1214
 * Efface une miniature (formulaire)
1112
 */
1215
 */
1113
WidgetSaisie.prototype.supprimerMiniature = function( miniature ) {
1216
WidgetSaisie.prototype.supprimerMiniature = function( miniature ) {
Line 1119... Line 1222...
1119
WidgetSaisie.prototype.surChangementReferentiel = function() {
1222
WidgetSaisie.prototype.surChangementReferentiel = function() {
1120
	this.nomSciReferentiel = $( '#referentiel' ).val();
1223
	this.nomSciReferentiel = $( '#referentiel' ).val();
1121
	//réinitialise taxon.val
1224
	//réinitialise taxon.val
1122
	$( '#taxon' ).val( '' );
1225
	$( '#taxon' ).val( '' );
1123
	$( '#taxon' ).data( 'numNomSel', '' );
1226
	$( '#taxon' ).data( 'numNomSel', '' );
1124
	// this.initialiserAutocompleteCommune();
-
 
1125
	// this.initialiserGoogleMap( false );
-
 
1126
};
1227
};
Line 1127... Line 1228...
1127
 
1228
 
1128
// Ajouter Obs ****************************************************************/
1229
// Ajouter Obs ****************************************************************/
1129
/**
1230
/**
Line 1132... Line 1233...
1132
WidgetSaisie.prototype.ajouterObs = function() {
1233
WidgetSaisie.prototype.ajouterObs = function() {
1133
	// Fermeture automatique des dialogue de transmission de données
1234
	// Fermeture automatique des dialogue de transmission de données
1134
	// @WARNING TEST
1235
	// @WARNING TEST
1135
	$( '#dialogue-obs-transaction-ko' ).addClass( 'hidden' );
1236
	$( '#dialogue-obs-transaction-ko' ).addClass( 'hidden' );
1136
	$( '#dialogue-obs-transaction-ok' ).addClass( 'hidden' );
1237
	$( '#dialogue-obs-transaction-ok' ).addClass( 'hidden' );
1137
 
-
 
1138
	if ( this.validerFormulaire() ) {
1238
	if ( this.validerFormulaire() ) {
1139
		this.masquerPanneau( '#dialogue-form-invalide' );
1239
		this.masquerPanneau( '#dialogue-form-invalide' );
1140
		this.obsNbre = this.obsNbre + 1;
1240
		this.obsNbre = this.obsNbre + 1;
1141
		$( '.obs-nbre' ).text( this.obsNbre );
1241
		$( '.obs-nbre' ).text( this.obsNbre );
1142
		$( '.obs-nbre' ).triggerHandler( 'changement' );
1242
		$( '.obs-nbre' ).triggerHandler( 'changement' );
Line 1175... Line 1275...
1175
 
1275
 
1176
/**
1276
/**
1177
 * Affiche une observation dans la liste des observations à transmettre
1277
 * Affiche une observation dans la liste des observations à transmettre
1178
 */
1278
 */
1179
WidgetSaisie.prototype.afficherObs = function() {
-
 
1180
 
1279
WidgetSaisie.prototype.afficherObs = function() {
1181
	var numNomSel = $( '#taxon' ).data( 'numNomSel' ),
1280
	var numNomSel = $( '#taxon' ).data( 'numNomSel' ),
1182
			taxon = $( '#taxon' ).val(),
1281
		taxon = $( '#taxon' ).val(),
1183
			referentiel = '',
1282
		referentiel = '',
1184
			commune = '',
1283
		commune = '',
1185
			inseeLatitudeLongitude = '',
1284
		inseeLatitudeLongitude = '',
1186
			lieudit = '',
1285
		lieudit = '',
1187
			station = '',
1286
		station = '',
1188
			milieu = '',
1287
		milieu = '',
Line 1189... Line 1288...
1189
			commentaires = '';
1288
		commentaires = '';
1190
 
1289
 
1191
	if ( valeurOk( numNomSel ) ) {
1290
	if ( valeurOk( numNomSel ) ) {
1192
		referentiel = '<span class="referentiel-obs">' + '[' + this.nomSciReferentiel + ']' + '</span>';
1291
		referentiel = '<span class="referentiel-obs">' + '[' + this.nomSciReferentiel + ']' + '</span>';
Line 1205... Line 1304...
1205
	}
1304
	}
1206
	if ( valeurOk( $( '#milieu' ).val() ) ) {
1305
	if ( valeurOk( $( '#milieu' ).val() ) ) {
1207
		milieu = '<span>' + this.msgTraduction( 'milieu' ) + ' :</span> ' + $( '#milieu' ).val() + ' ';
1306
		milieu = '<span>' + this.msgTraduction( 'milieu' ) + ' :</span> ' + $( '#milieu' ).val() + ' ';
1208
	}
1307
	}
1209
	if ( valeurOk( $( '#notes' ).val() ) ) {
1308
	if ( valeurOk( $( '#notes' ).val() ) ) {
1210
		commentaires = this.msgTraduction( 'commentaires' ) + ' : <span class="discretion">' + $( '#notes' ).val() + '</span>' + ' ';
1309
		commentaires = this.msgTraduction( 'commentaires' ) + ' : <span>' + $( '#notes' ).val() + '</span>' + ' ';
1211
	}
1310
	}
Line 1212... Line 1311...
1212
 
1311
 
1213
	var responsivDiff1 = '',
1312
	var responsivDiff1 = '',
1214
			responsivDiff2 = '',
1313
		responsivDiff2 = '',
1215
			responsivDiff3 = '',
1314
		responsivDiff3 = '',
1216
			responsivDiff4 = '',
1315
		responsivDiff4 = '',
1217
			responsivDiff5 = '',
1316
		responsivDiff5 = '',
1218
			responsivDiff6 = '';
1317
		responsivDiff6 = '';
1219
	if ( window.matchMedia( '(min-width: 576px)' ).matches ) {
1318
	if ( window.matchMedia( '(min-width: 576px)' ).matches ) {
1220
		/* La largeur minimum de l'affichage est 600 px inclus */
1319
		/* La largeur minimum de l'affichage est 600 px inclus */
1221
		responsivDiff1 = ' droite';
1320
		responsivDiff1 = ' droite';
1222
		responsivDiff2 = '<div></div>';
1321
		responsivDiff2 = '<div></div>';
Line 1281... Line 1380...
1281
				'<div class="defilement-miniatures">'+
1380
				'<div class="defilement-miniatures">'+
1282
					'<figure class="centre">'+
1381
					'<figure class="centre">'+
1283
						'<img class="miniature align-middle" alt="Aucune photo" src="' + this.pasDePhotoIconeUrl + '" width="80%" />'+
1382
						'<img class="miniature align-middle" alt="Aucune photo" src="' + this.pasDePhotoIconeUrl + '" width="80%" />'+
1284
					'</figure>'+
1383
					'</figure>'+
1285
				'</div>',
1384
				'</div>',
1286
			miniatures   = '',
1385
		miniatures   = '',
1287
			premiere     = true,
1386
		premiere     = true,
1288
			centre       = '';
1387
		centre       = '';
1289
			defilVisible = '';
1388
		defilVisible = '';
Line 1290... Line 1389...
1290
 
1389
 
1291
	if ( valeurOk( $( '#miniatures img' ) ) ) {
1390
	if ( valeurOk( $( '#miniatures img' ) ) ) {
-
 
1391
		$( '#miniatures img' ).each( function() {
1292
		$( '#miniatures img' ).each( function() {
1392
 
-
 
1393
			var imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee',
-
 
1394
				css        = ( $( this ).hasClass( 'b64' ) ) ? 'miniature b64' : 'miniature',
-
 
1395
				src        = $( this ).attr( 'src' ),
-
 
1396
				alt        = $( this ).attr( 'alt' ),
-
 
1397
				miniature  = '<img class="' + css + ' ' + imgVisible + ' align-middle"  alt="' + alt + '"src="' + src + '" width="80%" />';
1293
			var imgVisible = ( premiere ) ? 'miniature-selectionnee' : 'miniature-cachee';
1398
 
Line 1294... Line -...
1294
			premiere = false;
-
 
1295
 
-
 
1296
			var css        = ( $( this ).hasClass( 'b64' ) ) ? 'miniature b64' : 'miniature',
-
 
1297
					src        = $( this ).attr( 'src' ),
-
 
Line 1298... Line 1399...
1298
					alt        = $( this ).attr( 'alt' ),
1399
			premiere = false;
1299
					miniature  = '<img class="' + css + ' ' + imgVisible + ' align-middle"  alt="' + alt + '"src="' + src + '" width="80%" />';
1400
 
1300
 
1401
 
1301
			miniatures += miniature;
1402
			miniatures += miniature;
1302
		});
1403
		});
1303
		if ( 1 === $( '#miniatures img' ).length ) {
1404
		if ( 1 === $( '#miniatures img' ).length ) {
1304
			centre       = 'centre';
1405
			centre = 'centre';
1305
			defilVisible = ' defilement-miniatures-cache';
1406
			defilVisible = ' defilement-miniatures-cache';
1306
		}
1407
		}
1307
		html             =
1408
		html =
1308
			'<div class="defilement-miniatures">'+
1409
			'<div class="defilement-miniatures">'+
1309
				'<a href="#" class="defilement-miniatures-gauche mr-1' + defilVisible + '"><i class="fas fa-chevron-circle-left"></i></a>'+
1410
				'<a href="#" class="defilement-miniatures-gauche mr-1' + defilVisible + '"><i class="fas fa-chevron-circle-left"></i></a>'+
Line 1335... Line 1436...
1335
	return nn;
1436
	return nn;
1336
};
1437
};
Line 1337... Line 1438...
1337
 
1438
 
1338
 
1439
 
Line 1339... Line 1440...
1339
WidgetSaisie.prototype.stockerObsData = function() {
1440
WidgetSaisie.prototype.stockerObsData = function() {
1340
	var lthis = this;
1441
	const lthis = this;
1341
 
1442
 
1342
	var numNomSel   = $( '#taxon' ).data( 'numNomSel' ),
1443
	var numNomSel   = $( '#taxon' ).data( 'numNomSel' ),
1343
			nomSel      = $( '#taxon' ).val(),
1444
		nomSel      = $( '#taxon' ).val(),
1344
			nomRet      = $( '#taxon' ).data( 'nomRet' ),
1445
		nomRet      = $( '#taxon' ).data( 'nomRet' ),
1345
			numNomRet   = $( '#taxon' ).data( 'numNomRet' ),
1446
		numNomRet   = $( '#taxon' ).data( 'numNomRet' ),
Line 1346... Line 1447...
1346
			numTaxon    = $( '#taxon' ).data( 'nt' ),
1447
		numTaxon    = $( '#taxon' ).data( 'nt' ),
1347
			famille     = $( '#taxon' ).data( 'famille' ),
1448
		famille     = $( '#taxon' ).data( 'famille' ),
1348
			referentiel = ( !valeurOk( numNomSel ) ) ? 'autre' : this.nomSciReferentiel;
1449
		referentiel = ( !valeurOk( numNomSel ) ) ? 'autre' : this.nomSciReferentiel;
1349
 
1450
 
Line 1362... Line 1463...
1362
		'commune_nom'        : $( '#commune-nom' ).val(),
1463
		'commune_nom'        : $( '#commune-nom' ).val(),
1363
		'commune_code_insee' : $( '#commune-insee' ).val(),
1464
		'commune_code_insee' : $( '#commune-insee' ).val(),
1364
		'latitude'           : $( '#latitude' ).val(),
1465
		'latitude'           : $( '#latitude' ).val(),
1365
		'longitude'          : $( '#longitude' ).val(),
1466
		'longitude'          : $( '#longitude' ).val(),
1366
		'altitude'           : $( '#altitude' ).val(),
1467
		'altitude'           : $( '#altitude' ).val(),
1367
// début valeurs pour test:
-
 
1368
		// 'commune_nom'        : 'Montpellier',
-
 
1369
		// 'commune_code_insee' : '34172',
-
 
1370
		// 'latitude'           : '43.608320',
-
 
1371
		// 'longitude'          : '3.880196',
-
 
1372
		// 'altitude'           : '0',
-
 
1373
//fin valeurs pour test
-
 
1374
		'lieudit'            : $( '#lieudit' ).val(),
1468
		'lieudit'            : $( '#lieudit' ).val(),
1375
		'station'            : $( '#station' ).val(),
1469
		'station'            : $( '#station' ).val(),
1376
		'milieu'             : $( '#milieu' ).val(),
1470
		'milieu'             : $( '#milieu' ).val(),
1377
		//Ajout des champs images
1471
		//Ajout des champs images
1378
		'image_nom'          : lthis.getNomsImgsOriginales(),
1472
		'image_nom'          : lthis.getNomsImgsOriginales(),
Line 1382... Line 1476...
1382
	});
1476
	});
1383
};
1477
};
Line 1384... Line 1478...
1384
 
1478
 
1385
WidgetSaisie.prototype.getNomsImgsOriginales = function() {
1479
WidgetSaisie.prototype.getNomsImgsOriginales = function() {
-
 
1480
	var noms = new Array();
1386
	var noms = new Array();
1481
 
1387
	$( '.miniature-img' ).each( function() {
1482
	$( '.miniature-img' ).each( function() {
1388
		noms.push( $( this ).attr( 'alt' ) );
1483
		noms.push( $( this ).attr( 'alt' ) );
1389
	});
1484
	});
1390
	return noms;
1485
	return noms;
Line 1391... Line 1486...
1391
};
1486
};
1392
 
1487
 
-
 
1488
WidgetSaisie.prototype.getB64ImgsOriginales = function() {
1393
WidgetSaisie.prototype.getB64ImgsOriginales = function() {
1489
	var b64 = new Array();
1394
	var b64 = new Array();
1490
 
1395
	$( '.miniature-img' ).each( function() {
1491
	$( '.miniature-img' ).each( function() {
1396
		if ( $( this ).hasClass( 'b64' ) ) {
1492
		if ( $( this ).hasClass( 'b64' ) ) {
1397
			b64.push( $( this ).attr( 'src' ) );
1493
			b64.push( $( this ).attr( 'src' ) );
Line 1405... Line 1501...
1405
/**
1501
/**
1406
 * Retourne un Array contenant les valeurs des champs étendus
1502
 * Retourne un Array contenant les valeurs des champs étendus
1407
 */
1503
 */
1408
WidgetSaisie.prototype.getObsChpEtendus = function() {
1504
WidgetSaisie.prototype.getObsChpEtendus = function() {
1409
	var champs    = new Array(),
1505
	var champs    = new Array(),
1410
			$thisForm = $( '#form-supp' ),
1506
		$thisForm = $( '#form-supp' ),
1411
			elements  =
1507
		elements  =
1412
				'input[type=text]:not(.collect-other),'+
1508
			'input[type=text]:not(.collect-other),'+
1413
				'input[type=checkbox]:checked,'+
1509
			'input[type=checkbox]:checked,'+
1414
				'input[type=radio]:checked,'+
1510
			'input[type=radio]:checked,'+
1415
				'input[type=email],'+
1511
			'input[type=email],'+
1416
				'input[type=number],'+
1512
			'input[type=number],'+
1417
				'input[type=range],'+
1513
			'input[type=range],'+
1418
				'input[type=date],'+
1514
			'input[type=date],'+
1419
				'textarea,'+
1515
			'textarea,'+
1420
				'.select',
1516
			'.select',
1421
			retour    = new Array();
1517
		retour    = new Array();
Line 1422... Line 1518...
1422
 
1518
 
1423
	$( elements, $thisForm ).each( function() {
1519
	$( elements, $thisForm ).each( function() {
1424
		if ( valeurOk( $( this ).val() ) && ( valeurOk( $( this ).attr( 'name' ) ) || valeurOk( $( this ).data( 'name' ) ) ) ) {
1520
		if ( valeurOk( $( this ).val() ) && ( valeurOk( $( this ).attr( 'name' ) ) || valeurOk( $( this ).data( 'name' ) ) ) ) {
1425
			var valeur = $( this ).val(),
1521
			var valeur = $( this ).val(),
1426
					cle    = ( valeurOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' );
1522
				cle    = ( valeurOk( $( this ).attr( 'name' ) ) ) ? $( this ).attr( 'name' ) : $( this ).data( 'name' );
1427
			if ( cle in champs ) {
1523
			if ( cle in champs ) {
1428
				champs[cle] += ';' + valeur;
1524
				champs[cle] += ';' + valeur;
1429
			} else {
1525
			} else {
1430
				champs[cle] = valeur;
1526
				champs[cle] = valeur;
1431
			}
1527
			}
1432
		}
1528
		}
1433
	});
1529
	});
1434
	for( var key in champs ) {
1530
	for ( var key in champs ) {
-
 
1531
		retour.push({ 'cle' : key , 'valeur' : champs[key] });
-
 
1532
	}
-
 
1533
	if ( valeurOk( $( '#coord-lineaire' ).val() ) ) {
1435
		retour.push({ 'cle' : key , 'valeur' : champs[key] });
1534
		retour.push({ 'cle' : 'coordonnees-rue-ou-lineaire' , 'valeur' : $( '#coord-lineaire' ).val() });
1436
	};
1535
	}
1437
	return retour;
1536
	return retour;
Line 1438... Line 1537...
1438
};
1537
};
1439
 
1538
 
Line 1461... Line 1560...
1461
		this.afficherPanneau( '#dialogue-bloquer-creer-obs' );
1560
		this.afficherPanneau( '#dialogue-bloquer-creer-obs' );
1462
	}
1561
	}
1463
};
1562
};
Line 1464... Line 1563...
1464
 
1563
 
1465
WidgetSaisie.prototype.defilerMiniatures = function( element ) {
-
 
1466
 
1564
WidgetSaisie.prototype.defilerMiniatures = function( element ) {
-
 
1565
	var miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' );
1467
	var miniatureSelectionne = element.siblings( 'figure' ).find( 'img.miniature-selectionnee' );
1566
 
1468
	miniatureSelectionne.removeClass( 'miniature-selectionnee' );
1567
	miniatureSelectionne.removeClass( 'miniature-selectionnee' );
Line 1469... Line 1568...
1469
	miniatureSelectionne.addClass( 'miniature-cachee' );
1568
	miniatureSelectionne.addClass( 'miniature-cachee' );
Line 1487... Line 1586...
1487
	miniatureAffichee.removeClass( 'miniature-cachee' );
1586
	miniatureAffichee.removeClass( 'miniature-cachee' );
1488
};
1587
};
Line 1489... Line 1588...
1489
 
1588
 
1490
WidgetSaisie.prototype.supprimerObs = function( selector ) {
1589
WidgetSaisie.prototype.supprimerObs = function( selector ) {
-
 
1590
	var obsId = $( selector ).val();
1491
	var obsId = $( selector ).val();
1591
 
1492
	// Problème avec IE 6 et 7
1592
	// Problème avec IE 6 et 7
1493
	if ( 'Supprimer' === obsId ) {
1593
	if ( 'Supprimer' === obsId ) {
1494
		obsId = $( selector ).attr( 'title' );
1594
		obsId = $( selector ).attr( 'title' );
1495
	}
1595
	}
Line 1499... Line 1599...
1499
WidgetSaisie.prototype.supprimerObsParId = function( obsId ) {
1599
WidgetSaisie.prototype.supprimerObsParId = function( obsId ) {
1500
	this.obsNbre = this.obsNbre - 1;
1600
	this.obsNbre = this.obsNbre - 1;
1501
	$( '.obs-nbre' ).text( this.obsNbre );
1601
	$( '.obs-nbre' ).text( this.obsNbre );
1502
	$( '.obs-nbre' ).triggerHandler( 'changement' );
1602
	$( '.obs-nbre' ).triggerHandler( 'changement' );
1503
	$( '.obs' + obsId ).remove();
1603
	$( '.obs' + obsId ).remove();
-
 
1604
	obsId = parseInt( obsId );
-
 
1605
 
-
 
1606
	var listObsData = $( '#liste-obs' ).data(),
-
 
1607
		exId        = 0,
-
 
1608
		indexObs    = '',
-
 
1609
		exIndexObs  = '';
-
 
1610
 
-
 
1611
	for ( var id = obsId; id <= ( this.obsNbre + 1 ); id++ ) {
-
 
1612
		exId       = parseInt( id ) + 1;
-
 
1613
		indexObs   = 'obsId' + id;
-
 
1614
		exIndexObs = 'obsId' + exId;
1504
	$( '#liste-obs' ).removeData( 'obsId' + obsId );
1615
		$( '#liste-obs' ).removeData( indexObs );
-
 
1616
		if ( valeurOk( listObsData[ exIndexObs ] ) ) {
-
 
1617
			$( '#liste-obs' ).data( indexObs, listObsData[ exIndexObs ] );
-
 
1618
		}
-
 
1619
		$( '#obs' + exId )
-
 
1620
			.attr( 'id', 'obs' + id )
-
 
1621
			.removeClass( 'obs' + exId )
-
 
1622
			.addClass( 'obs' + id )
-
 
1623
			.find( '.supprimer-obs' )
-
 
1624
				.attr( 'title', 'Observation n°' + id )
-
 
1625
				.val( id );
-
 
1626
		if ( parseInt( id ) !== this.obsNbre ) {
-
 
1627
			id = parseInt( id );
-
 
1628
		}
-
 
1629
	}
1505
};
1630
};
Line 1506... Line 1631...
1506
 
1631
 
1507
WidgetSaisie.prototype.transmettreObs = function() {
1632
WidgetSaisie.prototype.transmettreObs = function() {
-
 
1633
	var observations = $( '#liste-obs' ).data();
1508
	var observations = $( '#liste-obs' ).data();
1634
 
1509
	if ( this.debug ) {
1635
	if ( this.debug ) {
1510
		console.log( observations );
1636
		console.log( observations );
1511
	}
1637
	}
1512
	if ( !valeurOk( typeof observations, true, 'object' ) ) {
1638
	if ( !valeurOk( typeof observations, true, 'object' ) ) {
Line 1522... Line 1648...
1522
	return false;
1648
	return false;
1523
};
1649
};
Line 1524... Line 1650...
1524
 
1650
 
1525
WidgetSaisie.prototype.depilerObsPourEnvoi = function() {
1651
WidgetSaisie.prototype.depilerObsPourEnvoi = function() {
-
 
1652
	var observations = $( '#liste-obs' ).data();
1526
	var observations = $( '#liste-obs' ).data();
1653
 
1527
	// la boucle est factice car on utilise un tableau
1654
	// la boucle est factice car on utilise un tableau
1528
	// dont on a besoin de n'extraire que le premier élément
1655
	// dont on a besoin de n'extraire que le premier élément
1529
	// or javascript n'a pas de méthode cross browsers pour extraire les clés
1656
	// or javascript n'a pas de méthode cross browsers pour extraire les clés
1530
	// TODO: utiliser var.keys quand ça sera plus répandu
1657
	// TODO: utiliser var.keys quand ça sera plus répandu
Line 1533... Line 1660...
1533
		var obsATransmettre = {
1660
		var obsATransmettre = {
1534
			'projet'  : this.tagProjet,
1661
			'projet'  : this.tagProjet,
1535
			'tag-obs' : this.tagObs,
1662
			'tag-obs' : this.tagObs,
1536
			'tag-img' : this.tagImg
1663
			'tag-img' : this.tagImg
1537
		};
1664
		};
1538
		var utilisateur = {
1665
		var utilisateur     = {
1539
			id_utilisateur : $( '#id_utilisateur' ).val(),
1666
			id_utilisateur : $( '#id_utilisateur' ).val(),
1540
			prenom         : $( '#prenom' ).val(),
1667
			prenom         : $( '#prenom' ).val(),
1541
			nom            : $( '#nom' ).val(),
1668
			nom            : $( '#nom' ).val(),
1542
			courriel       : $( '#courriel' ).val()
1669
			courriel       : $( '#courriel' ).val()
1543
		};
1670
		};
-
 
1671
 
1544
		obsATransmettre['utilisateur'] = utilisateur;
1672
		obsATransmettre['utilisateur'] = utilisateur;
1545
		obsATransmettre[obsNum] = observations[obsNum];
1673
		obsATransmettre[obsNum] = observations[obsNum];
-
 
1674
 
1546
		var idObsNumerique = obsNum.replace( 'obsId', '' );
1675
		var idObsNumerique = obsNum.replace( 'obsId', '' );
-
 
1676
 
1547
		if( '' !== idObsNumerique ) {
1677
		if( '' !== idObsNumerique ) {
1548
			this.envoyerObsAuCel( idObsNumerique, obsATransmettre );
1678
			this.envoyerObsAuCel( idObsNumerique, obsATransmettre );
1549
		}
1679
		}
1550
		break;
1680
		break;
1551
	}
1681
	}
1552
};
1682
};
Line 1553... Line 1683...
1553
 
1683
 
1554
WidgetSaisie.prototype.envoyerObsAuCel = function( idObs, observation ) {
1684
WidgetSaisie.prototype.envoyerObsAuCel = function( idObs, observation ) {
Line 1555... Line 1685...
1555
	var lthis = this;
1685
	const lthis = this;
-
 
1686
 
1556
 
1687
	var erreurMsg = '';
1557
	var erreurMsg = '';
1688
 
1558
	$.ajax({
1689
	$.ajax({
1559
		url        : lthis.serviceSaisieUrl,
1690
		url        : lthis.serviceSaisieUrl,
1560
		type       : 'POST',
1691
		type       : 'POST',
Line 1604... Line 1735...
1604
			if ( '' !== erreurMsg ) {
1735
			if ( '' !== erreurMsg ) {
1605
				if ( lthis.debug ) {
1736
				if ( lthis.debug ) {
1606
					$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-erreur">' + erreurMsg + '</pre>' );
1737
					$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-erreur">' + erreurMsg + '</pre>' );
1607
					$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-debug">Débogage : ' + debugMsg + '</pre>' );
1738
					$( '#dialogue-obs-transaction-ko .alert-txt' ).append( '<pre class="msg-debug">Débogage : ' + debugMsg + '</pre>' );
1608
				}
1739
				}
-
 
1740
 
1609
				var hrefCourriel = 'mailto:cel_remarques@tela-botanica.org?'+
1741
				var hrefCourriel = 'mailto:cel_remarques@tela-botanica.org?'+
1610
					'subject=Dysfonctionnement du widget de saisie ' + lthis.tagProjet+
1742
					'subject=Dysfonctionnement du widget de saisie ' + lthis.tagProjet+
1611
					'&body=' + erreurMsg + '%0D%0ADébogage :%0D%0A' + debugMsg;
1743
					'&body=' + erreurMsg + '%0D%0ADébogage :%0D%0A' + debugMsg;
Line 1612... Line -...
1612
 
-
 
1613
				// mise en valeur de l'obs en erreur + scroll vers celle ci en changeant le hash
1744
 
1614
				$( '#obs' + idObs + ' div div' ).addClass( 'obs-erreur' );
-
 
1615
				window.location.hash = 'obs' + idObs;
-
 
1616
 
1745
				$( '#obs' + idObs + ' div div' ).addClass( 'obs-erreur' );
1617
				$( '#dialogue-obs-transaction-ko .alert-txt' ).append(
1746
				$( '#dialogue-obs-transaction-ko .alert-txt' ).append(
1618
					$( '#tpl-transmission-ko' ).clone()
1747
					$( '#tpl-transmission-ko' ).clone()
1619
						.find( '.courriel-erreur' )
1748
						.find( '.courriel-erreur' )
1620
						.attr( 'href', hrefCourriel )
1749
						.attr( 'href', hrefCourriel )
Line 1631... Line 1760...
1631
				if( 0 === lthis.obsNbre ) {
1760
				if( 0 === lthis.obsNbre ) {
1632
					setTimeout( function() {
1761
					setTimeout( function() {
1633
						$( '#chargement' ).addClass( 'hidden' );
1762
						$( '#chargement' ).addClass( 'hidden' );
1634
						$( '#dialogue-obs-transaction-ok .alert-txt' ).append( $( '#tpl-transmission-ok' ).clone().html() );
1763
						$( '#dialogue-obs-transaction-ok .alert-txt' ).append( $( '#tpl-transmission-ok' ).clone().html() );
1635
						$( '#dialogue-obs-transaction-ok' ).removeClass( 'hidden' );
1764
						$( '#dialogue-obs-transaction-ok' ).removeClass( 'hidden' );
1636
						window.location.hash = 'dialogue-obs-transaction-ok';
-
 
1637
						lthis.initialiserObs.bind( lthis );
1765
						lthis.initialiserObs.bind( lthis );
1638
					}, 1500 );
1766
					}, 1500 );
1639
				}
1767
				}
1640
			}
1768
			}
1641
		}
1769
		}
Line 1700... Line 1828...
1700
 * langue en cours. S'il n'est pas trouvé, retourne la version française (par
1828
 * langue en cours. S'il n'est pas trouvé, retourne la version française (par
1701
 * défaut); si celle-ci n'exite pas, retourne "N/A".
1829
 * défaut); si celle-ci n'exite pas, retourne "N/A".
1702
 */
1830
 */
1703
WidgetSaisie.prototype.msgTraduction = function( cle ) {
1831
WidgetSaisie.prototype.msgTraduction = function( cle ) {
1704
	var msg = 'N/A';
1832
	var msg = 'N/A';
-
 
1833
 
1705
	if ( this.msgs ) {
1834
	if ( this.msgs ) {
1706
		if ( this.langue in this.msgs && cle in this.msgs[this.langue] ) {
1835
		if ( this.langue in this.msgs && cle in this.msgs[this.langue] ) {
1707
			msg = this.msgs[this.langue][cle];
1836
			msg = this.msgs[this.langue][cle];
1708
		} else if ( cle in this.msgs['fr'] ) {
1837
		} else if ( cle in this.msgs['fr'] ) {
1709
			msg = this.msgs['fr'][cle];
1838
			msg = this.msgs['fr'][cle];
Line 1724... Line 1853...
1724
* @param { boolean } sensComparaison : true = rechercher, false = refuser
1853
* @param { boolean } sensComparaison : true = rechercher, false = refuser
1725
* @param { string || number || object || undefined || boolean } comparer :valeur à comparer
1854
* @param { string || number || object || undefined || boolean } comparer :valeur à comparer
1726
* @returns {boolean}
1855
* @returns {boolean}
1727
*/
1856
*/
1728
function valeurOk( valeur, sensComparaison = true, comparer = undefined ) {
1857
function valeurOk( valeur, sensComparaison = true, comparer = undefined ) {
1729
 
-
 
1730
	if ( 'boolean' !== typeof valeur ) {
1858
	if ( 'boolean' !== typeof valeur ) {
1731
		switch( typeof valeur ) {
1859
		switch( typeof valeur ) {
1732
			case 'string' :
1860
			case 'string' :
1733
				retour = ( '' !== valeur );
1861
				retour = ( '' !== valeur );
1734
			 break;
1862
			 break;
Line 1775... Line 1903...
1775
 * @param jqXHR
1903
 * @param jqXHR
1776
 * @returns {String}
1904
 * @returns {String}
1777
 */
1905
 */
1778
function extraireEnteteDebug( jqXHR ) {
1906
function extraireEnteteDebug( jqXHR ) {
1779
	var msgDebug = '';
1907
	var msgDebug = '';
-
 
1908
 
1780
	if ( '' !== jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ) {
1909
	if ( '' !== jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) ) {
1781
		var debugInfos = jQuery.parseJSON( jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) );
1910
		var debugInfos = jQuery.parseJSON( jqXHR.getResponseHeader( 'X-DebugJrest-Data' ) );
-
 
1911
 
1782
		if ( null !== debugInfos ) {
1912
		if ( null !== debugInfos ) {
1783
			$.each( debugInfos, function( cle, valeur ) {
1913
			$.each( debugInfos, function( cle, valeur ) {
1784
				msgDebug += valeur + '\n';
1914
				msgDebug += valeur + '\n';
1785
			});
1915
			});
1786
		}
1916
		}
Line 1802... Line 1932...
1802
	var proto = $.ui.autocomplete.prototype,
1932
	var proto = $.ui.autocomplete.prototype,
1803
		initSource = proto._initSource;
1933
		initSource = proto._initSource;
Line 1804... Line 1934...
1804
 
1934
 
1805
	WidgetSaisie.prototype.filter = function( array, term ) {
1935
	WidgetSaisie.prototype.filter = function( array, term ) {
-
 
1936
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' );
1806
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), 'i' );
1937
 
1807
		return $.grep( array, function( value ) {
1938
		return $.grep( array, function( value ) {
1808
			return matcher.test( $( '<div>' ).html( value.label || value.value || value ).text() );
1939
			return matcher.test( $( '<div>' ).html( value.label || value.value || value ).text() );
1809
		});
1940
		});
1810
	}
1941
	}