Subversion Repositories eFlore/Applications.cel

Rev

Rev 3046 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3025 delphine 1
// Héritage !!
2
function WidgetSaisieBellesdemarue() {
3
	this.markerDeb = undefined;
4
	this.latLngDeb = undefined;
5
	this.markerFin = undefined;
6
	this.latLngCentre = undefined;
7
	this.latLngFin = undefined;
8
	this.ligneRue = undefined;
9
	this.premierDeplacement = true;
10
	this.valeurChamp = "";
11
	this.avertissementDeuxPhotosAffiche = false;
12
	this.googleMapMarqueurDebutUrl = null;
13
	this.googleMapMarqueurFinUrl = null;
14
	this.ville = null;
15
	this.supprimerIconeUrl = null;
16
	this.serviceTraceRueUrl = null;
17
	this.taxons = {};
18
	this.listeRues = {};
19
	this.indexRueSelectionnee = 0;
20
	this.requeteRechercheRue = null;
21
	this.aucuneRueSelectionnee = "Aucune rue sélectionnée";
22
	this.nomDeRueInconnue = "Nom de rue inconnu";
23
	this.zoneGeo = null;
24
	this.groupeZonesGeo = null;
25
	this.serviceCoordSearchUrl = "";
26
}
27
WidgetSaisieBellesdemarue.prototype = new WidgetSaisie();
28
 
29
//surcharge
30
WidgetSaisieBellesdemarue.prototype.initialiserGoogleMap = function() {
3046 mathias 31
	// centrage
3025 delphine 32
	this.latLng = new google.maps.LatLng(50.8504500, 4.3487800);// Bruxelles par défaut
33
 
34
	var options = {
35
			zoom: 11, // avant : 16
36
			center: this.latLng,
37
			mapTypeId: google.maps.MapTypeId.HYBRID,
38
			mapTypeControlOptions: {
39
				mapTypeIds: ['OSM',
40
					google.maps.MapTypeId.ROADMAP,
41
					google.maps.MapTypeId.HYBRID,
42
					google.maps.MapTypeId.SATELLITE,
43
					google.maps.MapTypeId.TERRAIN]}
44
		};
45
 
46
	// Ajout de la couche OSM à la carte
47
	osmMapType = new google.maps.ImageMapType({
48
		getTileUrl: function(coord, zoom) {
49
			return 'http://tile.openstreetmap.org/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
50
		},
51
		tileSize: new google.maps.Size(256, 256),
52
		isPng: true,
53
		alt: 'OpenStreetMap',
54
		name: 'OSM',
55
		maxZoom: 19
56
	});
57
 
58
	// Création de la carte Google
59
	this.map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
60
	this.map.mapTypes.set('OSM', osmMapType);
61
 
62
	// Création du Geocoder
63
	this.geocoder = new google.maps.Geocoder();
64
 
65
	// Marqueur google draggable
66
	this.marker = new google.maps.Marker({
67
		map: this.map,
68
		draggable: true,
69
		title: 'Ma station',
70
		icon: this.googleMapMarqueurUrl,
71
		position: this.latLng
72
	});
73
 
74
	this.initialiserMarker(this.latLng);
75
 
76
	// intéraction carte
77
	$("#geolocaliser").on('click', this.geolocaliser.bind(this));
78
	google.maps.event.addListener(this.marker, 'dragend', this.surDeplacementMarker.bind(this));
79
	google.maps.event.addListener(this.map, 'click', this.surClickDansCarte.bind(this));
80
};
81
 
82
//surcharge
83
WidgetSaisieBellesdemarue.prototype.initForm = function() {
84
	// super() à la main - toute autre manière de faire est über-komplex
85
	WidgetSaisie.prototype.initForm.call(this);
86
 
87
	this.surChangementTaxonListe();
88
	$('#taxon-liste').on('change', this.surChangementTaxonListe);
89
	if (this.debug) {
90
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
91
	}
92
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
93
	$('#taxon').on('blur', this.surChangementValeurTaxon);
3046 mathias 94
 
95
	this.surChangementMilieuListe();
96
	$('#milieu').on('change', this.surChangementMilieuListe);
3025 delphine 97
};
98
 
