Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2707 Rev 2708
Line 10... Line 10...
10
	this.ligneRue = null;
10
	this.ligneRue = null;
11
	this.googleMapMarqueurDebutUrl = null;
11
	this.googleMapMarqueurDebutUrl = null;
12
	this.googleMapMarqueurFinUrl = null;
12
	this.googleMapMarqueurFinUrl = null;
13
	this.premierDeplacement = true;
13
	this.premierDeplacement = true;
14
}
14
}
15
WidgetSaisieFlorileges.prototype = new WidgetSaisie();
15
WidgetSaisieFlorileges.prototype = new WidgetSaisieSauvages();
Line -... Line 16...
-
 
16
 
-
 
17
 
16
 
18
// @TODO harmoniser avec Sauvages (rue)
17
WidgetSaisieFlorileges.prototype.initCarto = function() {
19
WidgetSaisieFlorileges.prototype.initCarto = function() {
Line 18... Line 20...
18
	var lthis = this;
20
	var lthis = this;
19
 
21
 
Line 63... Line 65...
63
WidgetSaisieFlorileges.prototype.initEvts = function() {
65
WidgetSaisieFlorileges.prototype.initEvts = function() {
64
	var lthis = this;
66
	var lthis = this;
65
	// super() à la main - toute autre manière de faire est über-komplex
67
	// super() à la main - toute autre manière de faire est über-komplex
66
	WidgetSaisie.prototype.initEvts.call(this);
68
	WidgetSaisie.prototype.initEvts.call(this);
Line 67... Line -...
67
 
-
 
68
	$('#photo-placeholder').click(function(event) {
-
 
69
		$('#fichier').click();
-
 
70
	});
69
 
71
	$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) {
70
	$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) {
72
		event.stopPropagation();
71
		event.stopPropagation();
Line 73... Line 72...
73
	});
72
	});
Line 106... Line 105...
106
		$('.defilement-control', this).removeClass('hidden');
105
		$('.defilement-control', this).removeClass('hidden');
107
	});
106
	});
108
	$('body').on('mouseout', '.defilement-control-zone', function(event) {
107
	$('body').on('mouseout', '.defilement-control-zone', function(event) {
109
		$('.defilement-control', this).addClass('hidden');
108
		$('.defilement-control', this).addClass('hidden');
110
	});
109
	});
-
 
110
	$('#photo-placeholder').click(function(event) {
-
 
111
		$('#fichier').click();
-
 
112
	});
111
};
113
};
Line 112... Line -...
112
 
-
 
113
 
114
 
114
WidgetSaisieFlorileges.prototype.prechargerForm = function(infos) {
115
WidgetSaisieFlorileges.prototype.prechargerForm = function(infos) {
Line 115... Line 116...
115
	$('input[name="station"]').val(infos.station);
116
	$('input[name="station"]').val(infos.station);
116
 
117
 
Line 220... Line 221...
220
	$("#geolocaliser").on('click', this.geolocaliser.bind(this));
221
	$("#geolocaliser").on('click', this.geolocaliser.bind(this));
221
	// Création du Geocoder
222
	// Création du Geocoder
222
	this.geocoder = new google.maps.Geocoder();
223
	this.geocoder = new google.maps.Geocoder();
223
}
224
}
Line 224... Line -...
224
 
-
 
225
WidgetSaisieFlorileges.prototype.initialiserMarkerDeb = function() {
-
 
226
	this.premierDeplacement = true;
-
 
227
	if (this.markerDeb == undefined) {
-
 
228
		// Marqueur de début de Rue
-
 
229
		this.markerDeb = new google.maps.Marker({
-
 
230
			map: this.map,
-
 
231
			draggable: true,
-
 
232
			title: 'Début de la portion de rue étudiée',
-
 
233
			icon: this.googleMapMarqueurDebutUrl,
-
 
234
			position: this.latLngDeb
-
 
235
		});
-
 
236
		google.maps.event.addListener(this.markerDeb, 'dragend', this.surDeplacementMarkerDeb.bind(this));
-
 
237
	}
-
 
238
 
-
 
239
	this.latLngFin = this.latLngDeb;
-
 
240
	if (this.markerFin != undefined) {
-
 
241
		this.markerFin.setMap(null);
-
 
242
	}
-
 
243
	this.latLngCentre = this.latLngDeb;
-
 
244
	if (this.ligneRue != undefined) {
-
 
245
		this.ligneRue.setMap(null);
-
 
246
	}
-
 
247
}
-
 
