Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2700 Rev 2701
Line 12... Line 12...
12
	this.taxons = {};
12
	this.taxons = {};
13
	this.googleMapMarqueurDebutUrl = null;
13
	this.googleMapMarqueurDebutUrl = null;
14
	this.googleMapMarqueurFinUrl = null;
14
	this.googleMapMarqueurFinUrl = null;
15
	this.ville = null;
15
	this.ville = null;
16
	this.supprimerIconeUrl = null;
16
	this.supprimerIconeUrl = null;
17
}
17
}	
18
WidgetSaisieSauvages.prototype = new WidgetSaisie();
18
WidgetSaisieSauvages.prototype = new WidgetSaisie();
Line 19... Line 19...
19
 
19
 
20
// surcharge
20
// surcharge
21
WidgetSaisieSauvages.prototype.initCarto = function() {
21
WidgetSaisieSauvages.prototype.initCarto = function() {
22
	this.initialiserGoogleMap();
22
	this.initialiserGoogleMap();
23
	this.afficherEtapeGeolocalisation(1);
23
	this.afficherEtapeGeolocalisation(1);
Line 24... Line 24...
24
}
24
};
25
 
25
 
26
//surcharge
26
//surcharge
27
WidgetSaisieSauvages.prototype.initForm = function() {
27
WidgetSaisieSauvages.prototype.initForm = function() {
Line 37... Line 37...
37
	if (this.debug) {
37
	if (this.debug) {
38
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
38
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
39
	}
39
	}
40
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
40
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
41
	$('#taxon').on('blur', this.surChangementValeurTaxon);
41
	$('#taxon').on('blur', this.surChangementValeurTaxon);
42
}
42
};
Line 43... Line 43...
43
 
43
 
44
//surcharge
44
//surcharge
45
WidgetSaisieSauvages.prototype.initEvts = function() {
45
WidgetSaisieSauvages.prototype.initEvts = function() {
Line 152... Line 152...
152
			lthis.map.setZoom(16);
152
			lthis.map.setZoom(16);
153
			lthis.afficherEtapeGeolocalisation(2);
153
			lthis.afficherEtapeGeolocalisation(2);
154
		}
154
		}
155
	});
155
	});
156
	$('#geolocaliser').on('click', this.geolocaliser.bind(this));
156
	$('#geolocaliser').on('click', this.geolocaliser.bind(this));
157
}
157
};
Line 158... Line 158...
158
 
158
 
159
WidgetSaisieSauvages.prototype.montrerFormIdentite = function() {
159
WidgetSaisieSauvages.prototype.montrerFormIdentite = function() {
160
	$('#zone-courriel-confirmation, #zone-prenom-nom').css('display', 'block');
160
	$('#zone-courriel-confirmation, #zone-prenom-nom').css('display', 'block');
Line 161... Line 161...
161
}
161
};
162
 
162
 
163
// surcharge
163
// surcharge
164
WidgetSaisieSauvages.prototype.initialiserGoogleMap = function() {
164
WidgetSaisieSauvages.prototype.initialiserGoogleMap = function() {
Line 212... Line 212...
212
		}
212
		}
213
	});
213
	});
Line 214... Line 214...
214
 
214
 
215
	// Création du Geocoder
215
	// Création du Geocoder
216
	this.geocoder = new google.maps.Geocoder();
216
	this.geocoder = new google.maps.Geocoder();
Line 217... Line 217...
217
}
217
};
218
 
218
 
Line 219... Line 219...
219
// surcharge
219
// surcharge
Line 252... Line 252...
252
	    this.map.setCenter(latlngbounds.getCenter());
252
	    this.map.setCenter(latlngbounds.getCenter());
253
	    this.map.fitBounds(latlngbounds);
253
	    this.map.fitBounds(latlngbounds);
254
    } else if(data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
254
    } else if(data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
255
    	this.deplacerMarkerDeb(pos);
255
    	this.deplacerMarkerDeb(pos);
256
    }
256
    }
