Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2697 Rev 2700
Line 8... Line 8...
8
	this.ligneRue = undefined;
8
	this.ligneRue = undefined;
9
	this.premierDeplacement = true;
9
	this.premierDeplacement = true;
10
	this.valeurChamp = "";
10
	this.valeurChamp = "";
11
	this.avertissementDeuxPhotosAffiche = false;
11
	this.avertissementDeuxPhotosAffiche = false;
12
	this.taxons = {};
12
	this.taxons = {};
-
 
13
	this.googleMapMarqueurDebutUrl = null;
-
 
14
	this.googleMapMarqueurFinUrl = null;
-
 
15
	this.ville = null;
-
 
16
	this.supprimerIconeUrl = null;
13
}
17
}
14
WidgetSaisieSauvages.prototype = new WidgetSaisie();
18
WidgetSaisieSauvages.prototype = new WidgetSaisie();
Line 15... Line 19...
15
 
19
 
16
// surcharge
20
// surcharge
Line 28... Line 32...
28
	this.configurerFormValidator();
32
	this.configurerFormValidator();
29
	this.definirReglesFormValidator();
33
	this.definirReglesFormValidator();
Line 30... Line 34...
30
 
34
 
31
	this.surChangementTaxonListe();
35
	this.surChangementTaxonListe();
32
	$('#taxon-liste').on('change', this.surChangementTaxonListe);
36
	$('#taxon-liste').on('change', this.surChangementTaxonListe);
33
	if (DEBUG) {
37
	if (this.debug) {
34
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
38
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
35
	}
39
	}
36
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
40
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
37
	$('#taxon').on('blur', this.surChangementValeurTaxon);
41
	$('#taxon').on('blur', this.surChangementValeurTaxon);
Line 38... Line 42...
38
}
42
}
39
 
43
 
40
//surcharge
44
//surcharge
Line -... Line 45...
-
 
45
WidgetSaisieSauvages.prototype.initEvts = function() {
-
 
46
	var lthis = this;
-
 
47
 
-
 
48
	// super() à la main - toute autre manière de faire est über-komplex
41
WidgetSaisieSauvages.prototype.initEvts = function() {
49
	WidgetSaisie.prototype.initEvts.call(this);
42
	var lthis = this;
50
 
43
 
51
	$('.has-tooltip').tooltip('enable'); // @TODO harmoniser .has-tooltip et [rel="tooltip"]
-
 
52
	$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) {
44
	$('body').on('click', '.effacer-miniature', function(event) {
53
		event.stopPropagation();
Line 45... Line 54...
45
		lthis.supprimerMiniature($(this));
54
	});
46
	});
55
	$('#fichier').off(); // elever l'écouteur d'événements de base
