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