Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 3045 Rev 3046
Line 26... Line 26...
26
}
26
}
27
WidgetSaisieBellesdemarue.prototype = new WidgetSaisie();
27
WidgetSaisieBellesdemarue.prototype = new WidgetSaisie();
Line 28... Line 28...
28
 
28
 
29
//surcharge
29
//surcharge
30
WidgetSaisieBellesdemarue.prototype.initialiserGoogleMap = function() {
30
WidgetSaisieBellesdemarue.prototype.initialiserGoogleMap = function() {
31
	var lthis = this;
31
	// centrage
32
	this.latLng = new google.maps.LatLng(50.8504500, 4.3487800);// Bruxelles par défaut
-
 
Line 33... Line 32...
33
	//WidgetSaisie.prototype.initialiserGoogleMap.call(this);
32
	this.latLng = new google.maps.LatLng(50.8504500, 4.3487800);// Bruxelles par défaut
34
	
33
	
35
	var options = {
34
	var options = {
36
			zoom: 11, // avant : 16
35
			zoom: 11, // avant : 16
Line 72... Line 71...
72
		position: this.latLng
71
		position: this.latLng
73
	});
72
	});
Line 74... Line 73...
74
 
73
 
Line 75... Line -...
75
	this.initialiserMarker(this.latLng);
-
 
76
 
74
	this.initialiserMarker(this.latLng);
77
 
75
 
78
	// intéraction carte
76
	// intéraction carte
79
	$("#geolocaliser").on('click', this.geolocaliser.bind(this));
77
	$("#geolocaliser").on('click', this.geolocaliser.bind(this));
80
	google.maps.event.addListener(this.marker, 'dragend', this.surDeplacementMarker.bind(this));
78
	google.maps.event.addListener(this.marker, 'dragend', this.surDeplacementMarker.bind(this));
Line 91... Line 89...
91
	if (this.debug) {
89
	if (this.debug) {
92
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
90
		console.log('Selected taxon:'+$('#taxon-liste option:selected').val());
93
	}
91
	}
94
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
92
	$('#taxon-liste').on('blur', this.surChangementValeurTaxon);
95
	$('#taxon').on('blur', this.surChangementValeurTaxon);
93
	$('#taxon').on('blur', this.surChangementValeurTaxon);
-
 
94
 
-
 
95
	this.surChangementMilieuListe();
-
 
96
	$('#milieu').on('change', this.surChangementMilieuListe);
96
};
97
};
Line 97... Line 98...
97
 
98
 
98
//surcharge
99
//surcharge
99
WidgetSaisieBellesdemarue.prototype.initEvts = function() {
100
WidgetSaisieBellesdemarue.prototype.initEvts = function() {
Line 199... Line 200...
199
		}
200
		}
200
		lthis.valeurChamp = $('#taxon').val();
201
		lthis.valeurChamp = $('#taxon').val();
201
	});
202
	});
202
};
203
};
Line 203... Line -...
203
 
-
 
204
WidgetSaisieBellesdemarue.prototype.getUrlAutocompletionNomsSci = function() {
-
 
205
	var mots = $('#taxon').val(),
-
 
206
		url = this.serviceAutocompletionNomSciUrlTpl.replace('{referentiel}', this.nomSciReferentiel);
-
 
207
	url = url.replace('{masque}', mots);
-
 
208
	return url;
-
 
209
};
-
 
210
 
-
 
211
WidgetSaisieBellesdemarue.prototype.traiterRetourNomsSci = function(data) {
-
 
212
	var suggestions = [];
-
 
213
	if (data.resultat != undefined) {
-
 
214
		$.each(data.resultat, function(i, val) {
-
 
215
			val.nn = i;
-
 
216
			var nom = {label: '', value: '', nt: '', nomSel: '', nomSelComplet: '', numNomSel: '',
-
 
217
				nomRet: '', numNomRet: '', famille: '', retenu: false
-
 
218
			};
-
 
219
			if (suggestions.length >= this.autocompletionElementsNbre) {
-
 
220
				nom.label = '...';
-
 
221
				nom.value = $('#taxon').val();
-
 
222
				suggestions.push(nom);
-
 
223
				return false;
-
 
224
			} else {
-
 
225
				nom.label = val.nom_sci_complet;
-
 
226
				nom.value = val.nom_sci_complet;
-
 
227
				nom.nt = val.num_taxonomique;
-
 
228
				nom.nomSel = val.nom_sci;
-
 
229
				nom.nomSelComplet = val.nom_sci_complet;
-
 
230
				nom.numNomSel = val.nn;
-
 
231
				nom.nomRet = val.nom_retenu_complet;
-
 
232
				nom.numNomRet = val['nom_retenu.id'];
-
 
233
				nom.famille = val.famille;
-
 
234
				nom.retenu = (val.retenu == 'false') ? false : true;
-
 
235
 
-
 
236
				suggestions.push(nom);
-
 
237
			}
-
 
238
		});
-
 
239
	}
-
 
240
	return suggestions;
-
 
241
};
204
 
-
 
205
*/
242
*/
206
 
243
// surcharge
207
// surcharge
244
WidgetSaisieBellesdemarue.prototype.configurerFormValidator = function() {
208
WidgetSaisieBellesdemarue.prototype.configurerFormValidator = function() {
245
	$.validator.addMethod(
209
	$.validator.addMethod(
246
		'dateCel',
210
		'dateCel',
Line 278... Line 242...
278
		rules: {
242
		rules: {
279
			courriel: {
243
			courriel: {
280
				required: true,
244
				required: true,
281
				email: true},
245
				email: true},
282
			courriel_confirmation: {
246
			courriel_confirmation: {
283
				required: true,
-
 
284
				equalTo: '#courriel'},
247
				equalTo: '#courriel'},
285
			prenom: {
248
			prenom: {
286
				required: true},
249
				required: true},
287
			nom: {
250
			nom: {
288
				required: true}
251
				required: true}
289
		}
252
		}
290
	});
253
	});