99
//surcharge
100
WidgetSaisieBellesdemarue.prototype.initEvts = function() {
101
	var lthis = this;
102
	// super() à la main - toute autre manière de faire est über-komplex
103
	WidgetSaisie.prototype.initEvts.call(this);
104
 
105
	$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) {
106
		event.stopPropagation();
107
	});
108
	$('#fichier').off(); // elever l'écouteur d'événements de base
109
	$('#fichier').on('click change', function(event) {
110
		if ($(this).val().length > 0) {
111
			arreter(event);
112
			var options = {
113
				success: lthis.afficherMiniature.bind(lthis), // post-submit callback
114
				dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
115
				resetForm: true // reset the form after successful submit
116
			};
117
			$('#miniature').append(
118
				'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+ this.chargementImageIconeUrl +'"/>');
119
			$('#ajouter-obs').attr('disabled', 'disabled');
120
			if (lthis.verifierFormat($(this).val())) {
121
				$('#form-upload').ajaxSubmit(options);
122
			} else {
123
				$('#form-upload')[0].reset();
124
				window.alert("Le format de fichier n'est pas supporté, les formats acceptés sont "+	$('#fichier').attr('accept'));
125
			}
126
			return false;
127
		}
128
	});
129
 
130
	$('.cb-milieux').on('click', function(event) {
131
		$(this).valid();
132
		event.stopPropagation();
133
	});
134
 
135
	// Défilement des photos
136
	$('body').on('click', '.defilement-control-zone', function(event) {
137
		lthis.defilerMiniatures($(this));
138
	});
139
	$('body').on('mouseover', '.defilement-control-zone', function(event) {
140
		$('.defilement-control', this).removeClass('hidden');
141
	});
142
	$('body').on('mouseout', '.defilement-control-zone', function(event) {
143
		$('.defilement-control', this).addClass('hidden');
144
	});
145
 
146
	$('#photo-placeholder').click(function(event) {
147
		$('#fichier').click();
148
	});
149
	$('#geolocaliser').on('click', this.geolocaliser.bind(this));
150
 
151
};
152
 
153
/**
154
 * AUTO-COMPLÉTION Noms Scientifiques => OK
155
 * sélectionne un nom et puis qu'on le remplacer par un nom non valide
156
 * Garder la trace de la valeur permet de vider le nn lorsqu'on
157
 */
3045 mathias 158
/*
3025 delphine 159
WidgetSaisieBellesdemarue.prototype.ajouterAutocompletionNoms = function() {
160
	var lthis = this;
161
	$('#taxon').autocomplete({
162
		source: function(requete, add){
163
			// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
164
 
165
			var url = lthis.getUrlAutocompletionNomsSci();
166
			$.getJSON(url, function(data) {
167
				var suggestions = lthis.traiterRetourNomsSci(data);
168
				add(suggestions);
169
			});
170
		},
171
		html: true
172
	});
173
 
174
	$('#taxon').bind('autocompleteselect', function(event, ui) {
175
		$('#taxon').data(ui.item);
176
		lthis.valeurChamp = $('#taxon').val();
177
		if (ui.item.retenu == true) {
178
			$('#taxon').addClass('ns-retenu');
179
		} else {
180
			$('#taxon').removeClass('ns-retenu');
181
		}
182
	});
183
 
184
	$('#taxon').bind('keypress', function() {
185
		if(lthis.valeurChamp != $('#taxon').val()) {
186
			$('#taxon').data('numNomSel', '');
187
		}
188
		lthis.valeurChamp = $('#taxon').val();
189
	});
190
};
191
 
3046 mathias 192
*/
3025 delphine 193
 