248
 
-
 
249
WidgetSaisieFlorileges.prototype.surDeplacementMarkerDeb = function() {
-
 
250
	this.deplacerMarkerDeb(this.markerDeb.getPosition());
-
 
251
}
-
 
252
 
-
 
253
WidgetSaisieFlorileges.prototype.deplacerMarkerDeb = function(nouvellePosition) {
-
 
254
	this.latLngDeb = nouvellePosition;
-
 
255
	this.markerDeb.setPosition(this.latLngDeb);
-
 
256
	this.map.setCenter(this.latLngDeb);
-
 
257
	this.mettreAJourMarkerPosition(this.latLngDeb);
-
 
258
	this.trouverCommune(this.latLngDeb);
-
 
259
 
-
 
260
	if (this.premierDeplacement) {
-
 
261
		this.initialiserMarkerDeb();
-
 
262
		this.premierDeplacement = false;
-
 
263
	} else {
-
 
264
		var nouvellePositionFin = new google.maps.LatLng(this.latLngDeb.lat(), this.latLngDeb.lng() + 0.0010);
-
 
265
		this.initialiserMarkerFin();
-
 
266
		this.deplacerMakerFin(nouvellePositionFin)
-
 
267
		this.afficherEtapeGeolocalisation(3);
-
 
268
	}
-
 
269
}
-
 
270
 
-
 
271
WidgetSaisieFlorileges.prototype.initialiserMarkerFin = function() {
-
 
272
	if (this.markerFin == undefined) {
-
 
273
		this.markerFin = new google.maps.Marker({
-
 
274
			map: this.map,
-
 
275
			draggable: true,
-
 
276
			title: 'Fin de la portion de rue étudiée',
-
 
277
			icon: this.googleMapMarqueurFinUrl,
-
 
278
			position: this.latLngFin
-
 
279
		});
-
 
280
		google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this));
-
 
281
	} else {
-
 
282
		this.markerFin.setMap(null);
-
 
283
	}
-
 
284
}
-
 
285
 
-
 
286
WidgetSaisieFlorileges.prototype.deplacerMakerFin = function(nouvellePosition) {
-
 
287
	this.latLngFin = nouvellePosition;
-
 
288
	this.markerFin.setMap(this.map);
-
 
289
	this.markerFin.setPosition(this.latLngFin);
-
 
290
	this.dessinerLigneRue(this.latLngDeb, this.latLngFin);
-
 
291
}
-
 
292
 
-
 
293
WidgetSaisieFlorileges.prototype.surDeplacementMarkerFin = function() {
-
 
294
	this.dessinerLigneRue(this.markerDeb.getPosition(), this.markerFin.getPosition());
-
 
295
	this.afficherCentreRue();
-
 
296
	this.afficherEtapeGeolocalisation(4);
-
 
297
}
-
 
298
 
-
 
299
WidgetSaisieFlorileges.prototype.dessinerLigneRue = function(pointDebut, pointFin) {
-
 
300
	if (this.ligneRue != undefined) {
-
 
301
		this.ligneRue.setMap(null);
-
 
302
	}
-
 
303
 
-
 
304
	this.ligneRue = new google.maps.Polyline({
-
 
305
		path: [pointDebut, pointFin],
-
 
306
		strokeColor: "#FF0000",
-
 
307
		strokeOpacity: 1.0,
-
 
308
		strokeWeight: 2
-
 
309
	});
-
 
310
 
-
 
311
	this.ligneRue.setMap(this.map);
-
 
312
}
-
 