257
}
257
};
Line 258... Line 258...
258
 
258
 
259
WidgetSaisieSauvages.prototype.initialiserMarkerDeb = function() {
259
WidgetSaisieSauvages.prototype.initialiserMarkerDeb = function() {
260
	this.premierDeplacement = true;
260
	this.premierDeplacement = true;
261
	if (this.markerDeb == undefined) {
261
	if (this.markerDeb == undefined) {
Line 276... Line 276...
276
	}
276
	}
277
	this.latLngCentre = this.latLngDeb;
277
	this.latLngCentre = this.latLngDeb;
278
	if (this.ligneRue != undefined) {
278
	if (this.ligneRue != undefined) {
279
		this.ligneRue.setMap(null);
279
		this.ligneRue.setMap(null);
280
	}
280
	}
281
}
281
};
Line 282... Line 282...
282
 
282
 
283
WidgetSaisieSauvages.prototype.surDeplacementMarkerDeb = function() {
283
WidgetSaisieSauvages.prototype.surDeplacementMarkerDeb = function() {
284
	this.deplacerMarkerDeb(this.markerDeb.getPosition());
284
	this.deplacerMarkerDeb(this.markerDeb.getPosition());
Line 285... Line 285...
285
}
285
};
286
 
286
 
287
WidgetSaisieSauvages.prototype.deplacerMarkerDeb = function(nouvellePosition) {
287
WidgetSaisieSauvages.prototype.deplacerMarkerDeb = function(nouvellePosition) {
288
	this.latLngDeb = nouvellePosition;
288
	this.latLngDeb = nouvellePosition;
Line 298... Line 298...
298
		var nouvellePositionFin = new google.maps.LatLng(this.latLngDeb.lat(), this.latLngDeb.lng() + 0.0010);
298
		var nouvellePositionFin = new google.maps.LatLng(this.latLngDeb.lat(), this.latLngDeb.lng() + 0.0010);
299
		this.initialiserMarkerFin();
299
		this.initialiserMarkerFin();
300
		this.deplacerMarkerFin(nouvellePositionFin)
300
		this.deplacerMarkerFin(nouvellePositionFin)
301
		this.afficherEtapeGeolocalisation(3);
301
		this.afficherEtapeGeolocalisation(3);
302
	}
302
	}
303
}
303
};
Line 304... Line 304...
304
 
304
 
305
WidgetSaisieSauvages.prototype.initialiserMarkerFin = function() {
305
WidgetSaisieSauvages.prototype.initialiserMarkerFin = function() {
306
	if (this.markerFin == undefined) {
306
	if (this.markerFin == undefined) {
307
		this.markerFin = new google.maps.Marker({
307
		this.markerFin = new google.maps.Marker({
Line 313... Line 313...
313
		});
313
		});
314
		google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
314
		google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
315
	} else {
315
	} else {
316
		this.markerFin.setMap(null);
316
		this.markerFin.setMap(null);
317
	}
317
	}
318
}
318
};
Line 319... Line 319...
319
 
319
 
320
WidgetSaisieSauvages.prototype.deplacerMarkerFin = function(nouvellePosition) {
320
WidgetSaisieSauvages.prototype.deplacerMarkerFin = function(nouvellePosition) {
321
	this.latLngFin = nouvellePosition;
321
	this.latLngFin = nouvellePosition;
322
	this.markerFin.setMap(this.map);
322
	this.markerFin.setMap(this.map);
323
	this.markerFin.setPosition(this.latLngFin);
323
	this.markerFin.setPosition(this.latLngFin);
324
	this.dessinerLigneRue(this.latLngDeb, this.latLngFin);
324
	this.dessinerLigneRue(this.latLngDeb, this.latLngFin);
Line 325... Line 325...
325
}
325
};
326
 
326
 