194
// surcharge
195
WidgetSaisieBellesdemarue.prototype.configurerFormValidator = function() {
196
	$.validator.addMethod(
197
		'dateCel',
198
		function (value, element) {
199
			return value == '' || (/^[0-9]{2}[-\/][0-9]{2}[-\/][0-9]{4}$/.test(value));
200
		},
201
		'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.');
202
 
203
	$.extend($.validator.defaults, {
204
		ignore: [],// Forcer Jquery Validate à examiner les éléments avec en display:none;
205
		highlight: function(element) {
206
			$(element).closest('.control-group').removeClass('success').addClass('error');
207
		},
208
		success: function(element) {
209
			element.text('OK!').addClass('valid');
210
			element.closest('.control-group').removeClass('error').addClass('success');
211
 
212
			if (element.attr('id') == 'taxon' && $('#taxon').val() != '') {
213
				// Si le taxon n'est pas lié au référentiel, on vide le data associé
214
				if ($('#taxon').data('value') != $('#taxon').val()) {
215
					$('#taxon').data('numNomSel', '');
216
					$('#taxon').data('nomRet', '');
217
					$('#taxon').data('numNomRet', '');
218
					$('#taxon').data('nt', '');
219
					$('#taxon').data('famille', '');
220
				}
221
			}
222
		}
223
	});
224
};
225
 
226
// surcharge
227
WidgetSaisieBellesdemarue.prototype.definirReglesFormValidator = function() {
228
	$('#form-observateur').validate({
229
		rules: {
230
			courriel: {
231
				required: true,
232
				email: true},
233
			courriel_confirmation: {
234
				equalTo: '#courriel'},
235
			prenom: {
236
				required: true},
237
			nom: {
238
				required: true}
239
		}
240
	});
241
	$('#form-obs').validate({
242
		rules: {
243
			latitude : {
244
				required: true,
3046 mathias 245
				range: [-90, 90]
246
			},
3025 delphine 247
			longitude: {
248
				required: true,
3046 mathias 249
				range: [-180, 180]
250
			},
3025 delphine 251
			date: {
252
				required: true,
3046 mathias 253
				'dateCel' : true
254
			},
3025 delphine 255
			'taxon-liste': {
3046 mathias 256
				required: true
257
			},
258
			milieu: {
3025 delphine 259
				required: true,
3046 mathias 260
				minlength: 1
261
			},
262
			certitude: {
263
				required: true
264
			}
3025 delphine 265
		},
266
		errorPlacement: function(error, element) {
267
			if (element.attr('name') == 'date') {
268
				element.parent('.input-prepend').after(error);
3046 mathias 269
			} else if (element.attr('name') == 'certitude') {
270
				error.insertAfter('#certitude-controls');
3047 mathias 271
			} else if (element.attr('name') == 'longitude') { // on ignore "latitude" pour ne pas avoir de double erreur
272
				error.insertBefore('#info-commune');
3025 delphine 273
			} else {
274
				error.insertAfter(element);
275
			}
276
		}
277
	});
278
};
279
 
280
WidgetSaisieBellesdemarue.prototype.validerFormulaire = function() {
3046 mathias 281
	$observateur = $("#form-observateur").valid();
282
	$obs = $("#form-obs").valid();
283
	return ($observateur == true && $obs == true) ? true : false;
3025 delphine 284
};
285
 
286
WidgetSaisieBellesdemarue.prototype.surChangementTaxonListe = function() {
287
	if ($('#taxon-liste').val() === '?') {
288
		$('#taxon-input-groupe').removeClass('hidden');
289
	} else {
3046 mathias 290
		// $('#milieu-autre').val(''); paraît logique de faire ça mais méfiance
3025 delphine 291
		$('#taxon-input-groupe').addClass('hidden');
292
	}
293
};
294
 
3046 mathias 295
WidgetSaisieBellesdemarue.prototype.surChangementMilieuListe = function() {
296
	if ($('#milieu').val() === 'autres') {
297
		$('#milieu-autre-input-group').removeClass('hidden');
298
	} else {
299
		$('#milieu-autre').val('');
300
		$('#milieu-autre-input-group').addClass('hidden');
301
	}
302
};
303
 