291
	$('#form-obs').validate({
254
	$('#form-obs').validate({
292
		rules: {
255
		rules: {
293
			station: {
-
 
294
				required: true},
-
 
295
			latitude : {
256
			latitude : {
296
				required: true,
257
				required: true,
297
				range: [-90, 90]},
258
				range: [-90, 90]
-
 
259
			},
298
			longitude: {
260
			longitude: {
299
				required: true,
261
				required: true,
300
				range: [-180, 180]},
262
				range: [-180, 180]
-
 
263
			},
301
			date: {
264
			date: {
302
				required: true,
265
				required: true,
303
				'dateCel' : true},
266
				'dateCel' : true
304
			coteRue: {
267
			},
305
				required: true},
-
 
306
			'taxon-liste': {
268
			'taxon-liste': {
307
				required: true},
269
				required: true
-
 
270
			},
308
			'milieux[]': {
271
			milieu: {
309
				required: true,
272
				required: true,
310
				minlength: 1}
273
				minlength: 1
-
 
274
			},
-
 
275
			certitude: {
-
 
276
				required: true
-
 
277
			}
311
		},
278
		},
312
		errorPlacement: function(error, element) {
279
		errorPlacement: function(error, element) {
313
			if (element.attr('name') == 'date') {
280
			if (element.attr('name') == 'date') {
314
				element.parent('.input-prepend').after(error);
281
				element.parent('.input-prepend').after(error);
315
			} else if (element.attr('name') == 'milieux[]') {
282
			/*} else if (element.attr('name') == 'milieux[]') {
316
				error.insertAfter('#milieux-controls');
283
				error.insertAfter('#milieux-controls');*/
-
 
284
			} else if (element.attr('name') == 'certitude') {
-
 
285
				error.insertAfter('#certitude-controls');
317
			} else {
286
			} else {
318
				error.insertAfter(element);
287
				error.insertAfter(element);
319
			}
288
			}
320
		},
-
 
321
		messages: {
-
 
322
			'milieu[]': 'Vous devez sélectionner au moins un milieu'
-
 
323
		}
289
		}
324
	});
290
	});
325
};
291
};
Line 326... Line 292...
326
 
292
 
327
WidgetSaisieBellesdemarue.prototype.validerFormulaire = function() {
293
WidgetSaisieBellesdemarue.prototype.validerFormulaire = function() {
328
	var observateur = $('#form-observateur').valid(),
294
	$observateur = $("#form-observateur").valid();
329
		obs = $('#form-obs').valid(),
-
 
330
		debRue = (this.latLngDeb == undefined || this.latLngDeb == this.latLngFin) ? false : true,
-
 
331
		finRue = (this.latLngFin == undefined || this.latLngDeb == this.latLngFin) ? false : true;
295
	$obs = $("#form-obs").valid();
332
	var ok = (observateur && obs && debRue && finRue) ? true : false;
-
 
333
	//console.log('observateur:'+observateur+'-obs:'+obs+'-debRue:'+debRue+'('+latLngDeb+')-finRue:'+finRue+'('+latLngDeb+')');
-
 
334
	return ok;
296
	return ($observateur == true && $obs == true) ? true : false;
Line 335... Line -...
335
};
-
 
336
 
297
};
337
 
298
 
338
WidgetSaisieBellesdemarue.prototype.surChangementTaxonListe = function() {
299
WidgetSaisieBellesdemarue.prototype.surChangementTaxonListe = function() {
339
	if ($('#taxon-liste').val() === '?') {
300
	if ($('#taxon-liste').val() === '?') {
-
 
301
		$('#taxon-input-groupe').removeClass('hidden');
340
		$('#taxon-input-groupe').removeClass('hidden');
302
	} else {
341
	} else {
303
		// $('#milieu-autre').val(''); paraît logique de faire ça mais méfiance
342
		$('#taxon-input-groupe').addClass('hidden');
304
		$('#taxon-input-groupe').addClass('hidden');
Line -... Line 305...
-
 
305
	}
-
 
306
};
-
 
307
 
-
 
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');
343
	}
314
	}
344
};
315
};
345
 
316
 
346
WidgetSaisieBellesdemarue.prototype.trouverCommune = function(pos) {
317
WidgetSaisieBellesdemarue.prototype.trouverCommune = function(pos) {
347
	if (this.latLng == null) { // tentative de protection contre le démon de Prémilhat
318
	if (this.latLng == null) { // tentative de protection contre le démon de Prémilhat
Line 517... Line 488...
517
	}
488
	}
Line 518... Line 489...
518
	
489
	
519
	return station;
490
	return station;
Line 520... Line -...
520
}
-
 
521
 
-
 
522
WidgetSaisieBellesdemarue.prototype.getMilieux = function() {
-
 
523
	var milieuxStr = '',
-
 
524
		milieux = [];
-
 
525
	$('.cb-milieux:checked').each(function() {
-
 
526
		milieux.push($(this).val());
-
 
527
	});
-
 
528
 
-
 
529
	milieuxStr = Array.prototype.slice.call(milieux).join(', ');
-
 
530
	return milieuxStr;
-
 
531
};
491
}
532
 
492
 
533
WidgetSaisieBellesdemarue.prototype.ajouterImgMiniatureAuTransfert = function() {
493
WidgetSaisieBellesdemarue.prototype.ajouterImgMiniatureAuTransfert = function() {
534
	var html = '',
494
	var html = '',
535
		miniatures = '',
495
		miniatures = '',