327
WidgetSaisieSauvages.prototype.surDeplacementMarkerFin = function() {
327
WidgetSaisieSauvages.prototype.surDeplacementMarkerFin = function() {
328
	this.dessinerLigneRue(this.markerDeb.getPosition(), this.markerFin.getPosition());
328
	this.dessinerLigneRue(this.markerDeb.getPosition(), this.markerFin.getPosition());
329
	this.afficherCentreRue();
329
	this.afficherCentreRue();
Line 330... Line 330...
330
	this.afficherEtapeGeolocalisation(4);
330
	this.afficherEtapeGeolocalisation(4);
331
}
331
};
332
 
332
 
333
WidgetSaisieSauvages.prototype.dessinerLigneRue = function(pointDebut, pointFin) {
333
WidgetSaisieSauvages.prototype.dessinerLigneRue = function(pointDebut, pointFin) {
Line 341... Line 341...
341
		strokeOpacity: 1.0,
341
		strokeOpacity: 1.0,
342
		strokeWeight: 2
342
		strokeWeight: 2
343
	});
343
	});
Line 344... Line 344...
344
 
344
 
345
	this.ligneRue.setMap(this.map);
345
	this.ligneRue.setMap(this.map);
Line 346... Line 346...
346
}
346
};
347
 
347
 
348
WidgetSaisieSauvages.prototype.afficherCentreRue = function() {
348
WidgetSaisieSauvages.prototype.afficherCentreRue = function() {
349
	this.latLngDeb = this.markerDeb.getPosition();
349
	this.latLngDeb = this.markerDeb.getPosition();
350
	this.latLngFin = this.markerFin.getPosition();
350
	this.latLngFin = this.markerFin.getPosition();
351
	this.latLngCentre = new google.maps.LatLng((this.latLngFin.lat() + this.latLngDeb.lat())/2, (this.latLngFin.lng() + this.latLngDeb.lng())/2);
351
	this.latLngCentre = new google.maps.LatLng((this.latLngFin.lat() + this.latLngDeb.lat())/2, (this.latLngFin.lng() + this.latLngDeb.lng())/2);
Line 352... Line 352...
352
	this.mettreAJourStationPosition(this.latLngCentre);
352
	this.mettreAJourStationPosition(this.latLngCentre);
353
}
353
};
354
 
354
 
355
WidgetSaisieSauvages.prototype.mettreAJourStationPosition = function(latLng) {
355
WidgetSaisieSauvages.prototype.mettreAJourStationPosition = function(latLng) {
356
	var lat = latLng.lat().toFixed(5),
356
	var lat = latLng.lat().toFixed(5),
357
		lng = latLng.lng().toFixed(5);
357
		lng = latLng.lng().toFixed(5);
Line 358... Line 358...
358
	this.remplirChampLatitude(lat);
358
	this.remplirChampLatitude(lat);
359
	this.remplirChampLongitude(lng);
359
	this.remplirChampLongitude(lng);
360
}
360
};
361
 
361
 
Line 362... Line 362...
362
WidgetSaisieSauvages.prototype.afficherEtapeGeolocalisation = function(numEtape) {
362
WidgetSaisieSauvages.prototype.afficherEtapeGeolocalisation = function(numEtape) {
363
	$('.liste_indication_geolocalisation').children().hide();
363
	$('.liste_indication_geolocalisation').children().hide();
364
	$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show();
364
	$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show();
365
}
365
};
Line 372... Line 372...
372
	this.initialiserMarkerDeb();
372
	this.initialiserMarkerDeb();
373
	this.deplacerMarkerDeb(nouvellePosition);
373
	this.deplacerMarkerDeb(nouvellePosition);
374
	this.afficherEtapeGeolocalisation(2);
374
	this.afficherEtapeGeolocalisation(2);
375
	this.map.setZoom(16);
375
	this.map.setZoom(16);
376
	arreter(event);
376
	arreter(event);
377
}
377
};
Line 378... Line 378...
378
 
378
 
