2697 |
mathias |
1 |
// Héritage !!
|
|
|
2 |
function WidgetSaisieSauvages() {
|
|
|
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.taxons = {};
|
1054 |
jpm |
13 |
}
|
2697 |
mathias |
14 |
WidgetSaisieSauvages.prototype = new WidgetSaisie();
|
1346 |
aurelien |
15 |
|
2697 |
mathias |
16 |
// surcharge
|
|
|
17 |
WidgetSaisieSauvages.prototype.initCarto = function() {
|
|
|
18 |
this.initialiserGoogleMap();
|
|
|
19 |
this.afficherEtapeGeolocalisation(1);
|
1916 |
jpm |
20 |
}
|
1054 |
jpm |
21 |
|
2697 |
mathias |
22 |
//surcharge
|
|
|
23 |
WidgetSaisieSauvages.prototype.initForm = function() {
|
|
|
24 |
//this.requeterIdentite();// Sur rechargement de la page
|
|
|
25 |
// Gestion de la liste des taxons
|
|
|
26 |
this.configurerDatePicker('#date');
|
|
|
27 |
this.ajouterAutocompletionNoms();
|
|
|
28 |
this.configurerFormValidator();
|
|
|
29 |
this.definirReglesFormValidator();
|
1916 |
jpm |
30 |
|
2697 |
mathias |
31 |
this.surChangementTaxonListe();
|
|
|
32 |
$('#taxon-liste').on('change', this.surChangementTaxonListe);
|
|
|
33 |
if (DEBUG) {
|
|
|
34 |
console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
|
1916 |
jpm |
35 |
}
|
2697 |
mathias |
36 |
$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
|
|
|
37 |
$('#taxon').on('blur', this.surChangementValeurTaxon);
|
1916 |
jpm |
38 |
}
|
|
|
39 |
|
2697 |
mathias |
40 |
//surcharge
|
|
|
41 |
WidgetSaisieSauvages.prototype.initEvts = function() {
|
|
|
42 |
var lthis = this;
|
|
|
43 |
|
|
|
44 |
$('body').on('click', '.effacer-miniature', function(event) {
|
|
|
45 |
lthis.supprimerMiniature($(this));
|
|
|
46 |
});
|
|
|
47 |
$('#fichier').on('click change', function(event) {
|
|
|
48 |
|
|
|
49 |
if($("#photos-conteneur #miniatures .miniature").length == 1 && ! lthis.avertissementDeuxPhotosAffiche) {
|
|
|
50 |
messageAvertissement = "Attention: \n"+
|
|
|
51 |
"Sélectionnez uniquement les photos correspondantes à une seule plante \n"+
|
|
|
52 |
"(c'est à dire correspondant à un seul individu d'une espèce donnée) \n"+
|
|
|
53 |
"vue dans le tronçon de rue inventoriée ";
|
|
|
54 |
if(window.confirm(messageAvertissement)) {
|
|
|
55 |
lthis.avertissementDeuxPhotosAffiche = true;
|
|
|
56 |
return true;
|
|
|
57 |
} else {
|
|
|
58 |
return false;
|
1916 |
jpm |
59 |
}
|
2697 |
mathias |
60 |
}
|
|
|
61 |
if ($(this).val().length > 0) {
|
|
|
62 |
arreter(event);
|
|
|
63 |
var options = {
|
|
|
64 |
success: lthis.afficherMiniature.bind(lthis), // post-submit callback
|
|
|
65 |
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
|
|
|
66 |
resetForm: true // reset the form after successful submit
|
|
|
67 |
};
|
|
|
68 |
$('#miniature').append(
|
|
|
69 |
'<img id="miniature-chargement" class="miniature" alt="chargement" src="'+CHARGEMENT_IMAGE_URL+'"/>');
|
|
|
70 |
$('#ajouter-obs').attr('disabled', 'disabled');
|
|
|
71 |
if (lthis.verifierFormat($(this).val())) {
|
|
|
72 |
$('#form-upload').ajaxSubmit(options);
|
|
|
73 |
} else {
|
|
|
74 |
$('#form-upload')[0].reset();
|
|
|
75 |
window.alert("Le format de fichier n'est pas supporté, les formats acceptés sont "+ $('#fichier').attr('accept'));
|
|
|
76 |
}
|
|
|
77 |
return false;
|
|
|
78 |
}
|
1916 |
jpm |
79 |
});
|
|
|
80 |
|
2697 |
mathias |
81 |
$('.cb-milieux').on('click', function(event) {
|
|
|
82 |
$(this).valid();
|
|
|
83 |
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 |
});
|
|
|
93 |
$('#transmettre-obs').on('click', this.transmettreObs.bind(this));
|
1956 |
jpm |
94 |
|
2697 |
mathias |
95 |
// Défilement des photos
|
|
|
96 |
$('body').on('click', '.defilement-control-zone', function(event) {
|
|
|
97 |
lthis.defilerMiniatures($(this));
|
|
|
98 |
});
|
|
|
99 |
$('body').on('mouseover', '.defilement-control-zone', function(event) {
|
|
|
100 |
$('.defilement-control', this).removeClass('hidden');
|
|
|
101 |
});
|
|
|
102 |
$('body').on('mouseout', '.defilement-control-zone', function(event) {
|
|
|
103 |
$('.defilement-control', this).addClass('hidden');
|
|
|
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));
|
1916 |
jpm |
111 |
|
2697 |
mathias |
112 |
$('#photo-placeholder').click(function(event) {
|
|
|
113 |
$('#fichier').click();
|
|
|
114 |
});
|
1916 |
jpm |
115 |
|
2697 |
mathias |
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 |
});
|
1916 |
jpm |
123 |
|
1922 |
jpm |
124 |
// Autocompletion du champ adresse
|
|
|
125 |
$('#carte-recherche').on('focus', function() {
|
|
|
126 |
$(this).select();
|
1346 |
aurelien |
127 |
});
|
1922 |
jpm |
128 |
$('#carte-recherche').on('mouseup', function(event) {// Pour Safari...
|
|
|
129 |
event.preventDefault();
|
|
|
130 |
});
|
|
|
131 |
$('#carte-recherche').keypress(function(e) {
|
|
|
132 |
if (e.which == 13) {
|
|
|
133 |
e.preventDefault();
|
|
|
134 |
}
|
1054 |
jpm |
135 |
});
|
1922 |
jpm |
136 |
$('#carte-recherche').autocomplete({
|
1346 |
aurelien |
137 |
//Cette partie utilise geocoder pour extraire des valeurs d'adresse
|
|
|
138 |
source: function(request, response) {
|
2697 |
mathias |
139 |
lthis.geocoder.geocode( {'address': request.term+', France', 'region' : 'fr' }, function(results, status) {
|
1346 |
aurelien |
140 |
if (status == google.maps.GeocoderStatus.OK) {
|
1054 |
jpm |
141 |
response($.map(results, function(item) {
|
1956 |
jpm |
142 |
var rue = "";
|
|
|
143 |
$.each(item.address_components, function(){
|
|
|
144 |
if (this.types[0] == "route" || this.types[0] == "street_address" ) {
|
|
|
145 |
rue = this.short_name;
|
|
|
146 |
}
|
|
|
147 |
});
|
1346 |
aurelien |
148 |
var retour = {
|
|
|
149 |
label: item.formatted_address,
|
1956 |
jpm |
150 |
value: rue,
|
1054 |
jpm |
151 |
latitude: item.geometry.location.lat(),
|
|
|
152 |
longitude: item.geometry.location.lng()
|
1346 |
aurelien |
153 |
};
|
|
|
154 |
return retour;
|
1054 |
jpm |
155 |
}));
|
1346 |
aurelien |
156 |
} else {
|
2697 |
mathias |
157 |
lthis.afficherErreurGoogleMap(status);
|
1054 |
jpm |
158 |
}
|
|
|
159 |
});
|
1346 |
aurelien |
160 |
},
|
|
|
161 |
// Cette partie est executee a la selection d'une adresse
|
|
|
162 |
select: function(event, ui) {
|
1922 |
jpm |
163 |
var nouvellePosition = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
|
2697 |
mathias |
164 |
lthis.initialiserMarkerDeb();
|
|
|
165 |
lthis.deplacerMarkerDeb(nouvellePosition);
|
|
|
166 |
lthis.map.setZoom(16);
|
|
|
167 |
lthis.afficherEtapeGeolocalisation(2);
|
1346 |
aurelien |
168 |
}
|
1054 |
jpm |
169 |
});
|
2697 |
mathias |
170 |
$('#geolocaliser').on('click', this.geolocaliser.bind(this));
|
|
|
171 |
}
|
2408 |
jpm |
172 |
|
1922 |
jpm |
173 |
|
2697 |
mathias |
174 |
WidgetSaisieSauvages.prototype.montrerFormIdentite = function() {
|
|
|
175 |
$('#zone-courriel-confirmation, #zone-prenom-nom').css('display', 'block');
|
|
|
176 |
}
|
|
|
177 |
|
|
|
178 |
// surcharge
|
|
|
179 |
WidgetSaisieSauvages.prototype.initialiserGoogleMap = function() {
|
|
|
180 |
var lthis = this;
|
|
|
181 |
this.latLngDeb = new google.maps.LatLng(48.8543, 2.3483);// Paris
|
1946 |
jpm |
182 |
if (VILLE == 'Marseille') {
|
2697 |
mathias |
183 |
this.latLngDeb = new google.maps.LatLng(43.29545, 5.37458);
|
1946 |
jpm |
184 |
} else if (VILLE == 'Montpellier') {
|
2697 |
mathias |
185 |
this.latLngDeb = new google.maps.LatLng(43.61077, 3.87672);
|
1946 |
jpm |
186 |
}
|
1922 |
jpm |
187 |
var options = {
|
1946 |
jpm |
188 |
zoom: 16,
|
2697 |
mathias |
189 |
center: this.latLngDeb,
|
1922 |
jpm |
190 |
mapTypeId: google.maps.MapTypeId.HYBRID,
|
|
|
191 |
mapTypeControlOptions: {
|
2408 |
jpm |
192 |
mapTypeIds: ['OSM',
|
|
|
193 |
google.maps.MapTypeId.ROADMAP,
|
|
|
194 |
google.maps.MapTypeId.HYBRID,
|
|
|
195 |
google.maps.MapTypeId.SATELLITE,
|
1922 |
jpm |
196 |
google.maps.MapTypeId.TERRAIN]}
|
|
|
197 |
};
|
2408 |
jpm |
198 |
|
1922 |
jpm |
199 |
// Ajout de la couche OSM à la carte
|
|
|
200 |
osmMapType = new google.maps.ImageMapType({
|
|
|
201 |
getTileUrl: function(coord, zoom) {
|
|
|
202 |
return 'http://tile.openstreetmap.org/' + zoom + '/' + coord.x + '/' + coord.y + '.png';
|
|
|
203 |
},
|
|
|
204 |
tileSize: new google.maps.Size(256, 256),
|
|
|
205 |
isPng: true,
|
|
|
206 |
alt: 'OpenStreetMap',
|
|
|
207 |
name: 'OSM',
|
|
|
208 |
maxZoom: 19
|
1346 |
aurelien |
209 |
});
|
2408 |
jpm |
210 |
|
1922 |
jpm |
211 |
// Création de la carte Google
|
2697 |
mathias |
212 |
this.map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
|
|
|
213 |
this.map.mapTypes.set('OSM', osmMapType);
|
2408 |
jpm |
214 |
|
1922 |
jpm |
215 |
// Ajout de l'évènment sur click dans Carte
|
2697 |
mathias |
216 |
google.maps.event.addListener(this.map, 'click', this.surClickDansCarte.bind(this));
|
2408 |
jpm |
217 |
|
1922 |
jpm |
218 |
// Lorsque la carte est chargée, on vérifie si on peut précharger des données
|
2697 |
mathias |
219 |
google.maps.event.addListenerOnce(this.map, 'idle', function(){
|
1922 |
jpm |
220 |
// Initialisation du marker de début de rue
|
2697 |
mathias |
221 |
lthis.initialiserMarkerDeb();
|
2256 |
aurelien |
222 |
if (OBS_ID != '') {
|
2697 |
mathias |
223 |
lthis.chargerInfoObs();
|
2256 |
aurelien |
224 |
} else {
|
|
|
225 |
// Tentative de geocalisation si aucune obs à précharger
|
2697 |
mathias |
226 |
lthis.tenterGeolocalisation();
|
2256 |
aurelien |
227 |
}
|
1346 |
aurelien |
228 |
});
|
2408 |
jpm |
229 |
|
1922 |
jpm |
230 |
// Création du Geocoder
|
2697 |
mathias |
231 |
this.geocoder = new google.maps.Geocoder();
|
1922 |
jpm |
232 |
}
|
1054 |
jpm |
233 |
|
2697 |
mathias |
234 |
// surcharge
|
|
|
235 |
WidgetSaisieSauvages.prototype.prechargerForm = function(data) {
|
2256 |
aurelien |
236 |
|
|
|
237 |
$('#carte-recherche').val(data.zoneGeo);
|
|
|
238 |
$('#commune-nom').text(data.zoneGeo);
|
2408 |
jpm |
239 |
|
2257 |
aurelien |
240 |
if(data.hasOwnProperty("codeZoneGeo")) {
|
|
|
241 |
$('#commune-code-insee').text(data.codeZoneGeo.replace('INSEE-C:', ''));
|
|
|
242 |
}
|
2408 |
jpm |
243 |
|
2697 |
mathias |
244 |
var pos = new google.maps.LatLng(data.latitude, data.longitude);
|
2408 |
jpm |
245 |
|
2256 |
aurelien |
246 |
if(data.hasOwnProperty("extension")) {
|
2697 |
mathias |
247 |
this.initialiserMarkerFin();
|
2408 |
jpm |
248 |
|
2256 |
aurelien |
249 |
// cas des obs florilèges qui apparaissent aussi comme des obs sauvages
|
|
|
250 |
// mais qui n'ont pas de coté de rue
|
|
|
251 |
if(data.extension.hasOwnProperty("coteRue")) {
|
|
|
252 |
$('#rue_cote option[value='+data.extension.coteRue.valeur+']').attr("selected", "selected");
|
|
|
253 |
}
|
2408 |
jpm |
254 |
|
2697 |
mathias |
255 |
var deb = new google.maps.LatLng(data.extension.latitudeDebutRue.valeur, data.extension.longitudeDebutRue.valeur);
|
|
|
256 |
var fin = new google.maps.LatLng(data.extension.latitudeFinRue.valeur, data.extension.longitudeFinRue.valeur);
|
2408 |
jpm |
257 |
|
2697 |
mathias |
258 |
this.mettreAJourStationPosition(pos);
|
2408 |
jpm |
259 |
|
2697 |
mathias |
260 |
this.deplacerMarkerDeb(deb);
|
|
|
261 |
this.deplacerMarkerFin(fin);
|
|
|
262 |
this.afficherEtapeGeolocalisation(4);
|
2408 |
jpm |
263 |
|
2256 |
aurelien |
264 |
var latlngbounds = new google.maps.LatLngBounds();
|
|
|
265 |
latlngbounds.extend(deb);
|
|
|
266 |
latlngbounds.extend(fin);
|
2697 |
mathias |
267 |
this.map.setCenter(latlngbounds.getCenter());
|
|
|
268 |
this.map.fitBounds(latlngbounds);
|
2256 |
aurelien |
269 |
} else if(data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
|
2697 |
mathias |
270 |
this.deplacerMarkerDeb(pos);
|
2256 |
aurelien |
271 |
}
|
|
|
272 |
}
|
|
|
273 |
|
2697 |
mathias |
274 |
WidgetSaisieSauvages.prototype.initialiserMarkerDeb = function() {
|
|
|
275 |
this.premierDeplacement = true;
|
|
|
276 |
if (this.markerDeb == undefined) {
|
1922 |
jpm |
277 |
// Marqueur de début de Rue
|
2697 |
mathias |
278 |
this.markerDeb = new google.maps.Marker({
|
|
|
279 |
map: this.map,
|
1922 |
jpm |
280 |
draggable: true,
|
|
|
281 |
title: 'Début de la portion de rue étudiée',
|
|
|
282 |
icon: GOOGLE_MAP_MARQUEUR_DEBUT_URL,
|
2697 |
mathias |
283 |
position: this.latLngDeb
|
1922 |
jpm |
284 |
});
|
2697 |
mathias |
285 |
google.maps.event.addListener(this.markerDeb, 'dragend', this.surDeplacementMarkerDeb.bind(this));
|
1922 |
jpm |
286 |
}
|
2408 |
jpm |
287 |
|
2697 |
mathias |
288 |
this.latLngFin = this.latLngDeb;
|
|
|
289 |
if (this.markerFin != undefined) {
|
|
|
290 |
this.markerFin.setMap(null);
|
1922 |
jpm |
291 |
}
|
2697 |
mathias |
292 |
this.latLngCentre = this.latLngDeb;
|
|
|
293 |
if (this.ligneRue != undefined) {
|
|
|
294 |
this.ligneRue.setMap(null);
|
1922 |
jpm |
295 |
}
|
1346 |
aurelien |
296 |
}
|
|
|
297 |
|
2697 |
mathias |
298 |
WidgetSaisieSauvages.prototype.surDeplacementMarkerDeb = function() {
|
|
|
299 |
this.deplacerMarkerDeb(this.markerDeb.getPosition());
|
1346 |
aurelien |
300 |
}
|
|
|
301 |
|
2697 |
mathias |
302 |
WidgetSaisieSauvages.prototype.deplacerMarkerDeb = function(nouvellePosition) {
|
|
|
303 |
this.latLngDeb = nouvellePosition;
|
|
|
304 |
this.markerDeb.setPosition(this.latLngDeb);
|
|
|
305 |
this.map.setCenter(this.latLngDeb);
|
|
|
306 |
this.mettreAJourStationPosition(this.latLngDeb);
|
|
|
307 |
this.trouverCommune(this.latLngDeb);
|
1922 |
jpm |
308 |
|
2697 |
mathias |
309 |
if (this.premierDeplacement) {
|
|
|
310 |
this.initialiserMarkerDeb();
|
|
|
311 |
this.premierDeplacement = false;
|
1922 |
jpm |
312 |
} else {
|
2697 |
mathias |
313 |
var nouvellePositionFin = new google.maps.LatLng(this.latLngDeb.lat(), this.latLngDeb.lng() + 0.0010);
|
|
|
314 |
this.initialiserMarkerFin();
|
|
|
315 |
this.deplacerMarkerFin(nouvellePositionFin)
|
|
|
316 |
this.afficherEtapeGeolocalisation(3);
|
1346 |
aurelien |
317 |
}
|
|
|
318 |
}
|
|
|
319 |
|
2697 |
mathias |
320 |
WidgetSaisieSauvages.prototype.initialiserMarkerFin = function() {
|
|
|
321 |
if (this.markerFin == undefined) {
|
|
|
322 |
this.markerFin = new google.maps.Marker({
|
|
|
323 |
map: this.map,
|
1922 |
jpm |
324 |
draggable: true,
|
|
|
325 |
title: 'Fin de la portion de rue étudiée',
|
|
|
326 |
icon: GOOGLE_MAP_MARQUEUR_FIN_URL,
|
2697 |
mathias |
327 |
position: this.latLngFin
|
1922 |
jpm |
328 |
});
|
2697 |
mathias |
329 |
google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
|
1922 |
jpm |
330 |
} else {
|
2697 |
mathias |
331 |
this.markerFin.setMap(null);
|
1346 |
aurelien |
332 |
}
|
|
|
333 |
}
|
|
|
334 |
|
2697 |
mathias |
335 |
WidgetSaisieSauvages.prototype.deplacerMarkerFin = function(nouvellePosition) {
|
|
|
336 |
this.latLngFin = nouvellePosition;
|
|
|
337 |
this.markerFin.setMap(this.map);
|
|
|
338 |
this.markerFin.setPosition(this.latLngFin);
|
|
|
339 |
this.dessinerLigneRue(this.latLngDeb, this.latLngFin);
|
1922 |
jpm |
340 |
}
|
|
|
341 |
|
2697 |
mathias |
342 |
WidgetSaisieSauvages.prototype.surDeplacementMarkerFin = function() {
|
|
|
343 |
this.dessinerLigneRue(this.markerDeb.getPosition(), this.markerFin.getPosition());
|
|
|
344 |
this.afficherCentreRue();
|
|
|
345 |
this.afficherEtapeGeolocalisation(4);
|
1922 |
jpm |
346 |
}
|
|
|
347 |
|
2697 |
mathias |
348 |
WidgetSaisieSauvages.prototype.dessinerLigneRue = function(pointDebut, pointFin) {
|
|
|
349 |
if (this.ligneRue != undefined) {
|
|
|
350 |
this.ligneRue.setMap(null);
|
1346 |
aurelien |
351 |
}
|
2408 |
jpm |
352 |
|
2697 |
mathias |
353 |
this.ligneRue = new google.maps.Polyline({
|
1922 |
jpm |
354 |
path: [pointDebut, pointFin],
|
|
|
355 |
strokeColor: "#FF0000",
|
|
|
356 |
strokeOpacity: 1.0,
|
|
|
357 |
strokeWeight: 2
|
|
|
358 |
});
|
1346 |
aurelien |
359 |
|
2697 |
mathias |
360 |
this.ligneRue.setMap(this.map);
|
1346 |
aurelien |
361 |
}
|
|
|
362 |
|
2697 |
mathias |
363 |
WidgetSaisieSauvages.prototype.afficherCentreRue = function() {
|
|
|
364 |
this.latLngDeb = this.markerDeb.getPosition();
|
|
|
365 |
this.latLngFin = this.markerFin.getPosition();
|
|
|
366 |
this.latLngCentre = new google.maps.LatLng((this.latLngFin.lat() + this.latLngDeb.lat())/2, (this.latLngFin.lng() + this.latLngDeb.lng())/2);
|
|
|
367 |
this.mettreAJourStationPosition(this.latLngCentre);
|
1922 |
jpm |
368 |
}
|
|
|
369 |
|
2697 |
mathias |
370 |
WidgetSaisieSauvages.prototype.mettreAJourStationPosition = function(latLng) {
|
1922 |
jpm |
371 |
var lat = latLng.lat().toFixed(5),
|
2408 |
jpm |
372 |
lng = latLng.lng().toFixed(5);
|
2697 |
mathias |
373 |
this.remplirChampLatitude(lat);
|
|
|
374 |
this.remplirChampLongitude(lng);
|
1346 |
aurelien |
375 |
}
|
|
|
376 |
|
2697 |
mathias |
377 |
WidgetSaisieSauvages.prototype.afficherEtapeGeolocalisation = function(numEtape) {
|
1922 |
jpm |
378 |
$('.liste_indication_geolocalisation').children().hide();
|
|
|
379 |
$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show();
|
|
|
380 |
}
|
|
|
381 |
|
2697 |
mathias |
382 |
// surcharge
|
|
|
383 |
WidgetSaisieSauvages.prototype.geolocaliser = function(event) {
|
1922 |
jpm |
384 |
var latitude = $('#latitude').val(),
|
|
|
385 |
longitude = $('#longitude').val(),
|
|
|
386 |
nouvellePosition = new google.maps.LatLng(latitude, longitude);
|
2697 |
mathias |
387 |
this.initialiserMarkerDeb();
|
|
|
388 |
this.deplacerMarkerDeb(nouvellePosition);
|
|
|
389 |
this.afficherEtapeGeolocalisation(2);
|
|
|
390 |
this.map.setZoom(16);
|
1922 |
jpm |
391 |
arreter(event);
|
|
|
392 |
}
|
|
|
393 |
|
2697 |
mathias |
394 |
WidgetSaisieSauvages.prototype.tenterGeolocalisation = function() {
|
1922 |
jpm |
395 |
if (navigator.geolocation) {
|
|
|
396 |
navigator.geolocation.getCurrentPosition(function(position) {
|
|
|
397 |
var latitude = position.coords.latitude,
|
|
|
398 |
longitude = position.coords.longitude,
|
|
|
399 |
nouvellePosition = new google.maps.LatLng(latitude, longitude);
|
2697 |
mathias |
400 |
this.initialiserMarkerDeb();
|
|
|
401 |
this.deplacerMarkerDeb(nouvellePosition);
|
|
|
402 |
this.map.setZoom(16);
|
1922 |
jpm |
403 |
});
|
|
|
404 |
}
|
|
|
405 |
}
|
|
|
406 |
|
2697 |
mathias |
407 |
/**
|
|
|
408 |
* AUTO-COMPLÉTION Noms Scientifiques => OK
|
|
|
409 |
* sélectionne un nom et puis qu'on le remplacer par un nom non valide
|
|
|
410 |
* Garder la trace de la valeur permet de vider le nn lorsqu'on
|
|
|
411 |
*/
|
|
|
412 |
WidgetSaisieSauvages.prototype.ajouterAutocompletionNoms = function() {
|
|
|
413 |
var lthis = this;
|
1922 |
jpm |
414 |
$('#taxon').autocomplete({
|
2408 |
jpm |
415 |
source: function(requete, add){
|
1922 |
jpm |
416 |
// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
|
2408 |
jpm |
417 |
|
2697 |
mathias |
418 |
var url = lthis.getUrlAutocompletionNomsSci();
|
1922 |
jpm |
419 |
$.getJSON(url, function(data) {
|
2697 |
mathias |
420 |
var suggestions = lthis.traiterRetourNomsSci(data);
|
2408 |
jpm |
421 |
add(suggestions);
|
1922 |
jpm |
422 |
});
|
|
|
423 |
},
|
|
|
424 |
html: true
|
|
|
425 |
});
|
2408 |
jpm |
426 |
|
1922 |
jpm |
427 |
$('#taxon').bind('autocompleteselect', function(event, ui) {
|
|
|
428 |
$('#taxon').data(ui.item);
|
2697 |
mathias |
429 |
lthis.valeurChamp = $('#taxon').val();
|
1922 |
jpm |
430 |
if (ui.item.retenu == true) {
|
|
|
431 |
$('#taxon').addClass('ns-retenu');
|
|
|
432 |
} else {
|
|
|
433 |
$('#taxon').removeClass('ns-retenu');
|
|
|
434 |
}
|
|
|
435 |
});
|
2529 |
aurelien |
436 |
|
|
|
437 |
$('#taxon').bind('keypress', function() {
|
2697 |
mathias |
438 |
if(lthis.valeurChamp != $('#taxon').val()) {
|
2529 |
aurelien |
439 |
$('#taxon').data('numNomSel', '');
|
|
|
440 |
}
|
2697 |
mathias |
441 |
lthis.valeurChamp = $('#taxon').val();
|
2529 |
aurelien |
442 |
});
|
1922 |
jpm |
443 |
}
|
|
|
444 |
|
2697 |
mathias |
445 |
WidgetSaisieSauvages.prototype.getUrlAutocompletionNomsSci = function() {
|
1922 |
jpm |
446 |
var mots = $('#taxon').val(),
|
2408 |
jpm |
447 |
url = SERVICE_AUTOCOMPLETION_NOM_SCI_URL_TPL.replace('{referentiel}',NOM_SCI_REFERENTIEL);
|
1922 |
jpm |
448 |
url = url.replace('{masque}', mots);
|
|
|
449 |
return url;
|
|
|
450 |
}
|
|
|
451 |
|
2697 |
mathias |
452 |
WidgetSaisieSauvages.prototype.traiterRetourNomsSci = function(data) {
|
1922 |
jpm |
453 |
var suggestions = [];
|
|
|
454 |
if (data.resultat != undefined) {
|
|
|
455 |
$.each(data.resultat, function(i, val) {
|
|
|
456 |
val.nn = i;
|
|
|
457 |
var nom = {label: '', value: '', nt: '', nomSel: '', nomSelComplet: '', numNomSel: '',
|
|
|
458 |
nomRet: '', numNomRet: '', famille: '', retenu: false
|
|
|
459 |
};
|
|
|
460 |
if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
|
|
|
461 |
nom.label = '...';
|
|
|
462 |
nom.value = $('#taxon').val();
|
|
|
463 |
suggestions.push(nom);
|
|
|
464 |
return false;
|
|
|
465 |
} else {
|
|
|
466 |
nom.label = val.nom_sci_complet;
|
|
|
467 |
nom.value = val.nom_sci_complet;
|
|
|
468 |
nom.nt = val.num_taxonomique;
|
|
|
469 |
nom.nomSel = val.nom_sci;
|
|
|
470 |
nom.nomSelComplet = val.nom_sci_complet;
|
|
|
471 |
nom.numNomSel = val.nn;
|
|
|
472 |
nom.nomRet = val.nom_retenu_complet;
|
|
|
473 |
nom.numNomRet = val['nom_retenu.id'];
|
|
|
474 |
nom.famille = val.famille;
|
|
|
475 |
nom.retenu = (val.retenu == 'false') ? false : true;
|
2408 |
jpm |
476 |
|
1922 |
jpm |
477 |
suggestions.push(nom);
|
|
|
478 |
}
|
|
|
479 |
});
|
|
|
480 |
}
|
|
|
481 |
return suggestions;
|
|
|
482 |
}
|
|
|
483 |
|
2697 |
mathias |
484 |
WidgetSaisieSauvages.prototype.supprimerMiniature = function(miniature) {
|
1922 |
jpm |
485 |
miniature.parents('.miniature').remove();
|
|
|
486 |
}
|
|
|
487 |
|
2697 |
mathias |
488 |
// surcharge
|
|
|
489 |
WidgetSaisieSauvages.prototype.configurerFormValidator = function() {
|
1916 |
jpm |
490 |
$.validator.addMethod(
|
2408 |
jpm |
491 |
'dateCel',
|
|
|
492 |
function (value, element) {
|
|
|
493 |
return value == '' || (/^[0-9]{2}[-\/][0-9]{2}[-\/][0-9]{4}$/.test(value));
|
|
|
494 |
},
|
1916 |
jpm |
495 |
'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.');
|
2408 |
jpm |
496 |
|
1916 |
jpm |
497 |
$.extend($.validator.defaults, {
|
|
|
498 |
ignore: [],// Forcer Jquery Validate à examiner les éléments avec en display:none;
|
|
|
499 |
highlight: function(element) {
|
|
|
500 |
$(element).closest('.control-group').removeClass('success').addClass('error');
|
|
|
501 |
},
|
|
|
502 |
success: function(element) {
|
|
|
503 |
element.text('OK!').addClass('valid');
|
|
|
504 |
element.closest('.control-group').removeClass('error').addClass('success');
|
2408 |
jpm |
505 |
|
1916 |
jpm |
506 |
if (element.attr('id') == 'taxon' && $('#taxon').val() != '') {
|
|
|
507 |
// Si le taxon n'est pas lié au référentiel, on vide le data associé
|
|
|
508 |
if ($('#taxon').data('value') != $('#taxon').val()) {
|
|
|
509 |
$('#taxon').data('numNomSel', '');
|
|
|
510 |
$('#taxon').data('nomRet', '');
|
|
|
511 |
$('#taxon').data('numNomRet', '');
|
|
|
512 |
$('#taxon').data('nt', '');
|
|
|
513 |
$('#taxon').data('famille', '');
|
|
|
514 |
}
|
|
|
515 |
}
|
|
|
516 |
}
|
|
|
517 |
});
|
|
|
518 |
}
|
|
|
519 |
|
2697 |
mathias |
520 |
// surcharge
|
|
|
521 |
WidgetSaisieSauvages.prototype.definirReglesFormValidator = function() {
|
1916 |
jpm |
522 |
$('#form-observateur').validate({
|
|
|
523 |
rules: {
|
|
|
524 |
courriel: {
|
|
|
525 |
required: true,
|
|
|
526 |
email: true},
|
|
|
527 |
courriel_confirmation: {
|
|
|
528 |
required: true,
|
|
|
529 |
equalTo: '#courriel'},
|
|
|
530 |
prenom: {
|
|
|
531 |
required: true},
|
|
|
532 |
nom: {
|
|
|
533 |
required: true}
|
|
|
534 |
}
|
|
|
535 |
});
|
|
|
536 |
$('#form-obs').validate({
|
|
|
537 |
rules: {
|
|
|
538 |
station: {
|
|
|
539 |
required: true},
|
|
|
540 |
latitude : {
|
|
|
541 |
required: true,
|
|
|
542 |
range: [-90, 90]},
|
|
|
543 |
longitude: {
|
|
|
544 |
required: true,
|
|
|
545 |
range: [-180, 180]},
|
|
|
546 |
date: {
|
|
|
547 |
required: true,
|
|
|
548 |
'dateCel' : true},
|
1956 |
jpm |
549 |
coteRue: {
|
1916 |
jpm |
550 |
required: true},
|
|
|
551 |
'taxon-liste': {
|
|
|
552 |
required: true},
|
|
|
553 |
'milieux[]': {
|
|
|
554 |
required: true,
|
|
|
555 |
minlength: 1}
|
|
|
556 |
},
|
|
|
557 |
errorPlacement: function(error, element) {
|
|
|
558 |
if (element.attr('name') == 'date') {
|
|
|
559 |
element.parent('.input-prepend').after(error);
|
|
|
560 |
} else if (element.attr('name') == 'milieux[]') {
|
|
|
561 |
error.insertAfter('#milieux-controls');
|
|
|
562 |
} else {
|
|
|
563 |
error.insertAfter(element);
|
|
|
564 |
}
|
|
|
565 |
},
|
|
|
566 |
messages: {
|
|
|
567 |
'milieu[]': 'Vous devez sélectionner au moins un milieu'
|
|
|
568 |
}
|
|
|
569 |
});
|
|
|
570 |
}
|
|
|
571 |
|
2697 |
mathias |
572 |
WidgetSaisieSauvages.prototype.validerFormulaire = function() {
|
1946 |
jpm |
573 |
var observateur = $('#form-observateur').valid(),
|
|
|
574 |
obs = $('#form-obs').valid(),
|
2697 |
mathias |
575 |
debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
|
|
|
576 |
finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
|
1946 |
jpm |
577 |
var ok = (observateur && obs && debRue && finRue) ? true : false;
|
1964 |
jpm |
578 |
//console.log('observateur:'+observateur+'-obs:'+obs+'-debRue:'+debRue+'('+latLngDeb+')-finRue:'+finRue+'('+latLngDeb+')');
|
1946 |
jpm |
579 |
return ok;
|
|
|
580 |
}
|
|
|
581 |
|
2697 |
mathias |
582 |
WidgetSaisieSauvages.prototype.surChangementTaxonListe = function() {
|
1916 |
jpm |
583 |
if ($('#taxon-liste').val() === '?') {
|
|
|
584 |
$('#taxon-input-groupe').removeClass('hidden');
|
|
|
585 |
} else {
|
|
|
586 |
$('#taxon-input-groupe').addClass('hidden');
|
|
|
587 |
}
|
|
|
588 |
}
|
|
|
589 |
|
2697 |
mathias |
590 |
WidgetSaisieSauvages.prototype.surChangementValeurTaxon = function() {
|
2529 |
aurelien |
591 |
var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
|
2697 |
mathias |
592 |
var nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special');
|
|
|
593 |
var numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val();
|
2529 |
aurelien |
594 |
|
|
|
595 |
// Un nom non valide entraine automatiquement une certitude "à déterminer"
|
|
|
596 |
if(nomSpecial || !numNomSel) {
|
|
|
597 |
$('#certitude-adeterminer').attr('checked', 'checked');
|
|
|
598 |
} else {
|
|
|
599 |
$('#certitude-adeterminer').removeAttr('checked');
|
|
|
600 |
}
|
|
|
601 |
}
|
|
|
602 |
|
2697 |
mathias |
603 |
// surcharge
|
|
|
604 |
WidgetSaisieSauvages.prototype.configurerDatePicker = function(selector) {
|
1916 |
jpm |
605 |
$.datepicker.setDefaults($.datepicker.regional['fr']);
|
|
|
606 |
$(selector).datepicker({
|
|
|
607 |
dateFormat: 'dd/mm/yy',
|
1990 |
jpm |
608 |
maxDate: new Date,
|
1916 |
jpm |
609 |
showOn: 'button',
|
|
|
610 |
buttonImageOnly: true,
|
|
|
611 |
buttonImage: CALENDRIER_ICONE_URL,
|
|
|
612 |
buttonText: 'Afficher le calendrier pour saisir la date.',
|
|
|
613 |
showButtonPanel: true,
|
|
|
614 |
onSelect: function(date) {
|
|
|
615 |
$(this).valid();
|
|
|
616 |
}
|
|
|
617 |
});
|
|
|
618 |
$(selector + ' + img.ui-datepicker-trigger').appendTo(selector + '-icone.add-on');
|
|
|
619 |
}
|
|
|
620 |
|
2697 |
mathias |
621 |
// surcharge @TODO uniformiser .has-tooltip & rel="tooltip"
|
|
|
622 |
WidgetSaisieSauvages.prototype.basculerAffichageAide = function() {
|
1922 |
jpm |
623 |
if ($(this).hasClass('btn-warning')) {
|
|
|
624 |
$('.has-tooltip').tooltip('enable');
|
|
|
625 |
$(this).removeClass('btn-warning').addClass('btn-success');
|
|
|
626 |
$('#btn-aide-txt', this).text("Désactiver l'aide");
|
|
|
627 |
} else {
|
|
|
628 |
$('.has-tooltip').tooltip('disable');
|
|
|
629 |
$(this).removeClass('btn-success').addClass('btn-warning');
|
|
|
630 |
$('#btn-aide-txt', this).text("Activer l'aide");
|
1346 |
aurelien |
631 |
}
|
|
|
632 |
}
|
1054 |
jpm |
633 |
|
2697 |
mathias |
634 |
// surcharge
|
|
|
635 |
WidgetSaisieSauvages.prototype.ajouterObs = function() {
|
|
|
636 |
if (this.validerFormulaire() == true) {
|
|
|
637 |
this.obsNbre = this.obsNbre + 1;
|
|
|
638 |
$('.obs-nbre').text(this.obsNbre);
|
1922 |
jpm |
639 |
$('.obs-nbre').triggerHandler('changement');
|
2697 |
mathias |
640 |
this.afficherObs();
|
|
|
641 |
this.stockerObsData();
|
|
|
642 |
this.supprimerMiniatures();
|
1922 |
jpm |
643 |
} else {
|
1956 |
jpm |
644 |
// Affichage de tous les panneau cachés avec champ obligatoire
|
2697 |
mathias |
645 |
var debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
|
|
|
646 |
finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
|
1922 |
jpm |
647 |
if (debRue == false || finRue == false) {
|
|
|
648 |
afficherPanneau('#dialogue-form-invalide-rue');
|
|
|
649 |
} else {
|
1956 |
jpm |
650 |
afficherPanneau('#dialogue-form-invalide');
|
1922 |
jpm |
651 |
}
|
2697 |
mathias |
652 |
this.montrerFormIdentite();
|
1922 |
jpm |
653 |
}
|
2697 |
mathias |
654 |
};
|
1922 |
jpm |
655 |
|
2697 |
mathias |
656 |
// surcharge
|
|
|
657 |
WidgetSaisieSauvages.prototype.afficherObs = function() {
|
1922 |
jpm |
658 |
var numNomSel = ($('#taxon-liste').val() == '?') ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
|
|
|
659 |
nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
|
|
|
660 |
taxon = ($('#taxon-liste').val() == '?') ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
|
2408 |
jpm |
661 |
referentiel = (numNomSel == undefined) ? '' : '['+NOM_SCI_REFERENTIEL+']',
|
1922 |
jpm |
662 |
commune = $('#commune-nom').text(),
|
|
|
663 |
codeInsee = $('#commune-code-insee').text(),
|
1946 |
jpm |
664 |
station = $('input[name="adresse"]').val(),
|
1922 |
jpm |
665 |
lat = $('input[name="latitude"]').val(),
|
|
|
666 |
lng = $('input[name="longitude"]').val(),
|
|
|
667 |
date = $('#date').val(),
|
2697 |
mathias |
668 |
milieux = this.getMilieux(),
|
|
|
669 |
notes = (nomSpecial ? this.taxons[numNomSel]['nom_fr'] + ".<br />" : '') + $('#notes').val();
|
2408 |
jpm |
670 |
|
1922 |
jpm |
671 |
$('#liste-obs').prepend(
|
2697 |
mathias |
672 |
'<div id="obs'+this.obsNbre+'" class="row-fluid obs obs'+this.obsNbre+'">' +
|
1946 |
jpm |
673 |
'<div class="span12">' +
|
|
|
674 |
'<div class="well">' +
|
|
|
675 |
'<div class="obs-action pull-right has-tooltip" data-placement="bottom" ' +
|
|
|
676 |
'title="Supprimer cette observation de la liste à transmettre">' +
|
2697 |
mathias |
677 |
'<button class="btn btn-danger supprimer-obs" value="'+this.obsNbre+'" title="'+this.obsNbre+'">' +
|
1946 |
jpm |
678 |
'<i class="icon-trash icon-white"></i>' +
|
|
|
679 |
'</button>' +
|
2408 |
jpm |
680 |
'</div> ' +
|
|
|
681 |
'<div class="row-fluid">' +
|
1946 |
jpm |
682 |
'<div class="span2 obs-miniatures">' +
|
2697 |
mathias |
683 |
this.ajouterImgMiniatureAuTransfert() +
|
1922 |
jpm |
684 |
'</div>'+
|
1946 |
jpm |
685 |
'<div class="span7">' +
|
|
|
686 |
'<ul class="unstyled">' +
|
1922 |
jpm |
687 |
'<li>'+
|
|
|
688 |
'<span class="nom-sci">' + taxon + '</span> ' +
|
2697 |
mathias |
689 |
this.formaterNumNomSel(numNomSel) +
|
1946 |
jpm |
690 |
' observé à <br />' +
|
1993 |
jpm |
691 |
'<span class="commune">' + commune + '</span> ' +
|
|
|
692 |
'(' + codeInsee + '), ' +
|
1946 |
jpm |
693 |
'<span class="station">' + station + '</span><br /> ' +
|
1922 |
jpm |
694 |
' le ' +
|
|
|
695 |
'<span class="date">' + date + '</span>' +
|
|
|
696 |
'</li>' +
|
|
|
697 |
'<li>' +
|
1946 |
jpm |
698 |
'Milieux : ' + milieux + ' ' + ' ; ' +
|
1922 |
jpm |
699 |
'</li>' +
|
|
|
700 |
'<li>' +
|
2408 |
jpm |
701 |
'Notes : ' + notes +
|
1946 |
jpm |
702 |
'</li>' +
|
|
|
703 |
'</ul>' +
|
|
|
704 |
'</div>' +
|
|
|
705 |
'</div>' +
|
|
|
706 |
'</div>' +
|
1922 |
jpm |
707 |
'</div>'+
|
|
|
708 |
'</div>');
|
2697 |
mathias |
709 |
$('#zone-liste-obs').removeClass("hidden");
|
|
|
710 |
};
|
1922 |
jpm |
711 |
|
2697 |
mathias |
712 |
WidgetSaisieSauvages.prototype.getMilieux = function() {
|
1922 |
jpm |
713 |
var milieuxStr = '',
|
|
|
714 |
milieux = [];
|
|
|
715 |
$('.cb-milieux:checked').each(function() {
|
|
|
716 |
milieux.push($(this).val());
|
|
|
717 |
});
|
2408 |
jpm |
718 |
|
1922 |
jpm |
719 |
milieuxStr = Array.prototype.slice.call(milieux).join(', ');
|
|
|
720 |
return milieuxStr;
|
2697 |
mathias |
721 |
};
|
1922 |
jpm |
722 |
|
2697 |
mathias |
723 |
WidgetSaisieSauvages.prototype.ajouterImgMiniatureAuTransfert = function() {
|
1922 |
jpm |
724 |
var html = '',
|
|
|
725 |
miniatures = '',
|
|
|
726 |
indicateurs = '',
|
|
|
727 |
premiere = true,
|
|
|
728 |
numero = 1;
|
|
|
729 |
if ($('#miniatures img').length == 0) {
|
|
|
730 |
html = '<img class="miniature" alt="Aucune photo"src="'+PAS_DE_PHOTO_ICONE_URL+'" />';
|
|
|
731 |
} else if ($('#miniatures img').length >= 1) {
|
|
|
732 |
$('#miniatures img').each(function() {
|
|
|
733 |
var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee',
|
|
|
734 |
css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
|
|
|
735 |
src = $(this).attr('src'),
|
|
|
736 |
alt = $(this).attr('alt');
|
2408 |
jpm |
737 |
|
1922 |
jpm |
738 |
var miniature = '<img class="'+css+' '+visible+'" alt="'+alt+'"src="'+src+'" />';
|
|
|
739 |
miniatures += miniature;
|
2408 |
jpm |
740 |
|
1922 |
jpm |
741 |
var indicateurActif = premiere ? 'active' : '';
|
|
|
742 |
var indicateur = '<li class="' + indicateurActif + '" data-numero="' + numero++ + '"></li>';
|
|
|
743 |
indicateurs += indicateur;
|
2408 |
jpm |
744 |
|
1922 |
jpm |
745 |
premiere = false;
|
|
|
746 |
});
|
2408 |
jpm |
747 |
|
1922 |
jpm |
748 |
if ($('#miniatures img').length == 1) {
|
|
|
749 |
html = miniatures;
|
|
|
750 |
} else {
|
2408 |
jpm |
751 |
html =
|
1922 |
jpm |
752 |
'<div class="defilement">' +
|
|
|
753 |
miniatures +
|
|
|
754 |
'<a class="defilement-control-zone gauche">' +
|
|
|
755 |
' <span class="defilement-control gauche hidden"><</span>' +
|
|
|
756 |
'</a>' +
|
|
|
757 |
'<a class="defilement-control-zone droite">' +
|
|
|
758 |
' <span class="defilement-control droite hidden">></span>' +
|
|
|
759 |
'</a>' +
|
|
|
760 |
'<ol class="defilement-indicateurs">' + indicateurs + '</ol>' +
|
|
|
761 |
'</div>';
|
|
|
762 |
}
|
|
|
763 |
}
|
|
|
764 |
return html;
|
2697 |
mathias |
765 |
};
|
1922 |
jpm |
766 |
|
2697 |
mathias |
767 |
WidgetSaisieSauvages.prototype.defilerMiniatures = function(element) {
|
1922 |
jpm |
768 |
var miniatureSelectionne = element.siblings('img.miniature-selectionnee');
|
|
|
769 |
miniatureSelectionne.removeClass('miniature-selectionnee').addClass('miniature-cachee');
|
|
|
770 |
var miniatureAffichee = miniatureSelectionne;
|
2408 |
jpm |
771 |
|
1922 |
jpm |
772 |
var indicateurActif = element.parent().find('.defilement-indicateurs .active');
|
|
|
773 |
indicateurActif.removeClass('active');
|
2408 |
jpm |
774 |
|
1922 |
jpm |
775 |
if (element.hasClass('defilement-control-zone') && element.hasClass('gauche')) {
|
|
|
776 |
if (miniatureSelectionne.prev('.miniature').length != 0) {
|
|
|
777 |
miniatureAffichee = miniatureSelectionne.prev('.miniature');
|
|
|
778 |
indicateurActif.prev().addClass('active');
|
|
|
779 |
} else {
|
|
|
780 |
miniatureAffichee = miniatureSelectionne.siblings('.miniature').last();
|
|
|
781 |
indicateurActif.siblings().last().addClass('active');
|
|
|
782 |
}
|
|
|
783 |
} else {
|
|
|
784 |
if (miniatureSelectionne.next('.miniature').length != 0) {
|
|
|
785 |
miniatureAffichee = miniatureSelectionne.next('.miniature');
|
|
|
786 |
indicateurActif.next().addClass('active');
|
|
|
787 |
} else {
|
|
|
788 |
miniatureAffichee = miniatureSelectionne.siblings('.miniature').first();
|
|
|
789 |
indicateurActif.siblings().first().addClass('active');
|
|
|
790 |
}
|
|
|
791 |
}
|
|
|
792 |
miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee');
|
|
|
793 |
}
|
|
|
794 |
|
2697 |
mathias |
795 |
WidgetSaisieSauvages.prototype.formaterNumNomSel = function(numNomSel) {
|
1922 |
jpm |
796 |
var nn = '';
|
|
|
797 |
if (numNomSel == undefined) {
|
|
|
798 |
nn = '<span class="alert-error">[non lié au référentiel]</span>';
|
|
|
799 |
} else {
|
|
|
800 |
nn = '<span class="nn">[nn'+numNomSel+']</span>';
|
|
|
801 |
}
|
|
|
802 |
return nn;
|
|
|
803 |
}
|
|
|
804 |
|
2697 |
mathias |
805 |
// surcharge
|
|
|
806 |
WidgetSaisieSauvages.prototype.surChangementReferentiel = function() {
|
2408 |
jpm |
807 |
NOM_SCI_REFERENTIEL = $('#referentiel').val();
|
1922 |
jpm |
808 |
$('#taxon').val('');
|
|
|
809 |
}
|
|
|
810 |
|
2697 |
mathias |
811 |
// surcharge
|
|
|
812 |
WidgetSaisieSauvages.prototype.stockerObsData = function() {
|
|
|
813 |
var lthis = this;
|
1922 |
jpm |
814 |
var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
|
|
|
815 |
nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
|
|
|
816 |
numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
|
|
|
817 |
nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
|
|
|
818 |
nomRet = nomHorsListe ? $('#taxon').data('nomRet') : taxons[numNomSel]['nom_ret'],
|
|
|
819 |
numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : taxons[numNomSel]['num_nom_ret'],
|
|
|
820 |
numTaxon = nomHorsListe ? $('#taxon').data('nt') : taxons[numNomSel]['num_taxon'],
|
|
|
821 |
famille = nomHorsListe ? $('#taxon').data('famille') : taxons[numNomSel]['famille'],
|
|
|
822 |
referentiel = (numNomSel == undefined) ? '' : NOM_SCI_REFERENTIEL,
|
|
|
823 |
notes = (nomSpecial ? taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
|
2521 |
aurelien |
824 |
|
|
|
825 |
certitude = $('input[name=certitude]:checked').val();
|
|
|
826 |
certitude = (certitude == undefined) ? '' : certitude;
|
2408 |
jpm |
827 |
|
2697 |
mathias |
828 |
$('#liste-obs').data('obsId'+this.obsNbre, {
|
2408 |
jpm |
829 |
'date': $('#date').val(),
|
1922 |
jpm |
830 |
'notes': notes,
|
2408 |
jpm |
831 |
|
1946 |
jpm |
832 |
'station': $('input[name="adresse"]').val(),
|
1922 |
jpm |
833 |
'latitude': $('#latitude').val(),
|
|
|
834 |
'longitude': $('#longitude').val(),
|
|
|
835 |
'commune_nom': $('#commune-nom').text(),
|
|
|
836 |
'commune_code_insee': $('#commune-code-insee').text(),
|
2408 |
jpm |
837 |
|
1922 |
jpm |
838 |
'nom_sel': nomSel,
|
|
|
839 |
'num_nom_sel': numNomSel,
|
|
|
840 |
'nom_ret': nomRet,
|
|
|
841 |
'num_nom_ret': numNomRet,
|
|
|
842 |
'num_taxon': numTaxon,
|
|
|
843 |
'famille': famille,
|
|
|
844 |
'referentiel': referentiel,
|
2521 |
aurelien |
845 |
'certitude': certitude,
|
2697 |
mathias |
846 |
'milieu': lthis.getMilieux(),
|
2408 |
jpm |
847 |
|
1922 |
jpm |
848 |
// Ajout des champs images
|
2697 |
mathias |
849 |
'image_nom': lthis.getNomsImgsOriginales(),
|
2408 |
jpm |
850 |
|
1922 |
jpm |
851 |
// Ajout des champs étendus de l'obs
|
2697 |
mathias |
852 |
'obs_etendue': lthis.getObsChpEtendus()
|
1922 |
jpm |
853 |
});
|
1964 |
jpm |
854 |
if (DEBUG) {
|
2697 |
mathias |
855 |
console.log($('#liste-obs').data('obsId'+this.obsNbre));
|
1964 |
jpm |
856 |
}
|
1922 |
jpm |
857 |
}
|
|
|
858 |
|
2697 |
mathias |
859 |
WidgetSaisieSauvages.prototype.getObsChpEtendus = function() {
|
1946 |
jpm |
860 |
var champs = [];
|
2697 |
mathias |
861 |
if (this.latLngDeb != undefined) {
|
|
|
862 |
var latitudeDebutRue = {cle: 'latitudeDebutRue', label: 'Latitude du début de la rue', valeur: this.latLngDeb.lat().toFixed(5)};
|
1922 |
jpm |
863 |
champs.push(latitudeDebutRue);
|
2697 |
mathias |
864 |
var longitudeDebutRue = {cle: 'longitudeDebutRue', label: 'Longitude du début de la rue', valeur: this.latLngDeb.lng().toFixed(5)};
|
1922 |
jpm |
865 |
champs.push(longitudeDebutRue);
|
|
|
866 |
}
|
2697 |
mathias |
867 |
if (this.latLngFin != undefined) {
|
|
|
868 |
var latitudeFinRue = {cle: 'latitudeFinRue', label: 'Latitude de fin de la rue', valeur: this.latLngFin.lat().toFixed(5)};
|
1922 |
jpm |
869 |
champs.push(latitudeFinRue);
|
2697 |
mathias |
870 |
var longitudeFinRue = {cle: 'longitudeFinRue', label: 'Longitude de fin de la rue', valeur: this.latLngFin.lng().toFixed(5)};
|
1922 |
jpm |
871 |
champs.push(longitudeFinRue);
|
|
|
872 |
}
|
2408 |
jpm |
873 |
|
1922 |
jpm |
874 |
$('.obs-chp-etendu').each(function() {
|
|
|
875 |
var valeur = $(this).val(),
|
|
|
876 |
cle = $(this).attr('name'),
|
|
|
877 |
label = $(this).data('label');
|
|
|
878 |
if (valeur != '') {
|
|
|
879 |
var chpEtendu = {cle: cle, label: label, valeur: valeur};
|
|
|
880 |
champs.push(chpEtendu);
|
|
|
881 |
}
|
|
|
882 |
});
|
|
|
883 |
return champs;
|
1054 |
jpm |
884 |
}
|