3047 mathias 304
// trouve la commune (zone géo de niveau 8) sous le pointeur, en mode mondial
305
// et pas seulement français (service zoneAdmin et non nomCommune)
3045 mathias 306
WidgetSaisieBellesdemarue.prototype.trouverCommune = function(pos) {
307
	if (this.latLng == null) { // tentative de protection contre le démon de Prémilhat
308
		return;
309
	}
310
	var lthis = this;
311
	$(function() {
312
 
313
		var url_service = lthis.serviceNomCommuneUrl;
314
 
315
		var urlNomCommuneFormatee = url_service.replace('{lat}', pos.lat()).replace('{lon}', pos.lng());
316
		$.ajax({
317
			url : urlNomCommuneFormatee,
318
			type : "GET",
319
			dataType : "jsonp",
320
			beforeSend : function() {
321
				$(".commune-info").empty();
322
				$("#dialogue-erreur .alert-txt").empty();
323
			},
324
			success : function(data, textStatus, jqXHR) {
325
				$(".commune-info").empty();
326
				// en Belgique et en France, en général 8 = patelin @TODO bancal
327
				if ("8" in data) {
328
					$("#commune-nom").append(data["8"].intitule);
329
					$("#marqueur-commune").data('commune', {'nom' : data["8"].nom, 'codeInsee' : null});
330
				}
331
			},
332
			statusCode : {
333
			    500 : function(jqXHR, textStatus, errorThrown) {
334
					if (this.debug) {
335
						$("#dialogue-erreur .alert-txt").append('<p id="msg">Un problème est survenu lors de l\'appel au service fournissante le nom des communes.</p>');
336
						reponse = jQuery.parseJSON(jqXHR.responseText);
337
						var erreurMsg = "";
338
						if (reponse != null) {
339
							$.each(reponse, function (cle, valeur) {
340
								erreurMsg += valeur + "<br />";
341
							});
342
						}
343
 
344
						$("#dialogue-erreur .alert-txt").append('<p class="msg-erreur">Erreur 500 : '+errorThrown+"<br />"+erreurMsg+'</p>');
345
					}
346
			    }
347
			},
348
			error : function(jqXHR, textStatus, errorThrown) {
349
				if (this.debug) {
350
					$("#dialogue-erreur .alert-txt").append('<p class="msg">Une erreur Ajax est survenue lors de la recherche de la commune.</p>');
351
					reponse = jQuery.parseJSON(jqXHR.responseText);
352
					var erreurMsg = "";
353
					if (reponse != null) {
354
						$.each(reponse, function (cle, valeur) {
355
							erreurMsg += valeur + "<br />";
356
						});
357
					}
358
 
359
					$("#dialogue-erreur .alert-txt").append('<p class="msg-erreur">Erreur Ajax : '+errorThrown+' (type : '+textStatus+') <br />'+erreurMsg+'</p>');
360
				}
361
			},
362
			complete : function(jqXHR, textStatus) {
363
				var debugMsg = extraireEnteteDebug(jqXHR);
364
				if (debugMsg != '') {
365
					if (this.debug) {
366
						$("#dialogue-erreur .alert-txt").append('<pre class="msg-debug msg">Débogage : '+debugMsg+'</pre>');
367
					}
368
				}
369
				if ($("#dialogue-erreur .msg").length > 0) {
370
					$("#dialogue-erreur").show();
371
				}
372
			}
373
		});
374
	});
375
};
376
 
377
/*
3025 delphine 378
WidgetSaisieBellesdemarue.prototype.surChangementValeurTaxon = function() {
379
	var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
380
	var nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special');
381
	var numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val();
382
 
383
	// Un nom non valide entraine automatiquement une certitude "à déterminer"
384
	if(nomSpecial || !numNomSel) {
385
		$('#certitude-adeterminer').attr('checked', 'checked');
386
	} else {
387
		$('#certitude-adeterminer').removeAttr('checked');
388
	}
389
};
3047 mathias 390
*/
3025 delphine 391
 
