Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2707 → Rev 2708

/trunk/widget/modules/saisie/squelettes/sauvages/js/WidgetSaisieSauvages.js
22,6 → 22,7
this.initialiserGoogleMap();
this.afficherEtapeGeolocalisation(1);
 
var lthis = this;
$('#carte-recherche').autocomplete({
//Cette partie utilise geocoder pour extraire des valeurs d'adresse
source: function(request, response) {
60,12 → 61,8
 
//surcharge
WidgetSaisieSauvages.prototype.initForm = function() {
//this.requeterIdentite();// Sur rechargement de la page
// Gestion de la liste des taxons
this.configurerDatePicker('#date');
this.ajouterAutocompletionNoms();
this.configurerFormValidator();
this.definirReglesFormValidator();
// super() à la main - toute autre manière de faire est über-komplex
WidgetSaisie.prototype.initForm.call(this);
 
this.surChangementTaxonListe();
$('#taxon-liste').on('change', this.surChangementTaxonListe);
190,9 → 187,7
google.maps.event.addListenerOnce(this.map, 'idle', function(){
// Initialisation du marker de début de rue
lthis.initialiserMarkerDeb();
if (this.obsId != '') {
lthis.chargerInfoObs();
} else {
if (this.obsId == '') {
// Tentative de geocalisation si aucune obs à précharger
lthis.tenterGeolocalisation();
}
202,6 → 197,10
this.geocoder = new google.maps.Geocoder();
};
 
WidgetSaisieSauvages.prototype.surClickDansCarte = function(event) {
this.deplacerMarkerDeb(event.latLng);
};
 
// surcharge
WidgetSaisieSauvages.prototype.prechargerForm = function(data) {
 
226,7 → 225,7
var deb = new google.maps.LatLng(data.extension.latitudeDebutRue.valeur, data.extension.longitudeDebutRue.valeur);
var fin = new google.maps.LatLng(data.extension.latitudeFinRue.valeur, data.extension.longitudeFinRue.valeur);
 
this.mettreAJourStationPosition(pos);
this.mettreAJourMarkerPosition(pos);
 
this.deplacerMarkerDeb(deb);
this.deplacerMarkerFin(fin);
274,7 → 273,7
this.latLngDeb = nouvellePosition;
this.markerDeb.setPosition(this.latLngDeb);
this.map.setCenter(this.latLngDeb);
this.mettreAJourStationPosition(this.latLngDeb);
this.mettreAJourMarkerPosition(this.latLngDeb);
this.trouverCommune(this.latLngDeb);
 
if (this.premierDeplacement) {
335,16 → 334,9
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.mettreAJourStationPosition(this.latLngCentre);
this.mettreAJourMarkerPosition(this.latLngCentre);
};
 
WidgetSaisieSauvages.prototype.mettreAJourStationPosition = function(latLng) {
var lat = latLng.lat().toFixed(5),
lng = latLng.lng().toFixed(5);
this.remplirChampLatitude(lat);
this.remplirChampLongitude(lng);
};
 
WidgetSaisieSauvages.prototype.afficherEtapeGeolocalisation = function(numEtape) {
$('.liste_indication_geolocalisation').children().hide();
$('.liste_indication_geolocalisation :nth-child('+numEtape+')').show();
751,12 → 743,12
nomSpecial = $('#taxon-liste option:selected').hasClass('nom-special'),
numNomSel = nomHorsListe ? $('#taxon').data('numNomSel') : $('#taxon-liste').val(),
nomSel = nomHorsListe ? $('#taxon').val() : $('#taxon-liste option:selected').data('nom-a-sauver'),
nomRet = nomHorsListe ? $('#taxon').data('nomRet') : taxons[numNomSel]['nom_ret'],
numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : taxons[numNomSel]['num_nom_ret'],
numTaxon = nomHorsListe ? $('#taxon').data('nt') : taxons[numNomSel]['num_taxon'],
famille = nomHorsListe ? $('#taxon').data('famille') : taxons[numNomSel]['famille'],
nomRet = nomHorsListe ? $('#taxon').data('nomRet') : this.taxons[numNomSel]['nom_ret'],
numNomRet = nomHorsListe ? $('#taxon').data('numNomRet') : this.taxons[numNomSel]['num_nom_ret'],
numTaxon = nomHorsListe ? $('#taxon').data('nt') : this.taxons[numNomSel]['num_taxon'],
famille = nomHorsListe ? $('#taxon').data('famille') : this.taxons[numNomSel]['famille'],
referentiel = (numNomSel == undefined) ? '' : this.nomSciReferentiel,
notes = (nomSpecial ? taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
notes = (nomSpecial ? this.taxons[numNomSel]['nom_fr'] + '. ' : '') + $('#notes').val();
certitude = $('input[name=certitude]:checked').val();
certitude = (certitude == undefined) ? '' : certitude;
/trunk/widget/modules/saisie/squelettes/florileges/florileges.tpl.html
36,6 → 36,7
 
<!-- Javascript : appli saisie -->
<script type="text/javascript" src="<?=$url_base?>modules/saisie/squelettes/defaut/js/WidgetSaisie.js"></script>
<script type="text/javascript" src="<?=$url_base?>modules/saisie/squelettes/sauvages/js/WidgetSaisieSauvages.js"></script>
<script type="text/javascript" src="<?=$url_base?>modules/saisie/squelettes/florileges/js/WidgetSaisieFlorileges.js"></script>
<script src="<?=$url_base?>saisie?projet=florileges&amp;service=taxons" type="text/javascript"></script>
<script type="text/javascript">
/trunk/widget/modules/saisie/squelettes/florileges/js/WidgetSaisieFlorileges.js
12,8 → 12,10
this.googleMapMarqueurFinUrl = null;
this.premierDeplacement = true;
}
WidgetSaisieFlorileges.prototype = new WidgetSaisie();
WidgetSaisieFlorileges.prototype = new WidgetSaisieSauvages();
 
 
// @TODO harmoniser avec Sauvages (rue)
WidgetSaisieFlorileges.prototype.initCarto = function() {
var lthis = this;
 
65,9 → 67,6
// 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();
});
108,9 → 107,11
$('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);
 
222,135 → 223,6
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
410,45 → 282,6
}
}
 
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: {
541,7 → 374,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);
558,7 → 391,7
this.afficherPanneau('#dialogue-form-invalide');
}
}
}
}*/
 
WidgetSaisieFlorileges.prototype.afficherObs = function() {
var lthis = this;
624,106 → 457,8
$('#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">&#60;</span>' +
'</a>' +
'<a class="defilement-control-zone droite">' +
' <span class="defilement-control droite hidden">&#62;</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(),
765,33 → 500,14
}
 
WidgetSaisieFlorileges.prototype.getObsChpEtendus = function() {
var champs = [],
perceptionTechnicien = this.getPerceptionTechnicien();
// super()
var champs = WidgetSaisieSauvages.prototype.getObsChampsEtendus.call(this);
 
var 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;
}