47
	$('#fichier').on('click change', function(event) {
56
	$('#fichier').on('click change', function(event) {
Line 64... Line 73...
64
				success: lthis.afficherMiniature.bind(lthis), // post-submit callback
73
				success: lthis.afficherMiniature.bind(lthis), // post-submit callback
65
				dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
74
				dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
66
				resetForm: true // reset the form after successful submit
75
				resetForm: true // reset the form after successful submit
67
			};
76
			};
68
			$('#miniature').append(
77
			$('#miniature').append(
69
				'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+CHARGEMENT_IMAGE_URL+'"/>');
78
				'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+ this.chargementImageIconeUrl +'"/>');
70
			$('#ajouter-obs').attr('disabled', 'disabled');
79
			$('#ajouter-obs').attr('disabled', 'disabled');
71
			if (lthis.verifierFormat($(this).val())) {
80
			if (lthis.verifierFormat($(this).val())) {
72
				$('#form-upload').ajaxSubmit(options);
81
				$('#form-upload').ajaxSubmit(options);
73
			} else {
82
			} else {
74
				$('#form-upload')[0].reset();
83
				$('#form-upload')[0].reset();
Line 80... Line 89...
80
 
89
 
81
	$('.cb-milieux').on('click', function(event) {
90
	$('.cb-milieux').on('click', function(event) {
82
		$(this).valid();
91
		$(this).valid();
83
		event.stopPropagation();
92
		event.stopPropagation();
84
	});
-
 
85
	$('#ajouter-obs').on('click', this.ajouterObs.bind(this));
-
 
86
	$('.obs-nbre').on('changement', this.surChangementNbreObs.bind(this));
-
 
87
	$("body").on('click', ".supprimer-obs", function() {
-
 
88
		var that = this,
-
 
89
			suppObs = lthis.supprimerObs.bind(lthis);
-
 
90
		// bricolage pour avoir les deux contextes en même temps (objet et elt. du DOM)
-
 
91
		suppObs(that);
-
 
92
	});
-
 
Line 93... Line 93...
93
	$('#transmettre-obs').on('click', this.transmettreObs.bind(this));
93
	});
94
 
94
 
95
	// Défilement des photos
95
	// Défilement des photos
96
	$('body').on('click', '.defilement-control-zone', function(event) {
96
	$('body').on('click', '.defilement-control-zone', function(event) {
Line 100... Line 100...
100
		$('.defilement-control', this).removeClass('hidden');
100
		$('.defilement-control', this).removeClass('hidden');
101
	});
101
	});
102
	$('body').on('mouseout', '.defilement-control-zone', function(event) {
102
	$('body').on('mouseout', '.defilement-control-zone', function(event) {
103
		$('.defilement-control', this).addClass('hidden');
103
		$('.defilement-control', this).addClass('hidden');
104
	});
104
	});
105
	// Interaction sur le formulaire observateur
-
 
106
	$('#prenom').on('change', this.formaterPrenom.bind(this));
-
 
107
	$('#nom').on('change', this.formaterNom.bind(this));
-
 
108
	$('#courriel').on('keyup', this.testerLancementRequeteIdentite.bind(this));
-
 
109
	$('#courriel').on('blur', this.requeterIdentite.bind(this));
-
 
110
	$('#courriel_confirmation').on('paste', this.bloquerCopierCollerCourriel.bind(this));
-
 
Line 111... Line 105...
111
 
105
 
112
	$('#photo-placeholder').click(function(event) {
106
	$('#photo-placeholder').click(function(event) {
113
		$('#fichier').click();
107
		$('#fichier').click();
Line 114... Line -...
114
	});
-
 
115
 
-
 
116
	// Interaction générales
-
 
117
	$('.alert .close').on('click', this.fermerPanneauAlert);
-
 
118
	$('.has-tooltip').tooltip('enable');
-
 
119
	$('#btn-aide').on('click', this.basculerAffichageAide);
-
 
120
	$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) {
-
 
121
		event.stopPropagation();
-
 
122
	});
108
	});
123
 
109
 
124
	// Autocompletion du champ adresse
110
	// Autocompletion du champ adresse
125
	$('#carte-recherche').on('focus', function() {
111
	$('#carte-recherche').on('focus', function() {
126
		$(this).select();
112
		$(this).select();
Line 168... Line 154...
168
		}
154
		}
169
	});
155
	});
170
	$('#geolocaliser').on('click', this.geolocaliser.bind(this));
156
	$('#geolocaliser').on('click', this.geolocaliser.bind(this));
171
}
157
}
Line 172... Line -...
172
 
-
 
173
 
158
 
174
WidgetSaisieSauvages.prototype.montrerFormIdentite = function() {
159
WidgetSaisieSauvages.prototype.montrerFormIdentite = function() {
175
	$('#zone-courriel-confirmation, #zone-prenom-nom').css('display', 'block');
160
	$('#zone-courriel-confirmation, #zone-prenom-nom').css('display', 'block');
Line 176... Line 161...
176
}
161
}
177
 
162
 