392
// surcharge
393
WidgetSaisieBellesdemarue.prototype.ajouterObs = function() {
3047 mathias 394
	// Fermeture automatique des dialogue de transmission de données
395
	// @WARNING TEST
396
	$('#dialogue-obs-transaction-ko').hide();
397
	$('#dialogue-obs-transaction-ok').hide();
398
 
399
	// obligation de fournir au moins une image
400
	var nbImages = $('#miniatures img').length;
401
	if (nbImages == 0) {
402
		$('#image-obligatoire').show();
403
	} else {
404
		$('#image-obligatoire').hide();
405
	}
406
 
407
	if (this.validerFormulaire() == true && nbImages == 0) {
408
		this.masquerPanneau('#dialogue-form-invalide');
3025 delphine 409
		this.obsNbre = this.obsNbre + 1;
3047 mathias 410
		$(".obs-nbre").text(this.obsNbre);
411
		$(".obs-nbre").triggerHandler('changement');
3025 delphine 412
		this.afficherObs();
413
		this.stockerObsData();
414
		this.supprimerMiniatures();
3047 mathias 415
		if(! this.especeImposee) {
416
			$("#taxon").val("");
417
			$("#taxon").data("numNomSel",undefined);
418
		}
419
		$('#barre-progression-upload').attr('aria-valuemax', this.obsNbre);
420
		$('#barre-progression-upload .sr-only').text('0/'+this.obsNbre+" observations transmises");
3025 delphine 421
	} else {
3047 mathias 422
		this.afficherPanneau('#dialogue-form-invalide');
3025 delphine 423
	}
424
};
425
 