379
WidgetSaisieSauvages.prototype.tenterGeolocalisation = function() {
379
WidgetSaisieSauvages.prototype.tenterGeolocalisation = function() {
380
	if (navigator.geolocation) {
380
	if (navigator.geolocation) {
381
		navigator.geolocation.getCurrentPosition(function(position) {
381
		navigator.geolocation.getCurrentPosition(function(position) {
Line 385... Line 385...
385
			this.initialiserMarkerDeb();
385
			this.initialiserMarkerDeb();
386
			this.deplacerMarkerDeb(nouvellePosition);
386
			this.deplacerMarkerDeb(nouvellePosition);
387
			this.map.setZoom(16);
387
			this.map.setZoom(16);
388
		});
388
		});
389
	}
389
	}
390
}
390
};
Line 391... Line 391...
391
 
391
 
392
/**
392
/**
393
 * AUTO-COMPLÉTION Noms Scientifiques => OK
393
 * AUTO-COMPLÉTION Noms Scientifiques => OK
394
 * sélectionne un nom et puis qu'on le remplacer par un nom non valide
394
 * sélectionne un nom et puis qu'on le remplacer par un nom non valide
Line 423... Line 423...
423
		if(lthis.valeurChamp != $('#taxon').val()) {
423
		if(lthis.valeurChamp != $('#taxon').val()) {
424
			$('#taxon').data('numNomSel', '');
424
			$('#taxon').data('numNomSel', '');
425
		}
425
		}
426
		lthis.valeurChamp = $('#taxon').val();
426
		lthis.valeurChamp = $('#taxon').val();
427
	});
427
	});
428
}
428
};
Line 429... Line 429...
429
 
429
 
430
WidgetSaisieSauvages.prototype.getUrlAutocompletionNomsSci = function() {
430
WidgetSaisieSauvages.prototype.getUrlAutocompletionNomsSci = function() {
431
	var mots = $('#taxon').val(),
431
	var mots = $('#taxon').val(),
432
		url = this.serviceAutocompletionNomSciUrlTpl.replace('{referentiel}', this.nomSciReferentiel);
432
		url = this.serviceAutocompletionNomSciUrlTpl.replace('{referentiel}', this.nomSciReferentiel);
433
	url = url.replace('{masque}', mots);
433
	url = url.replace('{masque}', mots);
434
	return url;
434
	return url;
Line 435... Line 435...
435
}
435
};
436
 
436
 
437
WidgetSaisieSauvages.prototype.traiterRetourNomsSci = function(data) {
437
WidgetSaisieSauvages.prototype.traiterRetourNomsSci = function(data) {
438
	var suggestions = [];
438
	var suggestions = [];
Line 462... Line 462...
462
				suggestions.push(nom);
462
				suggestions.push(nom);
463
			}
463
			}
464
		});
464
		});
465
	}
465
	}
466
	return suggestions;
466
	return suggestions;
467
}
467
};
468
 
-
 
469
WidgetSaisieSauvages.prototype.supprimerMiniature = function(miniature) {
-
 
470
	miniature.parents('.miniature').remove();
-
 
471
}
-
 
Line 472... Line 468...
472
 
468
 
473
// surcharge
469
// surcharge
474
WidgetSaisieSauvages.prototype.configurerFormValidator = function() {
470
WidgetSaisieSauvages.prototype.configurerFormValidator = function() {
475
	$.validator.addMethod(
471
	$.validator.addMethod(
Line 498... Line 494...
498
					$('#taxon').data('famille', '');
494
					$('#taxon').data('famille', '');
499
				}
495
				}
500
			}
496
			}
501
		}
497
		}
502
	});
498
	});
503
}
499
};
Line 504... Line 500...
504
 
500
 
505
// surcharge
501
// surcharge
506
WidgetSaisieSauvages.prototype.definirReglesFormValidator = function() {
502
WidgetSaisieSauvages.prototype.definirReglesFormValidator = function() {
507
	$('#form-observateur').validate({
503
	$('#form-observateur').validate({
Line 550... Line 546...
550
		},
546
		},
551
		messages: {
547
		messages: {
552
			'milieu[]': 'Vous devez sélectionner au moins un milieu'
548
			'milieu[]': 'Vous devez sélectionner au moins un milieu'
553
		}
549
		}
554
	});
550
	});
555
}
551
};
Line 556... Line 552...
556
 
552
 
557
WidgetSaisieSauvages.prototype.validerFormulaire = function() {
553
WidgetSaisieSauvages.prototype.validerFormulaire = function() {
558
	var observateur = $('#form-observateur').valid(),
554
	var observateur = $('#form-observateur').valid(),
559
		obs = $('#form-obs').valid(),
555
		obs = $('#form-obs').valid(),
560
		debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
556
		debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
561
		finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
557
		finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
562
	var ok = (observateur && obs && debRue && finRue) ? true : false;
558
	var ok = (observateur && obs && debRue && finRue) ? true : false;
563
	//console.log('observateur:'+observateur+'-obs:'+obs+'-debRue:'+debRue+'('+latLngDeb+')-finRue:'+finRue+'('+latLngDeb+')');
559
	//console.log('observateur:'+observateur+'-obs:'+obs+'-debRue:'+debRue+'('+latLngDeb+')-finRue:'+finRue+'('+latLngDeb+')');
564
	return ok;
560
	return ok;
Line 565... Line 561...
565
}
561
};
566
 
562
 
567
WidgetSaisieSauvages.prototype.surChangementTaxonListe = function() {
563
WidgetSaisieSauvages.prototype.surChangementTaxonListe = function() {
568
	if ($('#taxon-liste').val() === '?') {
564
	if ($('#taxon-liste').val() === '?') {
569
		$('#taxon-input-groupe').removeClass('hidden');
565
		$('#taxon-input-groupe').removeClass('hidden');
570
	} else {
566
	} else {
571
		$('#taxon-input-groupe').addClass('hidden');
567
		$('#taxon-input-groupe').addClass('hidden');
Line 572... Line 568...
572
	}
568
	}
573
}
569
};
574
 
570
 
575
WidgetSaisieSauvages.prototype.surChangementValeurTaxon = function() {
571
WidgetSaisieSauvages.prototype.surChangementValeurTaxon = function() {
Line 581... Line 577...
581
	if(nomSpecial || !numNomSel) {
577
	if(nomSpecial || !numNomSel) {
582
		$('#certitude-adeterminer').attr('checked', 'checked');
578
		$('#certitude-adeterminer').attr('checked', 'checked');
583
	} else {
579
	} else {
584
		$('#certitude-adeterminer').removeAttr('checked');
580
		$('#certitude-adeterminer').removeAttr('checked');
585
	}
581
	}
586
}
582
};
Line 587... Line 583...
587
 
583
 
588
// surcharge
584
// surcharge @TODO fusionner
589
WidgetSaisieSauvages.prototype.configurerDatePicker = function(selector) {
585
WidgetSaisieSauvages.prototype.configurerDatePicker = function(selector) {
590
	$.datepicker.setDefaults($.datepicker.regional['fr']);
586
	$.datepicker.setDefaults($.datepicker.regional['fr']);
591
	$(selector).datepicker({
587
	$(selector).datepicker({
592
		dateFormat: 'dd/mm/yy',
588
		dateFormat: 'dd/mm/yy',
Line 599... Line 595...
599
		onSelect: function(date) {
595
		onSelect: function(date) {
600
			$(this).valid();
596
			$(this).valid();
601
		}
597
		}
602
	});
598
	});
603
	$(selector + ' + img.ui-datepicker-trigger').appendTo(selector + '-icone.add-on');
599
	$(selector + ' + img.ui-datepicker-trigger').appendTo(selector + '-icone.add-on');
604
}
600
};
Line 605... Line 601...
605
 
601
 
606
// surcharge @TODO uniformiser .has-tooltip & rel="tooltip"
602
// surcharge @TODO uniformiser .has-tooltip & rel="tooltip"
607
WidgetSaisieSauvages.prototype.basculerAffichageAide = function() {
603
WidgetSaisieSauvages.prototype.basculerAffichageAide = function() {
608
	if ($(this).hasClass('btn-warning')) {
604
	if ($(this).hasClass('btn-warning')) {
Line 612... Line 608...
612
	} else {
608
	} else {
613
		$('.has-tooltip').tooltip('disable');
609
		$('.has-tooltip').tooltip('disable');
614
		$(this).removeClass('btn-success').addClass('btn-warning');
610
		$(this).removeClass('btn-success').addClass('btn-warning');
615
		$('#btn-aide-txt', this).text("Activer l'aide");
611
		$('#btn-aide-txt', this).text("Activer l'aide");
616
	}
612
	}
617
}
613
};
Line 618... Line 614...
618
 
614
 
619
// surcharge
615
// surcharge
620
WidgetSaisieSauvages.prototype.ajouterObs = function() {
616
WidgetSaisieSauvages.prototype.ajouterObs = function() {
621
	if (this.validerFormulaire() == true) {
617
	if (this.validerFormulaire() == true) {
Line 773... Line 769...
773
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').first();
769
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').first();
774
			indicateurActif.siblings().first().addClass('active');
770
			indicateurActif.siblings().first().addClass('active');
775
		}
771
		}
776
	}
772
	}
777
	miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee');
773
	miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee');
778
}
774
};
Line 779... Line 775...
779
 
775
 
780
WidgetSaisieSauvages.prototype.formaterNumNomSel = function(numNomSel) {
776
WidgetSaisieSauvages.prototype.formaterNumNomSel = function(numNomSel) {
781
	var nn = '';
777
	var nn = '';
782
	if (numNomSel == undefined) {
778
	if (numNomSel == undefined) {
783
		nn = '<span class="alert-error">[non lié au référentiel]</span>';
779
		nn = '<span class="alert-error">[non lié au référentiel]</span>';
784
	} else {
780
	} else {
785
		nn = '<span class="nn">[nn'+numNomSel+']</span>';
781
		nn = '<span class="nn">[nn'+numNomSel+']</span>';
786
	}
782
	}
787
	return nn;
783
	return nn;
Line 788... Line 784...
788
}
784
};
789
 
785
 
790
// surcharge
786
// surcharge
791
WidgetSaisieSauvages.prototype.surChangementReferentiel = function() {
787
WidgetSaisieSauvages.prototype.surChangementReferentiel = function() {
792
	this.nomSciReferentiel = $('#referentiel').val();
788
	this.nomSciReferentiel = $('#referentiel').val();
Line 793... Line 789...
793
	$('#taxon').val('');
789
	$('#taxon').val('');
794
}
790
};
795
 
791
 
796
// surcharge
792
// surcharge
Line 837... Line 833...
837
		'obs_etendue': lthis.getObsChpEtendus()
833
		'obs_etendue': lthis.getObsChpEtendus()
838
	});
834
	});
839
	if (this.debug) {
835
	if (this.debug) {
840
		console.log($('#liste-obs').data('obsId'+this.obsNbre));
836
		console.log($('#liste-obs').data('obsId'+this.obsNbre));
841
	}
837
	}
842
}
838
};
Line 843... Line 839...
843
 
839
 
844
WidgetSaisieSauvages.prototype.getObsChpEtendus = function() {
840
WidgetSaisieSauvages.prototype.getObsChpEtendus = function() {
845
	var champs = [];
841
	var champs = [];
846
	if (this.latLngDeb != undefined) {
842
	if (this.latLngDeb != undefined) {
Line 864... Line 860...
864
			var chpEtendu = {cle: cle, label: label, valeur: valeur};
860
			var chpEtendu = {cle: cle, label: label, valeur: valeur};
865
			champs.push(chpEtendu);
861
			champs.push(chpEtendu);
866
		}
862
		}
867
	});
863
	});
868
	return champs;
864
	return champs;
869
}
-
 
870
865
};
-
 
866
871
867