313
 
-
 
314
WidgetSaisieFlorileges.prototype.afficherCentreRue = function() {
-
 
315
	this.latLngDeb = this.markerDeb.getPosition();
-
 
316
	this.latLngFin = this.markerFin.getPosition();
-
 
317
	this.latLngCentre = new google.maps.LatLng((this.latLngFin.lat() + this.latLngDeb.lat())/2, (this.latLngFin.lng() + this.latLngDeb.lng())/2);
-
 
318
	this.mettreAJourMarkerPosition(this.latLngCentre);
-
 
319
}
-
 
320
 
-
 
321
WidgetSaisieFlorileges.prototype.afficherEtapeGeolocalisation = function(numEtape) {
-
 
322
	$('.liste_indication_geolocalisation').children().hide();
-
 
323
	$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show();
-
 
324
}
-
 
325
 
-
 
326
WidgetSaisieFlorileges.prototype.geolocaliser = function(event) {
-
 
327
	var latitude = $('#latitude').val(),
-
 
328
		longitude = $('#longitude').val(),
-
 
329
		nouvellePosition = new google.maps.LatLng(latitude, longitude);
-
 
330
	this.initialiserMarkerDeb();
-
 
331
	this.deplacerMarkerDeb(nouvellePosition);
-
 
332
	this.afficherEtapeGeolocalisation(2);
-
 
333
	this.map.setZoom(16);
-
 
334
	arreter(event);
-
 
335
}
-
 
336
 
-
 
337
WidgetSaisieFlorileges.prototype.tenterGeolocalisation = function() {
-
 
338
	if (navigator.geolocation) {
-
 
339
		navigator.geolocation.getCurrentPosition(function(position) {
-
 
340
			var latitude = position.coords.latitude,
-
 
341
				longitude = position.coords.longitude,
-
 
342
				nouvellePosition = new google.maps.LatLng(latitude, longitude);
-
 
343
			this.initialiserMarkerDeb();
-
 
344
			this.deplacerMarkerDeb(nouvellePosition);
-
 
345
			this.map.setZoom(16);
-
 
346
		});
-
 
347
	}
-
 
348
}
-
 
349
 
-
 
350
WidgetSaisieFlorileges.prototype.surClickDansCarte = function(event) {
-
 
351
	this.deplacerMarkerDeb(event.latLng);
-
 
352
}
-
 
353
 
225
 
