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