12,10 → 12,8 |
this.googleMapMarqueurFinUrl = null; |
this.premierDeplacement = true; |
} |
WidgetSaisieFlorileges.prototype = new WidgetSaisieSauvages(); |
WidgetSaisieFlorileges.prototype = new WidgetSaisie(); |
|
|
// @TODO harmoniser avec Sauvages (rue) |
WidgetSaisieFlorileges.prototype.initCarto = function() { |
var lthis = this; |
|
67,6 → 65,9 |
// super() à la main - toute autre manière de faire est über-komplex |
WidgetSaisie.prototype.initEvts.call(this); |
|
$('#photo-placeholder').click(function(event) { |
$('#fichier').click(); |
}); |
$('.dropdown-menu input, .dropdown-menu label').on('click', function(event) { |
event.stopPropagation(); |
}); |
107,11 → 108,9 |
$('body').on('mouseout', '.defilement-control-zone', function(event) { |
$('.defilement-control', this).addClass('hidden'); |
}); |
$('#photo-placeholder').click(function(event) { |
$('#fichier').click(); |
}); |
}; |
|
|
WidgetSaisieFlorileges.prototype.prechargerForm = function(infos) { |
$('input[name="station"]').val(infos.station); |
|
223,6 → 222,135 |
this.geocoder = new google.maps.Geocoder(); |
} |
|
WidgetSaisieFlorileges.prototype.initialiserMarkerDeb = function() { |
this.premierDeplacement = true; |
if (this.markerDeb == undefined) { |
// Marqueur de début de Rue |
this.markerDeb = new google.maps.Marker({ |
map: this.map, |
draggable: true, |
title: 'Début de la portion de rue étudiée', |
icon: this.googleMapMarqueurDebutUrl, |
position: this.latLngDeb |
}); |
google.maps.event.addListener(this.markerDeb, 'dragend', this.surDeplacementMarkerDeb.bind(this)); |
} |
|
this.latLngFin = this.latLngDeb; |
if (this.markerFin != undefined) { |
this.markerFin.setMap(null); |
} |
this.latLngCentre = this.latLngDeb; |
if (this.ligneRue != undefined) { |
this.ligneRue.setMap(null); |
} |
} |
|
WidgetSaisieFlorileges.prototype.surDeplacementMarkerDeb = function() { |
this.deplacerMarkerDeb(this.markerDeb.getPosition()); |
} |
|
WidgetSaisieFlorileges.prototype.deplacerMarkerDeb = function(nouvellePosition) { |
this.latLngDeb = nouvellePosition; |
this.markerDeb.setPosition(this.latLngDeb); |
this.map.setCenter(this.latLngDeb); |
this.mettreAJourMarkerPosition(this.latLngDeb); |
this.trouverCommune(this.latLngDeb); |
|
if (this.premierDeplacement) { |
this.initialiserMarkerDeb(); |
this.premierDeplacement = false; |
} else { |
var nouvellePositionFin = new google.maps.LatLng(this.latLngDeb.lat(), this.latLngDeb.lng() + 0.0010); |
this.initialiserMarkerFin(); |
this.deplacerMakerFin(nouvellePositionFin) |
this.afficherEtapeGeolocalisation(3); |
} |
} |
|
WidgetSaisieFlorileges.prototype.initialiserMarkerFin = function() { |
if (this.markerFin == undefined) { |
this.markerFin = new google.maps.Marker({ |
map: this.map, |
draggable: true, |
title: 'Fin de la portion de rue étudiée', |
icon: this.googleMapMarqueurFinUrl, |
position: this.latLngFin |
}); |
google.maps.event.addListener(this.markerFin, 'dragend', this.surDeplacementMarkerFin.bind(this)); |
} else { |
this.markerFin.setMap(null); |
} |
} |
|
WidgetSaisieFlorileges.prototype.deplacerMakerFin = function(nouvellePosition) { |
this.latLngFin = nouvellePosition; |
this.markerFin.setMap(this.map); |
this.markerFin.setPosition(this.latLngFin); |
this.dessinerLigneRue(this.latLngDeb, this.latLngFin); |
} |
|
WidgetSaisieFlorileges.prototype.surDeplacementMarkerFin = function() { |
this.dessinerLigneRue(this.markerDeb.getPosition(), this.markerFin.getPosition()); |
this.afficherCentreRue(); |
this.afficherEtapeGeolocalisation(4); |
} |
|
WidgetSaisieFlorileges.prototype.dessinerLigneRue = function(pointDebut, pointFin) { |
if (this.ligneRue != undefined) { |
this.ligneRue.setMap(null); |
} |
|
this.ligneRue = new google.maps.Polyline({ |
path: [pointDebut, pointFin], |
strokeColor: "#FF0000", |
strokeOpacity: 1.0, |
strokeWeight: 2 |
}); |
|
this.ligneRue.setMap(this.map); |
} |
|
WidgetSaisieFlorileges.prototype.afficherCentreRue = function() { |
this.latLngDeb = this.markerDeb.getPosition(); |
this.latLngFin = this.markerFin.getPosition(); |
this.latLngCentre = new google.maps.LatLng((this.latLngFin.lat() + this.latLngDeb.lat())/2, (this.latLngFin.lng() + this.latLngDeb.lng())/2); |
this.mettreAJourMarkerPosition(this.latLngCentre); |
} |
|
WidgetSaisieFlorileges.prototype.afficherEtapeGeolocalisation = function(numEtape) { |
$('.liste_indication_geolocalisation').children().hide(); |
$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show(); |
} |
|
WidgetSaisieFlorileges.prototype.geolocaliser = function(event) { |
var latitude = $('#latitude').val(), |
longitude = $('#longitude').val(), |
nouvellePosition = new google.maps.LatLng(latitude, longitude); |
this.initialiserMarkerDeb(); |
this.deplacerMarkerDeb(nouvellePosition); |
this.afficherEtapeGeolocalisation(2); |
this.map.setZoom(16); |
arreter(event); |
} |
|
WidgetSaisieFlorileges.prototype.tenterGeolocalisation = function() { |
if (navigator.geolocation) { |
navigator.geolocation.getCurrentPosition(function(position) { |
var latitude = position.coords.latitude, |
longitude = position.coords.longitude, |
nouvellePosition = new google.maps.LatLng(latitude, longitude); |
this.initialiserMarkerDeb(); |
this.deplacerMarkerDeb(nouvellePosition); |
this.map.setZoom(16); |
}); |
} |
} |
|
WidgetSaisieFlorileges.prototype.surClickDansCarte = function(event) { |
this.deplacerMarkerDeb(event.latLng); |
} |
|
WidgetSaisieFlorileges.prototype.transformerEnSlider = function(selector) { |
$(selector).each(function(index, el) { |
// hide the element |
282,6 → 410,45 |
} |
} |
|
WidgetSaisieFlorileges.prototype.surChangementTaxonListe = function() { |
if ($('#taxon-liste').val() === '?') { |
$('#taxon-input-groupe').removeClass('hidden'); |
} else { |
$('#taxon-input-groupe').addClass('hidden'); |
} |
} |
|
WidgetSaisieFlorileges.prototype.configurerFormValidator = function() { |
$.validator.addMethod( |
'dateCel', |
function (value, element) { |
return value == '' || (/^[0-9]{2}[-\/][0-9]{2}[-\/][0-9]{4}$/.test(value)); |
}, |
'Format : jj/mm/aaaa. Date incomplète, utiliser 0, exemple : 00/12/2011.'); |
|
$.extend($.validator.defaults, { |
ignore: [],// Forcer Jquery Validate à examiner les éléments avec en display:none; |
highlight: function(element) { |
$(element).closest('.control-group').removeClass('success').addClass('error'); |
}, |
success: function(element) { |
element.text('OK!').addClass('valid'); |
element.closest('.control-group').removeClass('error').addClass('success'); |
|
if (element.attr('id') == 'taxon' && $('#taxon').val() != '') { |
// Si le taxon n'est pas lié au référentiel, on vide le data associé |
if ($('#taxon').data('value') != $('#taxon').val()) { |
$('#taxon').data('numNomSel', ''); |
$('#taxon').data('nomRet', ''); |
$('#taxon').data('numNomRet', ''); |
$('#taxon').data('nt', ''); |
$('#taxon').data('famille', ''); |
} |
} |
} |
}); |
} |
|
WidgetSaisieFlorileges.prototype.definirReglesFormValidator = function() { |
$('#form-observateur').validate({ |
rules: { |
374,7 → 541,7 |
return ok; |
} |
|
/*WidgetSaisieFlorileges.prototype.ajouterObs = function() { |
WidgetSaisieFlorileges.prototype.ajouterObs = function() { |
if (this.validerFormulaire() == true) { |
this.obsNbre = this.obsNbre + 1; |
$('.obs-nbre').text(this.obsNbre); |
391,7 → 558,7 |
this.afficherPanneau('#dialogue-form-invalide'); |
} |
} |
}*/ |
} |
|
WidgetSaisieFlorileges.prototype.afficherObs = function() { |
var lthis = this; |
457,8 → 624,106 |
$('#zone-liste-obs').removeClass("hidden").show(); |
} |
|
WidgetSaisieFlorileges.prototype.getMilieux = function() { |
var milieuxStr = '', |
milieux = []; |
$('.cb-milieux:checked').each(function() { |
milieux.push($(this).val()); |
}); |
|
milieuxStr = Array.prototype.slice.call(milieux).join(', '); |
return milieuxStr; |
} |
|
WidgetSaisieFlorileges.prototype.ajouterImgMiniatureAuTransfert = function() { |
var html = '', |
miniatures = '', |
indicateurs = '', |
premiere = true, |
numero = 1; |
if ($('#miniatures img').length == 0) { |
html = '<img class="miniature" alt="Aucune photo"src="'+ this.pasDePhotoIconeUrl +'" />'; |
} else if ($('#miniatures img').length >= 1) { |
$('#miniatures img').each(function() { |
var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee', |
css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature', |
src = $(this).attr('src'), |
alt = $(this).attr('alt'); |
|
var miniature = '<img class="'+css+' '+visible+'" alt="'+alt+'"src="'+src+'" />'; |
miniatures += miniature; |
|
var indicateurActif = premiere ? 'active' : ''; |
var indicateur = '<li class="' + indicateurActif + '" data-numero="' + numero++ + '"></li>'; |
indicateurs += indicateur; |
|
premiere = false; |
}); |
|
if ($('#miniatures img').length == 1) { |
html = miniatures; |
} else { |
html = |
'<div class="defilement">' + |
miniatures + |
'<a class="defilement-control-zone gauche">' + |
' <span class="defilement-control gauche hidden"><</span>' + |
'</a>' + |
'<a class="defilement-control-zone droite">' + |
' <span class="defilement-control droite hidden">></span>' + |
'</a>' + |
'<ol class="defilement-indicateurs">' + indicateurs + '</ol>' + |
'</div>'; |
} |
} |
return html; |
} |
|
WidgetSaisieFlorileges.prototype.defilerMiniatures = function(element) { |
var miniatureSelectionne = element.siblings('img.miniature-selectionnee'); |
miniatureSelectionne.removeClass('miniature-selectionnee').addClass('miniature-cachee'); |
var miniatureAffichee = miniatureSelectionne; |
|
var indicateurActif = element.parent().find('.defilement-indicateurs .active'); |
indicateurActif.removeClass('active'); |
|
if (element.hasClass('defilement-control-zone') && element.hasClass('gauche')) { |
if (miniatureSelectionne.prev('.miniature').length != 0) { |
miniatureAffichee = miniatureSelectionne.prev('.miniature'); |
indicateurActif.prev().addClass('active'); |
} else { |
miniatureAffichee = miniatureSelectionne.siblings('.miniature').last(); |
indicateurActif.siblings().last().addClass('active'); |
} |
} else { |
if (miniatureSelectionne.next('.miniature').length != 0) { |
miniatureAffichee = miniatureSelectionne.next('.miniature'); |
indicateurActif.next().addClass('active'); |
} else { |
miniatureAffichee = miniatureSelectionne.siblings('.miniature').first(); |
indicateurActif.siblings().first().addClass('active'); |
} |
} |
miniatureAffichee.addClass('miniature-selectionnee').removeClass('miniature-cachee'); |
} |
|
WidgetSaisieFlorileges.prototype.formaterNumNomSel = function(numNomSel) { |
var nn = ''; |
if (numNomSel == undefined) { |
nn = '<span class="alert-error">[non lié au référentiel]</span>'; |
} else { |
nn = '<span class="nn">[nn'+numNomSel+']</span>'; |
} |
return nn; |
} |
|
// tentativé d'héritage |
/*function surChangementReferentiel() { |
NOM_SCI_REFERENTIEL = $('#referentiel').val(); |
$('#taxon').val(''); |
}*/ |
|
WidgetSaisieFlorileges.prototype.stockerObsData = function() { |
|
var nomHorsListe = $('#taxon-liste').val() == '?' ? true : false; |
nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'), |
numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(), |
500,14 → 765,33 |
} |
|
WidgetSaisieFlorileges.prototype.getObsChpEtendus = function() { |
// super() |
var champs = WidgetSaisieSauvages.prototype.getObsChampsEtendus.call(this); |
|
var perceptionTechnicien = this.getPerceptionTechnicien(); |
var champs = [], |
perceptionTechnicien = this.getPerceptionTechnicien(); |
if (perceptionTechnicien != undefined) { |
champs.push(perceptionTechnicien); |
} |
if (this.latLngDeb != undefined) { |
var latitudeDebutRue = {cle: 'latitudeDebutRue', label: 'Latitude du début de la rue', valeur: this.latLngDeb.lat().toFixed(5)}; |
champs.push(latitudeDebutRue); |
var longitudeDebutRue = {cle: 'longitudeDebutRue', label: 'Longitude du début de la rue', valeur: this.latLngDeb.lng().toFixed(5)}; |
champs.push(longitudeDebutRue); |
} |
if (this.latLngFin != undefined) { |
var latitudeFinRue = {cle: 'latitudeFinRue', label: 'Latitude de fin de la rue', valeur: this.latLngFin.lat().toFixed(5)}; |
champs.push(latitudeFinRue); |
var longitudeFinRue = {cle: 'longitudeFinRue', label: 'Longitude de fin de la rue', valeur: this.latLngFin.lng().toFixed(5)}; |
champs.push(longitudeFinRue); |
} |
|
$('.obs-chp-etendu').each(function() { |
var valeur = $(this).val(), |
cle = $(this).attr('name'), |
label = $(this).data('label'); |
if (valeur != '') { |
var chpEtendu = {cle: cle, label: label, valeur: valeur}; |
champs.push(chpEtendu); |
} |
}); |
return champs; |
} |
|