354
WidgetSaisieFlorileges.prototype.transformerEnSlider = function(selector) {
226
WidgetSaisieFlorileges.prototype.transformerEnSlider = function(selector) {
355
	$(selector).each(function(index, el) {
227
	$(selector).each(function(index, el) {
356
		// hide the element
228
		// hide the element
Line 408... Line 280...
408
	} else {
280
	} else {
409
		$('#datp-zone').addClass('hidden');
281
		$('#datp-zone').addClass('hidden');
410
	}
282
	}
411
}
283
}
Line 412... Line -...
412
 
-
 
413
WidgetSaisieFlorileges.prototype.surChangementTaxonListe = function() {
-
 
414
	if ($('#taxon-liste').val() === '?') {
-
 
415
		$('#taxon-input-groupe').removeClass('hidden');
-
 
416
	} else {
-
 
417
		$('#taxon-input-groupe').addClass('hidden');
-
 
418
	}
-
 
419
}
-
 
420
 
-
 
421
WidgetSaisieFlorileges.prototype.configurerFormValidator = function() {
-
 
422
	$.validator.addMethod(
-
 
423
		'dateCel',
-
 
424
		function (value, element) {
-
 
425
			return value == '' || (/^[0-9]{2}[-\/][0-9]{2}[-\/][0-9]{4}$/.test(value));
-
 
426
		},
-
 
427
		'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.');
-
 
428
 
-
 
429
	$.extend($.validator.defaults, {
-
 
430
		ignore: [],// Forcer Jquery Validate à examiner les éléments avec en display:none;
-
 
431
		highlight: function(element) {
-
 
432
			$(element).closest('.control-group').removeClass('success').addClass('error');
-
 
433
		},
-
 
434
		success: function(element) {
-
 
435
			element.text('OK!').addClass('valid');
-
 
436
			element.closest('.control-group').removeClass('error').addClass('success');
-
 
437
 
-
 
438
			if (element.attr('id') == 'taxon' && $('#taxon').val() != '') {
-
 
439
				// Si le taxon n'est pas lié au référentiel, on vide le data associé
-
 
440
				if ($('#taxon').data('value') != $('#taxon').val()) {
-
 
441
					$('#taxon').data('numNomSel', '');
-
 
442
					$('#taxon').data('nomRet', '');
-
 
443
					$('#taxon').data('numNomRet', '');
-
 
444
					$('#taxon').data('nt', '');
-
 
445
					$('#taxon').data('famille', '');
-
 
446
				}
-
 
447
			}
-
 
448
		}
-
 
449
	});
-
 
450
}
-
 
451
 
284
 
452
WidgetSaisieFlorileges.prototype.definirReglesFormValidator = function() {
285
WidgetSaisieFlorileges.prototype.definirReglesFormValidator = function() {
453
	$('#form-observateur').validate({
286
	$('#form-observateur').validate({
454
		rules: {
287
		rules: {
455
			courriel: {
288
			courriel: {
Line 539... Line 372...
539
	var ok = (observateur && station && obs && date && debRue && finRue) ? true : false;
372
	var ok = (observateur && station && obs && date && debRue && finRue) ? true : false;
540
	//console.log(observateur+'-'+station+'-'+obs+'-'+date+'-'+debRue+'-'+finRue);
373
	//console.log(observateur+'-'+station+'-'+obs+'-'+date+'-'+debRue+'-'+finRue);
541
	return ok;
374
	return ok;
542
}
375
}
Line 543... Line 376...
543
 
376
 
544
WidgetSaisieFlorileges.prototype.ajouterObs = function() {
377
/*WidgetSaisieFlorileges.prototype.ajouterObs = function() {
545
	if (this.validerFormulaire() == true) {
378
	if (this.validerFormulaire() == true) {
546
		this.obsNbre = this.obsNbre + 1;
379
		this.obsNbre = this.obsNbre + 1;
547
		$('.obs-nbre').text(this.obsNbre);
380
		$('.obs-nbre').text(this.obsNbre);
548
		$('.obs-nbre').triggerHandler('changement');
381
		$('.obs-nbre').triggerHandler('changement');
Line 556... Line 389...
556
			this.afficherPanneau('#dialogue-form-invalide-rue');
389
			this.afficherPanneau('#dialogue-form-invalide-rue');
557
		} else {
390
		} else {
558
			this.afficherPanneau('#dialogue-form-invalide');
391
			this.afficherPanneau('#dialogue-form-invalide');
559
		}
392
		}
560
	}
393
	}
561
}
394
}*/
Line 562... Line 395...
562
 
395
 
563
WidgetSaisieFlorileges.prototype.afficherObs = function() {
396
WidgetSaisieFlorileges.prototype.afficherObs = function() {
Line 564... Line 397...
564
	var lthis = this;
397
	var lthis = this;
Line 622... Line 455...
622
			'</div>'+
455
			'</div>'+
623
		'</div>');
456
		'</div>');
624
	$('#zone-liste-obs').removeClass("hidden").show();
457
	$('#zone-liste-obs').removeClass("hidden").show();
625
}
458
}
Line 626... Line -...
626
 
-
 
627
WidgetSaisieFlorileges.prototype.getMilieux = function() {
-
 
628
	var milieuxStr = '',
-
 
629
		milieux = [];
-
 
630
	$('.cb-milieux:checked').each(function() {
-
 
631
		milieux.push($(this).val());
-
 
632
	});
-
 
633
 
-
 
634
	milieuxStr = Array.prototype.slice.call(milieux).join(', ');
-
 
635
	return milieuxStr;
-
 
636
}
-
 
637
 
-
 
638
WidgetSaisieFlorileges.prototype.ajouterImgMiniatureAuTransfert = function() {
-
 
639
	var html = '',
-
 
640
		miniatures = '',
-
 
641
		indicateurs = '',
-
 
642
		premiere = true,
-
 
643
		numero = 1;
-
 
644
	if ($('#miniatures img').length == 0) {
-
 
645
		html = '<img class="miniature" alt="Aucune photo"src="'+ this.pasDePhotoIconeUrl +'" />';
-
 
646
	} else if ($('#miniatures img').length >= 1) {
-
 
647
		$('#miniatures img').each(function() {
-
 
648
			var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee',
-
 
649
				css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
-
 
650
				src = $(this).attr('src'),
-
 
651
				alt = $(this).attr('alt');
-
 
652
 
-
 
653
			var miniature = '<img class="'+css+' '+visible+'"  alt="'+alt+'"src="'+src+'" />';
-
 
654
			miniatures += miniature;
-
 
655
 
-
 
656
			var indicateurActif = premiere ? 'active' : '';
-
 
657
			var indicateur = '<li class="' + indicateurActif + '" data-numero="' + numero++ + '"></li>';
-
 
658
			indicateurs += indicateur;
-
 
659
 
-
 
660
			premiere = false;
-
 
661
		});
-
 
662
 
-
 
663
		if ($('#miniatures img').length == 1) {
-
 
664
			html = miniatures;
-
 
665
		} else {
-
 
666
			html =
-
 
667
				'<div class="defilement">' +
-
 
668
					miniatures +
-
 
669
					'<a class="defilement-control-zone gauche">' +
-
 
670
					'	<span class="defilement-control gauche hidden">&#60;</span>' +
-
 
671
					'</a>' +
-
 
672
					'<a class="defilement-control-zone droite">' +
-
 
673
					'	<span class="defilement-control droite hidden">&#62;</span>' +
-
 
674
					'</a>' +
-
 
675
					'<ol class="defilement-indicateurs">' + indicateurs + '</ol>' +
-
 
676
				'</div>';
-
 
677
		}
-
 
678
	}
-
 
679
	return html;
-
 
680
}
-
 
681
 
-
 
682
WidgetSaisieFlorileges.prototype.defilerMiniatures = function(element) {
-
 
683
	var miniatureSelectionne = element.siblings('img.miniature-selectionnee');
-
 
684
	miniatureSelectionne.removeClass('miniature-selectionnee').addClass('miniature-cachee');
-
 
685
	var miniatureAffichee = miniatureSelectionne;
-
 
686
 
-
 
687
	var indicateurActif = element.parent().find('.defilement-indicateurs .active');
-
 
688
	indicateurActif.removeClass('active');
-
 
689
 
-
 
690
	if (element.hasClass('defilement-control-zone') && element.hasClass('gauche')) {
-
 
691
		if (miniatureSelectionne.prev('.miniature').length != 0) {
-
 
692
			miniatureAffichee = miniatureSelectionne.prev('.miniature');
-
 
693
			indicateurActif.prev().addClass('active');
-
 
694
		} else {
-
 
695
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').last();
-
 
696
			indicateurActif.siblings().last().addClass('active');
-
 
697
		}
-
 
698
	} else {
-
 
699
		if (miniatureSelectionne.next('.miniature').length != 0) {
-
 
700
			miniatureAffichee = miniatureSelectionne.next('.miniature');
-
 
701
			indicateurActif.next().addClass('active');
-
 
702
		} else {
-
 
703
			miniatureAffichee = miniatureSelectionne.siblings('.miniature').first();
-
 
704
			indicateurActif.siblings().first().addClass('active');
-
 
705
		}
-
 
706
	}
-
 
707
	miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee');
-
 
708
}
-
 
709
 
-
 
710
WidgetSaisieFlorileges.prototype.formaterNumNomSel = function(numNomSel) {
-
 
711
	var nn = '';
-
 
712
	if (numNomSel == undefined) {
-
 
713
		nn = '<span class="alert-error">[non lié au référentiel]</span>';
-
 
714
	} else {
-
 
715
		nn = '<span class="nn">[nn'+numNomSel+']</span>';
-
 
716
	}
-
 
717
	return nn;
-
 
718
}
-
 
719
 
-
 
720
// tentativé d'héritage
-
 
721
/*function surChangementReferentiel() {
-
 
722
	NOM_SCI_REFERENTIEL = $('#referentiel').val();
-
 
723
	$('#taxon').val('');
-
 
724
}*/
-
 
725
 
459
 
-
 
460
WidgetSaisieFlorileges.prototype.stockerObsData = function() {
726
WidgetSaisieFlorileges.prototype.stockerObsData = function() {
461
	
727
	var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
462
	var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false;
728
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
463
		nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
729
		numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
464
		numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
730
		nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
465
		nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
Line 763... Line 498...
763
	});
498
	});
764
	//console.log($('#liste-obs').data('obsId'+obsNbre));
499
	//console.log($('#liste-obs').data('obsId'+obsNbre));
765
}
500
}
Line 766... Line 501...
766
 
501
 
767
WidgetSaisieFlorileges.prototype.getObsChpEtendus = function() {
502
WidgetSaisieFlorileges.prototype.getObsChpEtendus = function() {
-
 
503
	// super()
-
 
504
	var champs = WidgetSaisieSauvages.prototype.getObsChampsEtendus.call(this);
768
	var champs = [],
505
 
769
		perceptionTechnicien = this.getPerceptionTechnicien();
506
	var perceptionTechnicien = this.getPerceptionTechnicien();
770
	if (perceptionTechnicien != undefined) {
507
	if (perceptionTechnicien != undefined) {
771
		champs.push(perceptionTechnicien);
508
		champs.push(perceptionTechnicien);
772
	}
-
 
773
	if (this.latLngDeb != undefined) {
-
 
774
		var latitudeDebutRue = {cle: 'latitudeDebutRue', label: 'Latitude du début de la rue', valeur: this.latLngDeb.lat().toFixed(5)};
-
 
775
		champs.push(latitudeDebutRue);
-
 
776
		var longitudeDebutRue = {cle: 'longitudeDebutRue', label: 'Longitude du début de la rue', valeur: this.latLngDeb.lng().toFixed(5)};
-
 
777
		champs.push(longitudeDebutRue);
-
 
778
	}
-
 
779
	if (this.latLngFin != undefined) {
-
 
780
		var latitudeFinRue = {cle: 'latitudeFinRue', label: 'Latitude de fin de la rue', valeur: this.latLngFin.lat().toFixed(5)};
-
 
781
		champs.push(latitudeFinRue);
-
 
782
		var longitudeFinRue = {cle: 'longitudeFinRue', label: 'Longitude de fin de la rue', valeur: this.latLngFin.lng().toFixed(5)};
-
 
783
		champs.push(longitudeFinRue);
-
 
Line 784... Line -...
784
	}
-
 
785
 
-
 
786
	$('.obs-chp-etendu').each(function() {
-
 
787
		var valeur = $(this).val(),
-
 
788
			cle = $(this).attr('name'),
-
 
789
			label = $(this).data('label');
-
 
790
		if (valeur != '') {
-
 
791
			var chpEtendu = {cle: cle, label: label, valeur: valeur};
-
 
792
			champs.push(chpEtendu);
-
 
793
		}
509
	}
794
	});
510
 
Line 795... Line 511...
795
	return champs;
511
	return champs;
796
}
512
}