3047 mathias 426
/*
3025 delphine 427
// surcharge
428
WidgetSaisieBellesdemarue.prototype.afficherObs = function() {
429
	var numNomSel = ($('#taxon-liste').val() == '?') ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
430
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
431
		taxon = ($('#taxon-liste').val() == '?') ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
432
		referentiel = (numNomSel == undefined) ? '' : '['+ this.nomSciReferentiel +']',
433
		commune = $('#commune-nom').text(),
434
		codeInsee = $('#commune-code-insee').text(),
435
		station = this.getValeurStation(),
436
		lat = $('input[name="latitude"]').val(),
437
		lng = $('input[name="longitude"]').val(),
438
		date = $('#date').val(),
439
		milieux = this.getMilieux(),
440
		notes = (nomSpecial ? this.taxons[numNomSel]['nom_fr'] + ".<br />" : '') + $('#notes').val();
441
 
442
	$('#liste-obs').prepend(
443
		'<div id="obs'+this.obsNbre+'" class="row-fluid obs obs'+this.obsNbre+'">' +
444
			'<div class="span12">' +
445
				'<div class="well">' +
446
					'<div class="obs-action pull-right has-tooltip" data-placement="bottom" ' +
447
						'title="Supprimer cette observation de la liste à transmettre">' +
448
						'<button class="btn btn-danger supprimer-obs" value="'+this.obsNbre+'" title="'+this.obsNbre+'">' +
449
							'<i class="icon-trash icon-white"></i>' +
450
						'</button>' +
451
					'</div> ' +
452
					'<div class="row-fluid">' +
453
						'<div class="span2 obs-miniatures">' +
454
						this.ajouterImgMiniatureAuTransfert() +
455
						'</div>'+
456
						'<div class="span7">' +
457
							'<ul class="unstyled">' +
458
								'<li>'+
459
									'<span class="nom-sci">' + taxon + '</span> ' +
460
									this.formaterNumNomSel(numNomSel) +
461
									' observé à <br />' +
462
									'<span class="commune">' + commune + '</span> ' +
463
									'(' + codeInsee + '), ' +
464
									'<span class="station">' + station + '</span><br /> ' +
465
									' le ' +
466
									'<span class="date">' + date + '</span>' +
467
								'</li>' +
468
								'<li>' +
469
									'Milieux : ' + milieux + ' ' + ' ; ' +
470
								'</li>' +
471
								'<li>' +
472
									'Notes : ' + notes +
473
								'</li>' +
474
							'</ul>' +
475
						'</div>' +
476
					'</div>' +
477
				'</div>' +
478
			'</div>'+
479
		'</div>');
480
	$('#zone-liste-obs').removeClass("hidden");
481
};
482
 
483
WidgetSaisieBellesdemarue.prototype.getValeurStation = function() {
484
	var station = "";
485
	var valeurSelectionnee = $("#indication-nom-rue-nom").text().trim();
486
	if(valeurSelectionnee == this.aucuneRueSelectionnee || valeurSelectionnee == this.nomDeRueInconnue) {
487
		station = $('input[name="adresse"]').val().trim()
488
	} else {
489
		station = $("#indication-nom-rue-nom").text().trim();
490
	}
491
 
492
	return station;
493
}
494
 
495
WidgetSaisieBellesdemarue.prototype.ajouterImgMiniatureAuTransfert = function() {
496
	var html = '',
497
		miniatures = '',
498
		indicateurs = '',
499
		premiere = true,
500
		numero = 1;
501
	if ($('#miniatures img').length == 0) {
502
		html = '<img class="miniature" alt="Aucune photo"src="'+ this.pasDePhotoIconeUrl +'" />';
503
	} else if ($('#miniatures img').length >= 1) {
504
		$('#miniatures img').each(function() {
505
			var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee',
506
				css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
507
				src = $(this).attr('src'),
508
				alt = $(this).attr('alt');
509
 
510
			var miniature = '<img class="'+css+' '+visible+'"  alt="'+alt+'"src="'+src+'" />';
511
			miniatures += miniature;
512
 
513
			var indicateurActif = premiere ? 'active' : '';
514
			var indicateur = '<li class="' + indicateurActif + '" data-numero="' + numero++ + '"></li>';
515
			indicateurs += indicateur;
516
 
517
			premiere = false;
518
		});
519
 
520
		if ($('#miniatures img').length == 1) {
521
			html = miniatures;
522
		} else {
523
			html =
524
				'<div class="defilement">' +
525
					miniatures +
526
					'<a class="defilement-control-zone gauche">' +
527
					'	<span class="defilement-control gauche hidden">&#60;</span>' +
528
					'</a>' +
529
					'<a class="defilement-control-zone droite">' +
530
					'	<span class="defilement-control droite hidden">&#62;</span>' +
531
					'</a>' +
532
					'<ol class="defilement-indicateurs">' + indicateurs + '</ol>' +
533
				'</div>';
534
		}
535
	}
536
	return html;
537
};
538
 
539
WidgetSaisieBellesdemarue.prototype.defilerMiniatures = function(element) {
540
	var miniatureSelectionne = element.siblings('img.miniature-selectionnee');
541
	miniatureSelectionne.removeClass('miniature-selectionnee').addClass('miniature-cachee');
542
	var miniatureAffichee = miniatureSelectionne;
543
 
544
	var indicateurActif = element.parent().find('.defilement-indicateurs .active');
545
	indicateurActif.removeClass('active');
546
 
547
	if (element.hasClass('defilement-control-zone') && element.hasClass('gauche')) {
548
		if (miniatureSelectionne.prev('.miniature').length != 0) {
549
			miniatureAffichee = miniatureSelectionne.prev('.miniature');
550
			indicateurActif.prev().addClass('active');
551
		} else {
552
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').last();
553
			indicateurActif.siblings().last().addClass('active');
554
		}
555
	} else {
556
		if (miniatureSelectionne.next('.miniature').length != 0) {
557
			miniatureAffichee = miniatureSelectionne.next('.miniature');
558
			indicateurActif.next().addClass('active');
559
		} else {
560
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').first();
561
			indicateurActif.siblings().first().addClass('active');
562
		}
563
	}
564
	miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee');
565
};
566
 
567
WidgetSaisieBellesdemarue.prototype.formaterNumNomSel = function(numNomSel) {
568
	var nn = '';
569
	if (numNomSel == undefined) {
570
		nn = '<span class="alert-error">[non lié au référentiel]</span>';
571
	} else {
572
		nn = '<span class="nn">[nn'+numNomSel+']</span>';
573
	}
574
	return nn;
575
};
576
 
577
// surcharge
578
WidgetSaisieBellesdemarue.prototype.surChangementReferentiel = function() {
579
	this.nomSciReferentiel = $('#referentiel').val();
580
	$('#taxon').val('');
581
};
582
 
583
// surcharge
584
WidgetSaisieBellesdemarue.prototype.stockerObsData = function() {
585
	var lthis = this;
586
	var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
587
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
588
		numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val();
589
	var nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
590
		nomRet = nomHorsListe ? $('#taxon').data('nomRet') : this.taxons[numNomSel]['nom_ret'],
591
		numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : this.taxons[numNomSel]['num_nom_ret'],
592
		numTaxon = nomHorsListe ? $('#taxon').data('nt') : this.taxons[numNomSel]['num_taxon'],
593
		famille = nomHorsListe ? $('#taxon').data('famille') : this.taxons[numNomSel]['famille'],
594
		referentiel = (numNomSel == undefined) ? '' : this.nomSciReferentiel,
595
		notes = (nomSpecial ? this.taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
596
 
597
		certitude = $('input[name=certitude]:checked').val();
598
		certitude = (certitude == undefined) ? '' : certitude;
599
 
600
	$('#liste-obs').data('obsId'+this.obsNbre, {
601
		'date': $('#date').val(),
602
		'notes': notes,
603
 
604
		'station': this.getValeurStation(),
605
		'latitude': $('#latitude').val(),
606
		'longitude': $('#longitude').val(),
607
		'commune_nom': $('#commune-nom').text(),
608
		'commune_code_insee': $('#commune-code-insee').text(),
609
 
610
		'nom_sel': nomSel,
611
		'num_nom_sel': numNomSel,
612
		'nom_ret': nomRet,
613
		'num_nom_ret': numNomRet,
614
		'num_taxon': numTaxon,
615
		'famille': famille,
616
		'referentiel': referentiel,
617
		'certitude': certitude,
618
		'milieu': lthis.getMilieux(),
619
 
620
		// Ajout des champs images
621
		'image_nom': lthis.getNomsImgsOriginales(),
622
 
623
		// Ajout des champs étendus de l'obs
624
		'obs_etendue': lthis.getObsChpEtendus()
625
	});
626
	if (this.debug) {
627
		console.log($('#liste-obs').data('obsId'+this.obsNbre));
628
	}
629
};
630
 
631
WidgetSaisieBellesdemarue.prototype.getObsChpEtendus = function() {
632
	var champs = [];
633
	if (this.latLngDeb != undefined) {
634
		var latitudeDebutRue = {cle: 'latitudeDebutRue', label: 'Latitude du début de la rue', valeur: this.latLngDeb.lat().toFixed(5)};
635
		champs.push(latitudeDebutRue);
636
		var longitudeDebutRue = {cle: 'longitudeDebutRue', label: 'Longitude du début de la rue', valeur: this.latLngDeb.lng().toFixed(5)};
637
		champs.push(longitudeDebutRue);
638
	}
639
	if (this.latLngFin != undefined) {
640
		var latitudeFinRue = {cle: 'latitudeFinRue', label: 'Latitude de fin de la rue', valeur: this.latLngFin.lat().toFixed(5)};
641
		champs.push(latitudeFinRue);
642
		var longitudeFinRue = {cle: 'longitudeFinRue', label: 'Longitude de fin de la rue', valeur: this.latLngFin.lng().toFixed(5)};
643
		champs.push(longitudeFinRue);
644
	}
645
 
646
	$('.obs-chp-etendu').each(function() {
647
		var valeur = $(this).val(),
648
			cle = $(this).attr('name'),
649
			label = $(this).data('label');
650
		if (valeur != '') {
651
			var chpEtendu = {cle: cle, label: label, valeur: valeur};
652
			champs.push(chpEtendu);
653
		}
654
	});
655
	return champs;
656
};
3045 mathias 657
*/