178
// surcharge
163
// surcharge
179
WidgetSaisieSauvages.prototype.initialiserGoogleMap = function() {
164
WidgetSaisieSauvages.prototype.initialiserGoogleMap = function() {
180
	var lthis = this;
165
	var lthis = this;
181
	this.latLngDeb = new google.maps.LatLng(48.8543, 2.3483);// Paris
166
	this.latLngDeb = new google.maps.LatLng(48.8543, 2.3483);// Paris
182
	if (VILLE == 'Marseille') {
167
	if (this.ville == 'Marseille') {
183
		this.latLngDeb = new google.maps.LatLng(43.29545, 5.37458);
168
		this.latLngDeb = new google.maps.LatLng(43.29545, 5.37458);
184
	} else if (VILLE == 'Montpellier') {
169
	} else if (this.ville == 'Montpellier') {
185
		this.latLngDeb = new google.maps.LatLng(43.61077, 3.87672);
170
		this.latLngDeb = new google.maps.LatLng(43.61077, 3.87672);
186
	}
171
	}
187
	var options = {
172
	var options = {
Line 217... Line 202...
217
 
202
 
218
	// Lorsque la carte est chargée, on vérifie si on peut précharger des données
203
	// Lorsque la carte est chargée, on vérifie si on peut précharger des données
219
	google.maps.event.addListenerOnce(this.map, 'idle', function(){
204
	google.maps.event.addListenerOnce(this.map, 'idle', function(){
220
		// Initialisation du marker de début de rue
205
		// Initialisation du marker de début de rue
221
		lthis.initialiserMarkerDeb();
206
		lthis.initialiserMarkerDeb();
222
		if (OBS_ID != '') {
207
		if (this.obsId != '') {
223
			lthis.chargerInfoObs();
208
			lthis.chargerInfoObs();
224
		} else {
209
		} else {
225
			// Tentative de geocalisation si aucune obs à précharger
210
			// Tentative de geocalisation si aucune obs à précharger
226
			lthis.tenterGeolocalisation();
211
			lthis.tenterGeolocalisation();
Line 277... Line 262...
277
		// Marqueur de début de Rue
262
		// Marqueur de début de Rue
278
		this.markerDeb = new google.maps.Marker({
263
		this.markerDeb = new google.maps.Marker({
279
			map: this.map,
264
			map: this.map,
280
			draggable: true,
265
			draggable: true,
281
			title: 'Début de la portion de rue étudiée',
266
			title: 'Début de la portion de rue étudiée',
282
			icon: GOOGLE_MAP_MARQUEUR_DEBUT_URL,
267
			icon: this.googleMapMarqueurDebutUrl,
283
			position: this.latLngDeb
268
			position: this.latLngDeb
284
		});
269
		});
285
		google.maps.event.addListener(this.markerDeb, 'dragend', this.surDeplacementMarkerDeb.bind(this));
270
		google.maps.event.addListener(this.markerDeb, 'dragend', this.surDeplacementMarkerDeb.bind(this));
286
	}
271
	}
Line 321... Line 306...
321
	if (this.markerFin == undefined) {
306
	if (this.markerFin == undefined) {
322
		this.markerFin = new google.maps.Marker({
307
		this.markerFin = new google.maps.Marker({
323
			map: this.map,
308
			map: this.map,
324
			draggable: true,
309
			draggable: true,
325
			title: 'Fin de la portion de rue étudiée',
310
			title: 'Fin de la portion de rue étudiée',
326
			icon: GOOGLE_MAP_MARQUEUR_FIN_URL,
311
			icon: this.googleMapMarqueurFinUrl,
327
			position: this.latLngFin
312
			position: this.latLngFin
328
		});
313
		});
329
		google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
314
		google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
330
	} else {
315
	} else {
331
		this.markerFin.setMap(null);
316
		this.markerFin.setMap(null);
Line 442... Line 427...
442
	});
427
	});
443
}
428
}
Line 444... Line 429...
444
 
429
 
445
WidgetSaisieSauvages.prototype.getUrlAutocompletionNomsSci = function() {
430
WidgetSaisieSauvages.prototype.getUrlAutocompletionNomsSci = function() {
446
	var mots = $('#taxon').val(),
431
	var mots = $('#taxon').val(),
447
		url = SERVICE_AUTOCOMPLETION_NOM_SCI_URL_TPL.replace('{referentiel}',NOM_SCI_REFERENTIEL);
432
		url = this.serviceAutocompletionNomSciUrlTpl.replace('{referentiel}', this.nomSciReferentiel);
448
	url = url.replace('{masque}', mots);
433
	url = url.replace('{masque}', mots);
449
	return url;
434
	return url;
Line 450... Line 435...
450
}
435
}
Line 455... Line 440...
455
		$.each(data.resultat, function(i, val) {
440
		$.each(data.resultat, function(i, val) {
456
			val.nn = i;
441
			val.nn = i;
457
			var nom = {label: '', value: '', nt: '', nomSel: '', nomSelComplet: '', numNomSel: '',
442
			var nom = {label: '', value: '', nt: '', nomSel: '', nomSelComplet: '', numNomSel: '',
458
				nomRet: '', numNomRet: '', famille: '', retenu: false
443
				nomRet: '', numNomRet: '', famille: '', retenu: false
459
			};
444
			};
460
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
445
			if (suggestions.length >= this.autocompletionElementsNbre) {
461
				nom.label = '...';
446
				nom.label = '...';
462
				nom.value = $('#taxon').val();
447
				nom.value = $('#taxon').val();
463
				suggestions.push(nom);
448
				suggestions.push(nom);
464
				return false;
449
				return false;
465
			} else {
450
			} else {
Line 606... Line 591...
606
	$(selector).datepicker({
591
	$(selector).datepicker({
607
		dateFormat: 'dd/mm/yy',
592
		dateFormat: 'dd/mm/yy',
608
		maxDate: new Date,
593
		maxDate: new Date,
609
		showOn: 'button',
594
		showOn: 'button',
610
		buttonImageOnly: true,
595
		buttonImageOnly: true,
611
		buttonImage: CALENDRIER_ICONE_URL,
596
		buttonImage: this.calendrierIconeUrl,
612
		buttonText: 'Afficher le calendrier pour saisir la date.',
597
		buttonText: 'Afficher le calendrier pour saisir la date.',
613
		showButtonPanel: true,
598
		showButtonPanel: true,
614
		onSelect: function(date) {
599
		onSelect: function(date) {
615
			$(this).valid();
600
			$(this).valid();
616
		}
601
		}
Line 643... Line 628...
643
	} else {
628
	} else {
644
		// Affichage de tous les panneau cachés avec champ obligatoire
629
		// Affichage de tous les panneau cachés avec champ obligatoire
645
		var debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
630
		var debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
646
			finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
631
			finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
647
		if (debRue == false || finRue == false) {
632
		if (debRue == false || finRue == false) {
648
			afficherPanneau('#dialogue-form-invalide-rue');
633
			this.afficherPanneau('#dialogue-form-invalide-rue');
649
		} else {
634
		} else {
650
			afficherPanneau('#dialogue-form-invalide');
635
			this.afficherPanneau('#dialogue-form-invalide');
651
		}
636
		}
652
		this.montrerFormIdentite();
637
		this.montrerFormIdentite();
653
	}
638
	}
654
};
639
};
Line 655... Line 640...
655
 
640
 
656
// surcharge
641
// surcharge
657
WidgetSaisieSauvages.prototype.afficherObs = function() {
642
WidgetSaisieSauvages.prototype.afficherObs = function() {
658
	var numNomSel = ($('#taxon-liste').val() == '?') ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
643
	var numNomSel = ($('#taxon-liste').val() == '?') ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
659
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
644
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
660
		taxon = ($('#taxon-liste').val() == '?') ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
645
		taxon = ($('#taxon-liste').val() == '?') ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
661
		referentiel = (numNomSel == undefined) ? '' : '['+NOM_SCI_REFERENTIEL+']',
646
		referentiel = (numNomSel == undefined) ? '' : '['+ this.nomSciReferentiel +']',
662
		commune = $('#commune-nom').text(),
647
		commune = $('#commune-nom').text(),
663
		codeInsee = $('#commune-code-insee').text(),
648
		codeInsee = $('#commune-code-insee').text(),
664
		station = $('input[name="adresse"]').val(),
649
		station = $('input[name="adresse"]').val(),
665
		lat = $('input[name="latitude"]').val(),
650
		lat = $('input[name="latitude"]').val(),
Line 725... Line 710...
725
		miniatures = '',
710
		miniatures = '',
726
		indicateurs = '',
711
		indicateurs = '',
727
		premiere = true,
712
		premiere = true,
728
		numero = 1;
713
		numero = 1;
729
	if ($('#miniatures img').length == 0) {
714
	if ($('#miniatures img').length == 0) {
730
		html = '<img class="miniature" alt="Aucune photo"src="'+PAS_DE_PHOTO_ICONE_URL+'" />';
715
		html = '<img class="miniature" alt="Aucune photo"src="'+ this.pasDePhotoIconeUrl +'" />';
731
	} else if ($('#miniatures img').length >= 1) {
716
	} else if ($('#miniatures img').length >= 1) {
732
		$('#miniatures img').each(function() {
717
		$('#miniatures img').each(function() {
733
			var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee',
718
			var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee',
734
				css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
719
				css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
735
				src = $(this).attr('src'),
720
				src = $(this).attr('src'),
Line 802... Line 787...
802
	return nn;
787
	return nn;
803
}
788
}
Line 804... Line 789...
804
 
789
 
805
// surcharge
790
// surcharge
806
WidgetSaisieSauvages.prototype.surChangementReferentiel = function() {
791
WidgetSaisieSauvages.prototype.surChangementReferentiel = function() {
807
	NOM_SCI_REFERENTIEL = $('#referentiel').val();
792
	this.nomSciReferentiel = $('#referentiel').val();
808
	$('#taxon').val('');
793
	$('#taxon').val('');
Line 809... Line 794...
809
}
794
}
810
 
795
 
Line 817... Line 802...
817
		nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
802
		nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
818
		nomRet = nomHorsListe ? $('#taxon').data('nomRet') : taxons[numNomSel]['nom_ret'],
803
		nomRet = nomHorsListe ? $('#taxon').data('nomRet') : taxons[numNomSel]['nom_ret'],
819
		numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : taxons[numNomSel]['num_nom_ret'],
804
		numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : taxons[numNomSel]['num_nom_ret'],
820
		numTaxon = nomHorsListe ? $('#taxon').data('nt') : taxons[numNomSel]['num_taxon'],
805
		numTaxon = nomHorsListe ? $('#taxon').data('nt') : taxons[numNomSel]['num_taxon'],
821
		famille = nomHorsListe ? $('#taxon').data('famille') : taxons[numNomSel]['famille'],
806
		famille = nomHorsListe ? $('#taxon').data('famille') : taxons[numNomSel]['famille'],
822
		referentiel = (numNomSel == undefined) ? '' : NOM_SCI_REFERENTIEL,
807
		referentiel = (numNomSel == undefined) ? '' : this.nomSciReferentiel,
823
		notes = (nomSpecial ? taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
808
		notes = (nomSpecial ? taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
Line 824... Line 809...
824
		
809
		
825
		certitude = $('input[name=certitude]:checked').val();
810
		certitude = $('input[name=certitude]:checked').val();
Line 849... Line 834...
849
		'image_nom': lthis.getNomsImgsOriginales(),
834
		'image_nom': lthis.getNomsImgsOriginales(),
Line 850... Line 835...
850
 
835
 
851
		// Ajout des champs étendus de l'obs
836
		// Ajout des champs étendus de l'obs
852
		'obs_etendue': lthis.getObsChpEtendus()
837
		'obs_etendue': lthis.getObsChpEtendus()
853
	});
838
	});
854
	if (DEBUG) {
839
	if (this.debug) {
855
		console.log($('#liste-obs').data('obsId'+this.obsNbre));
840
		console.log($('#liste-obs').data('obsId'+this.obsNbre));
856
	}
841
	}
Line 857... Line 842...
857
}
842
}