Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2687 → Rev 2688

/trunk/widget/modules/saisie/Saisie.php
1,17 → 1,15
<?php
// declare(encoding='UTF-8');
/**
* Widget fournissant des interfaces de saisies simplifiée pour différent projets.
* Encodage en entrée : utf8
* Encodage en sortie : utf8
* Widget fournissant des interfaces de saisie simplifiée pour différent projets
*
* Cas d'utilisation et documentation :
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetSaisie
* @link http://www.tela-botanica.org/wikini/AideCarnetEnLigne/wakka.php?wiki=AideCELWidgetSaisie
*
* Paramètres :
* ===> projet = chaine [par défaut : defaut] : indique le widgetde saisie à charger.
* ===> mission = chaine [par défaut : vide] : permet de charger un "sous-widget" vis à vis du projet.
* Indique quel projet nous voulons charger
* - projet [par défaut : defaut] : indique le mot-clé à associer aux obs saisies; si un widget de saisie personnalisé
* portant ce nom existe, il sera chargé
* - mission [par défaut : vide] : permet de charger un "sous-widget", dans le cas où un widget personnalisé
* est associé au projet, et ce widget accepte des sous-widgets (ex: "missions-flore")
*
* @author Mathias CHOUET <mathias@tela-botanica.org>
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
18,7 → 16,7
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
* @copyright 1999-2015 Tela Botanica <accueil@tela-botanica.org>
*/
class Saisie extends WidgetCommun {
 
29,34 → 27,41
const WS_OBS = 'CelObs';
const WS_NOM = 'noms';
const EFLORE_API_VERSION = '0.1';
const REFERENTIEL_DEFAUT = 'bdtfx';
 
private $ns_referentiel = 'bdtfx';
private $projet = null;
private $configProjet = null;
private $configMission = null;
/** référentiel utilisé pour al complétion des noms scientifiques */
protected $ns_referentiel;
/** mot-clé associé aux saisies, et template personnalisé si appliquable */
protected $projet = null;
protected $configProjet = null;
protected $configMission = null;
 
/**
* Méthode appelée par défaut pour charger ce widget.
* Amorçage du widget
*/
public function executer() {
$retour = null;
extract($this->parametres);
// paramètres par défaut
$this->ns_referentiel = self::REFERENTIEL_DEFAUT;
$this->projet = self::PROJET_DEFAUT;
 
$this->projet = self::PROJET_DEFAUT;
if (isset($projet) && trim($projet) != "") {
$projets = explode(',', $projet);
// définition du projet / mission
if (isset($this->parametres['projet']) && trim($this->parametres['projet']) != "") {
$projets = explode(',', $this->parametres['projet']);
$this->projet = strtolower($projets[0]);
}
$this->chargerConfigProjet();
 
$service = isset($service) ? $service : 'widget';
// exécution du service (le widget entier ou une sous-partie, par ex "Taxons")
$retour = null;
$service = isset($this->parametres['service']) ? $this->parametres['service'] : 'widget';
$methode = $this->traiterNomMethodeExecuter($service);
if (method_exists($this, $methode)) {
$retour = $this->$methode();
} else {
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
$this->messages[] = "Le service '$methode' n'est pas disponible.";
}
 
// injection des données dans le squelette
$contenu = null;
$mime = null;
if (is_array($retour) && array_key_exists('squelette', $retour)) {
70,15 → 75,21
$mime = isset($retour['mime']) ? $retour['mime'] : null;
} else {
if (count($this->messages) == 0) {
$this->messages[] = "La méthode du sous-service ne renvoie pas les données dans le bon format.";
$this->messages[] = "La méthode du sous-service ne renvoie pas les données dans le bon format";
}
$contenu = 'Un problème est survenu : '.print_r($this->messages, true);
$contenu = 'Un problème est survenu : ' . print_r($this->messages, true);
}
 
// envoi de la page
$this->envoyer($contenu, $mime);
}
 
private function chargerConfigProjet() {
/**
* Charge le fichier de configuration associé au projet : configurations/nomduprojet.ini
* Si une mission est définie, charge séparément la section de la configuration concernant
* cette mission : [nommission]
*/
protected function chargerConfigProjet() {
$fichier_config = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'.ini';
if (file_exists($fichier_config)) {
if ($this->configProjet = parse_ini_file($fichier_config, true)) {
87,25 → 98,31
if (isset($this->configProjet[$mission])) {
$this->configMission = $this->configProjet[$mission];
}
}
}
} else {
$this->messages[] = "Le fichier ini '$fichier_config' du projet n'a pu être chargé.";
$this->messages[] = "Le fichier de configuration '$fichier_config' n'a pu être chargé.";
}
} else {
$this->debug[] = "Le fichier ini '$fichier_config' du projet n'existe pas.";
$this->debug[] = "Le fichier de configuration '$fichier_config' n'existe pas.";
}
}
 
private function projetASquelette() {
// fonction très simple qui ne teste que si le dossier du projet courant
// existe, mais elle suffit pour le moment.
/**
* Retourne true si le dossier du projet courant existe, false sinon
* @return boolean
*/
protected function projetASquelette() {
return file_exists(dirname(__FILE__).self::DS.'squelettes'.self::DS.$this->projet);
}
 
/**
* Exécution du widget complet
* @return Ambigous <string, unknown, multitype:string unknown >
*/
public function executerWidget() {
$referentiel_impose = false;
if (isset($_GET['referentiel']) && $_GET['referentiel'] != '' && $_GET['referentiel'] != "autre") {
$this->ns_referentiel = isset($_GET['referentiel']) && $_GET['referentiel'] != '' ? $_GET['referentiel'] : $this->ns_referentiel;
$this->ns_referentiel = $_GET['referentiel'];
$referentiel_impose = true;
}
 
138,7 → 155,7
if ($this->especeEstImposee()) {
$nnEspeceImposee = $this->getNnEspeceImposee();
$nom = $this->executerChargementInfosTaxon($nnEspeceImposee);
$nom = $this->chargerInfosTaxon($nnEspeceImposee);
$widget['donnees']['espece_imposee'] = true;
$widget['donnees']['nn_espece_defaut'] = $nnEspeceImposee;
$widget['donnees']['nom_sci_espece_defaut'] = $nom['nom_sci'];
164,7 → 181,7
return $widget;
}
 
private function getTitrePage() {
protected function getTitrePage() {
$titre = 'defaut';
if (isset($this->configProjet['titre_page'])) {
$titre = $this->configProjet['titre_page'];
181,6 → 198,11
return $titre;
}
 
/**
* Remplit un fichier JS avec une variable contenant une liste restreinte de taxons,
* pour certains projets
* @return string
*/
public function executerTaxons() {
$widget['squelette'] = $this->projet.'_taxons';
$widget['squelette_ext'] = '.tpl.js';
194,7 → 216,10
return $widget;
}
 
private function recupererListeNomsSci() {
/**
* Trie par nom français les taxons lus dans le fichier tsv
*/
protected function recupererListeNomsSci() {
$taxons = $this->recupererListeTaxon();
if (is_array($taxons)) {
$taxons = self::trierTableauMd($taxons, array('nom_fr' => SORT_ASC));
202,7 → 227,11
return $taxons;
}
 
private function recupererListeNoms() {
/**
* @TODO documenter
* @return array
*/
protected function recupererListeNoms() {
$taxons = $this->recupererListeTaxon();
$nomsAAfficher = array();
$nomsSpeciaux = array();
243,8 → 272,11
return array('speciaux' => $nomsSpeciaux, 'sci-et-fr' => $nomsAAfficher);
}
 
private function recupererListeTaxon() {
$taxons = null;
/**
* Lit une liste de taxons depuis un fichier tsv fourni
*/
protected function recupererListeTaxon() {
$taxons = array();
$fichier_tsv = dirname(__FILE__).self::DS.'configurations'.self::DS.$this->projet.'_taxons.tsv';
if (file_exists($fichier_tsv) && is_readable($fichier_tsv)) {
$taxons = $this->decomposerFichierTsv($fichier_tsv);
254,7 → 286,10
return $taxons;
}
 
private function decomposerFichierTsv($fichier, $delimiter = "\t"){
/**
* Découpe un fihcier tsv
*/
protected function decomposerFichierTsv($fichier, $delimiter = "\t"){
$header = null;
$data = array();
if (($handle = fopen($fichier, 'r')) !== FALSE) {
270,7 → 305,12
return $data;
}
 
private function parserMilieux() {
/**
* Récupère la liste des milieux depuis la section [milieux] de la configuration
* du projet, si elle existe
* @return array
*/
protected function parserMilieux() {
$infosMilieux = array();
if (isset($this->configProjet['milieux'])) {
$milieux = explode('|', $this->configProjet['milieux']);
288,12 → 328,21
return $infosMilieux;
}
 
private function especeEstImposee() {
return (isset($_GET['num_nom']) && $_GET['num_nom'] != ''
/**
* Retourne true si le widget est restreint à une espèce, false sinon
* @return boolean
*/
protected function especeEstImposee() {
return ((isset($_GET['num_nom']) && $_GET['num_nom'] != '')
|| isset($this->configProjet['sp_imposee']) || isset($this->configMission['sp_imposee']));
}
 
private function getNnEspeceImposee() {
/**
* Retourne le numéro nomenclatural (nn) de l'espèce imposée si tel est
* le cas, null sinon
* @return string
*/
protected function getNnEspeceImposee() {
$nn = null;
if (isset($_GET['num_nom']) && is_numeric($_GET['num_nom'])) {
$nn = $_GET['num_nom'];
305,10 → 354,17
return $nn;
}
 
private function executerChargementInfosTaxon($num_nom) {
/**
* Consulte un webservice pour obtenir des informations sur le taxon dont le
* numéro nomenclatural est $num_nom (ce sont donc plutôt des infos sur le nom
* et non le taxon?)
* @param string|int $num_nom
* @return array
*/
protected function chargerInfosTaxon($num_nom) {
$url_service_infos = sprintf($this->config['chemins']['infosTaxonUrl'], $this->ns_referentiel, $num_nom);
$infos = json_decode(file_get_contents($url_service_infos));
// trop de champs injectés dans les infos espèces peut
// trop de champs injectés dans les infos espèces peuvent
// faire planter javascript
$champs_a_garder = array('id', 'nom_sci','nom_sci_complet',
'famille','nom_retenu.id', 'nom_retenu.libelle', 'num_taxonomique');
323,7 → 379,13
return $resultat;
}
 
private function array2js($array,$show_keys) {
/**
* Convertit un tableau PHP en Javascript - @WTF pourquoi ne pas faire un json_encode ?
* @param array $array
* @param boolean $show_keys
* @return une portion de JSON représentant le tableau
*/
protected function array2js($array,$show_keys) {
$tableauJs = '{}';
if (!empty($array)) {
$total = count($array) - 1;
/trunk/widget/modules/saisie/squelettes/defaut/js/defaut.js
1,6 → 1,12
//+---------------------------------------------------------------------------------------------------------+
// GÉNÉRAL
/**
* Déclenchement des actions sur la page
*/
$(document).ready(function() {
// OMG un modèle objet !!
var widget = new WidgetSaisie();
widget.init();
 
// fermeture fenêtre
if (DEBUG == false) {
$(window).on('beforeunload', function(event) {
return 'Êtes vous sûr de vouloir quiter la page?\nLes observations saisies mais non transmises seront perdues.';
7,14 → 13,13
});
}
});
//+----------------------------------------------------------------------------------------------------------+
// FONCTIONS GÉNÉRIQUES
 
// lib
 
/**
* Stope l'évènement courrant quand on clique sur un lien.
* Utile pour Chrome, Safari...
* @param evenement
* @return
*/
* Stope l'évènement courant quand on clique sur un lien.
* Utile pour Chrome, Safari...
*/
function arreter(evenement) {
if (evenement.stopPropagation) {
evenement.stopPropagation();
25,6 → 30,11
return false;
}
 
/**
* Extrait les données de désinsectisation d'une requête AJAX de jQuery
* @param jqXHR
* @returns {String}
*/
function extraireEnteteDebug(jqXHR) {
var msgDebug = '';
if (jqXHR.getResponseHeader("X-DebugJrest-Data") != '') {
42,24 → 52,90
$(selecteur).fadeIn("slow").delay(DUREE_MESSAGE).fadeOut("slow");
}
 
//+----------------------------------------------------------------------------------------------------------+
//UPLOAD PHOTO : Traitement de l'image
$(document).ready(function() {
 
$(".effacer-miniature").click(function () {
supprimerMiniatures($(this));
 
 
/**
* Constructeur WidgetSaisie par défaut
*/
function WidgetSaisie() {
this.obsNbre = 0;
this.nbObsEnCours = 1;
this.totalObsATransmettre = 0;
this.nbObsTransmises = 0;
this.map = null;
this.marker = null;
this.latLng = null;
this.geocoder = null;
}
 
/**
* Initialisation du widget
*/
WidgetSaisie.prototype.init = function() {
this.initCarto();
this.initForm();
this.initEvts();
};
 
/**
* Initialise la cartographie
*/
WidgetSaisie.prototype.initCarto = function() {
this.initialiserGoogleMap();
this.initialiserAutocompleteCommune();
}
 
/**
* Initialise le formulaire, les validateurs, les listes de complétion...
*/
WidgetSaisie.prototype.initForm = function() {
if (OBS_ID != '') {
widget.chargerInfoObs();
}
 
this.configurerDatePicker();
this.ajouterAutocompletionNoms();
this.configurerFormValidator();
this.definirReglesFormValidator();
 
if(ESPECE_IMPOSEE) {
$("#taxon").attr("disabled", "disabled");
$("#taxon-input-groupe").attr("title","");
var infosAssociee = {
label : INFOS_ESPECE_IMPOSEE.nom_sci_complet,
value : INFOS_ESPECE_IMPOSEE.nom_sci_complet,
nt : INFOS_ESPECE_IMPOSEE.num_taxonomique,
nomSel : INFOS_ESPECE_IMPOSEE.nom_sci,
nomSelComplet : INFOS_ESPECE_IMPOSEE.nom_sci_complet,
numNomSel : INFOS_ESPECE_IMPOSEE.id,
nomRet : INFOS_ESPECE_IMPOSEE["nom_retenu.libelle"],
numNomRet : INFOS_ESPECE_IMPOSEE["nom_retenu.id"],
famille : INFOS_ESPECE_IMPOSEE.famille,
retenu : (INFOS_ESPECE_IMPOSEE.retenu == 'false') ? false : true
};
$("#taxon").data(infosAssociee);
}
}
 
/**
* Initialise les écouteurs d'événements
*/
WidgetSaisie.prototype.initEvts = function() {
var lthis = this;
$('body').on('click', '.effacer-miniature', function() {
$(this).parent().remove();
});
 
$("#fichier").bind('change', function (e) {
arreter(e);
var options = {
success: afficherMiniature, // post-submit callback
success: lthis.afficherMiniature.bind(lthis), // post-submit callback
dataType: 'xml', // 'xml', 'script', or 'json' (expected server response type)
resetForm: true // reset the form after successful submit
};
$("#miniature").append('<img id="miniature-chargement" class="miniature" alt="chargement" src="'+CHARGEMENT_IMAGE_URL+'"/>');
$("#ajouter-obs").attr('disabled', 'disabled');
if(verifierFormat($("#fichier").val())) {
if(lthis.verifierFormat($("#fichier").val())) {
$("#form-upload").ajaxSubmit(options);
} else {
$('#form-upload')[0].reset();
67,36 → 143,51
}
return false;
});
// idéntité
$("#courriel").on('blur', this.requeterIdentite.bind(this));
$("#courriel").on('keypress', this.testerLancementRequeteIdentite.bind(this));
$(".alert .close").on('click', this.fermerPanneauAlert);
$("[rel=tooltip]").tooltip('enable');
$("#btn-aide").on('click', this.basculerAffichageAide);
$("#prenom").on("change", this.formaterPrenom.bind(this));
$("#nom").on("change", this.formaterNom.bind(this));
 
if(ESPECE_IMPOSEE) {
$("#taxon").attr("disabled", "disabled");
$("#taxon-input-groupe").attr("title","");
var infosAssociee = new Object();
infosAssociee.label = INFOS_ESPECE_IMPOSEE.nom_sci_complet;
infosAssociee.value = INFOS_ESPECE_IMPOSEE.nom_sci_complet;
infosAssociee.nt = INFOS_ESPECE_IMPOSEE.num_taxonomique;
infosAssociee.nomSel = INFOS_ESPECE_IMPOSEE.nom_sci;
infosAssociee.nomSelComplet = INFOS_ESPECE_IMPOSEE.nom_sci_complet;
infosAssociee.numNomSel = INFOS_ESPECE_IMPOSEE.id;
infosAssociee.nomRet = INFOS_ESPECE_IMPOSEE["nom_retenu.libelle"];
infosAssociee.numNomRet = INFOS_ESPECE_IMPOSEE["nom_retenu.id"];
infosAssociee.famille = INFOS_ESPECE_IMPOSEE.famille;
infosAssociee.retenu = (INFOS_ESPECE_IMPOSEE.retenu == 'false') ? false : true;
$("#taxon").data(infosAssociee);
}
$("#courriel_confirmation").on('paste', this.bloquerCopierCollerCourriel.bind(this));
$("a.afficher-coord").on('click', this.basculerAffichageCoord.bind(this));
$("#ajouter-obs").on('click', this.ajouterObs.bind(this));
$(".obs-nbre").on('changement', this.surChangementNbreObs.bind(this));
$("body").on('click', ".supprimer-obs", function() {
var that = this,
suppObs = lthis.supprimerObs.bind(lthis);
// bricolage pour avoir les deux contextes en même temps (objet et elt. du DOM)
suppObs(that);
});
$("#transmettre-obs").on('click', this.transmettreObs.bind(this));
$("#referentiel").on('change', this.surChangementReferentiel.bind(this));
 
$('.effacer-miniature').live('click', function() {
$(this).parent().remove();
$("body").on('click', ".defilement-miniatures-gauche", function(event) {
event.preventDefault();
lthis.defilerMiniatures($(this));
});
});
$("body").on('click', ".defilement-miniatures-droite", function(event) {
event.preventDefault();
lthis.defilerMiniatures($(this));
});
}
 
function verifierFormat(nom) {
/**
* Retourne true si l'extension de l'image "nom" est .jpg ou .jpeg
*/
WidgetSaisie.prototype.verifierFormat = function(nom) {
var parts = nom.split('.');
extension = parts[parts.length - 1];
return (extension.toLowerCase() == 'jpeg' || extension.toLowerCase() == 'jpg');
}
};
 
function afficherMiniature(reponse) {
/**
* Affiche la miniature d'une image temporaire (formulaire) qu'on a ajoutée à l'obs
*/
WidgetSaisie.prototype.afficherMiniature = function(reponse) {
if (DEBUG) {
var debogage = $("debogage", reponse).text();
//console.log("Débogage upload : "+debogage);
105,12 → 196,15
if (message != '') {
$("#miniature-msg").append(message);
} else {
$("#miniatures").append(creerWidgetMiniature(reponse));
$("#miniatures").append(this.creerWidgetMiniature(reponse));
}
$('#ajouter-obs').removeAttr('disabled');
}
};
 
function creerWidgetMiniature(reponse) {
/**
* Crée la miniature d'une image temporaire (formulaire), avec le bouton pour l'effacer
*/
WidgetSaisie.prototype.creerWidgetMiniature = function(reponse) {
var miniatureUrl = $("miniature-url", reponse).text();
var imgNom = $("image-nom", reponse).text();
var html =
119,18 → 213,24
'<button class="effacer-miniature" type="button">Effacer</button>'+
'</div>'
return html;
}
};
 
function supprimerMiniatures() {
/**
* Efface toutes les miniatures (formulaire)
*/
WidgetSaisie.prototype.supprimerMiniatures = function() {
$("#miniatures").empty();
$("#miniature-msg").empty();
}
};
 
//Initialise l'autocomplétion de la commune, en fonction du référentiel
function initialiserAutocompleteCommune() {
/**
* Initialise l'autocomplétion de la commune, en fonction du référentiel
*/
WidgetSaisie.prototype.initialiserAutocompleteCommune = function() {
var geocoderOptions = {
};
var addressSuffix = '';
},
addressSuffix = '',
lthis = this;
 
switch(NOM_SCI_REFERENTIEL) {
case 'isfan':
158,7 → 258,7
source: function(request, response) {
geocoderOptions.address = request.term + addressSuffix;
console.log('Geocoder options', geocoderOptions);
geocoder.geocode( geocoderOptions, function(results, status) {
lthis.geocoder.geocode( geocoderOptions, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
response($.map(results, function(item) {
var retour = {
170,7 → 270,7
return retour;
}));
} else {
afficherErreurGoogleMap(status);
lthis.afficherErreurGoogleMap(status);
}
});
},
177,7 → 277,7
// Cette partie est executee a la selection d'une adresse
select: function(event, ui) {
var latLng = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
deplacerMarker(latLng);
lthis.deplacerMarker(latLng);
}
});
 
188,7 → 288,6
$("#carte-recherche").on('mouseup', function(event) {// Pour Safari...
event.preventDefault();
});
 
$("#carte-recherche").keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
196,19 → 295,7
});
};
 
//+----------------------------------------------------------------------------------------------------------+
// GOOGLE MAP
var map;
var marker;
var latLng;
var geocoder;
 
$(document).ready(function() {
initialiserGoogleMap();
initialiserAutocompleteCommune();
});
 
function afficherErreurGoogleMap(status) {
WidgetSaisie.prototype.afficherErreurGoogleMap = function(status) {
if (DEBUG) {
$('#dialogue-google-map .contenu').empty().append(
'<pre class="msg-erreur">'+
216,44 → 303,49
'</pre>');
afficherPanneau('#dialogue-google-map');
}
}
};
 
function surDeplacementMarker() {
trouverCommune(marker.getPosition());
mettreAJourMarkerPosition(marker.getPosition());
}
WidgetSaisie.prototype.surDeplacementMarker = function() {
this.trouverCommune(this.marker.getPosition());
this.mettreAJourMarkerPosition(this.marker.getPosition());
};
 
function surClickDansCarte(event) {
deplacerMarker(event.latLng);
}
WidgetSaisie.prototype.surClickDansCarte = function(event) {
this.deplacerMarker(event.latLng);
};
 
function geolocaliser() {
/**
* Place le marqueur aux coordonnées indiquées dans les champs "latitude" et "longitude"
*/
WidgetSaisie.prototype.geolocaliser = function() {
var latitude = $('#latitude').val();
var longitude = $('#longitude').val();
latLng = new google.maps.LatLng(latitude, longitude);
deplacerMarker(latLng);
}
this.latLng = new google.maps.LatLng(latitude, longitude);
this.deplacerMarker(this.latLng);
};
 
function initialiserGoogleMap(){
WidgetSaisie.prototype.initialiserGoogleMap = function() {
var latLng,
zoomDefaut;
// Carte @TODO mettre ça dans la config
if(NOM_SCI_REFERENTIEL == 'bdtre') {
var latLng = new google.maps.LatLng(-21.10, 55.30);// Réunion
var zoomDefaut = 7;
latLng = new google.maps.LatLng(-21.10, 55.30);// Réunion
zoomDefaut = 7;
} else if(NOM_SCI_REFERENTIEL == 'lbf') {
var latLng = new google.maps.LatLng(33.72211, 35.8603);// Liban
var zoomDefaut = 7;
latLng = new google.maps.LatLng(33.72211, 35.8603);// Liban
zoomDefaut = 7;
} else if(NOM_SCI_REFERENTIEL == 'bdtxa') {
var latLng = new google.maps.LatLng(14.6, -61.08334);// Fort-De-France
var zoomDefaut = 8;
latLng = new google.maps.LatLng(14.6, -61.08334);// Fort-De-France
zoomDefaut = 8;
} else if(NOM_SCI_REFERENTIEL == 'isfan') {
var latLng = new google.maps.LatLng(29.28358, 10.21884);// Afrique du Nord
var zoomDefaut = 4;
latLng = new google.maps.LatLng(29.28358, 10.21884);// Afrique du Nord
zoomDefaut = 4;
} else if(NOM_SCI_REFERENTIEL == 'apd') {
var latLng = new google.maps.LatLng(8.75624, 1.80176);// Afrique de l'Ouest et du Centre
var zoomDefaut = 4;
latLng = new google.maps.LatLng(8.75624, 1.80176);// Afrique de l'Ouest et du Centre
zoomDefaut = 4;
} else {
var latLng = new google.maps.LatLng(46.30871, 2.54395);// Centre de la France
var zoomDefaut = 5;
latLng = new google.maps.LatLng(46.30871, 2.54395);// Centre de la France
zoomDefaut = 5;
}
 
var options = {
278,15 → 370,15
});
 
// Création de la carte Google
map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
map.mapTypes.set('OSM', osmMapType);
this.map = new google.maps.Map(document.getElementById('map-canvas'), options); //affiche la google map dans la div map_canvas
this.map.mapTypes.set('OSM', osmMapType);
 
// Création du Geocoder
geocoder = new google.maps.Geocoder();
this.geocoder = new google.maps.Geocoder();
 
// Marqueur google draggable
marker = new google.maps.Marker({
map: map,
this.marker = new google.maps.Marker({
map: this.map,
draggable: true,
title: 'Ma station',
icon: GOOGLE_MAP_MARQUEUR_URL,
293,7 → 385,7
position: latLng
});
 
initialiserMarker(latLng);
this.initialiserMarker(latLng);
 
// Tentative de geocalisation
if (navigator.geolocation) {
300,51 → 392,51
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
latLng = new google.maps.LatLng(latitude, longitude);
deplacerMarker(latLng);
this.latLng = new google.maps.LatLng(latitude, longitude);
this.deplacerMarker(this.latLng);
});
}
 
// intéraction carte
$("#geolocaliser").on('click', geolocaliser);
google.maps.event.addListener(marker, 'dragend', surDeplacementMarker);
google.maps.event.addListener(map, 'click', surClickDansCarte);
}
$("#geolocaliser").on('click', this.geolocaliser.bind(this));
google.maps.event.addListener(this.marker, 'dragend', this.surDeplacementMarker.bind(this));
google.maps.event.addListener(this.map, 'click', this.surClickDansCarte.bind(this));
};
 
function initialiserMarker(latLng) {
if (marker != undefined) {
marker.setPosition(latLng);
map.setCenter(latLng);
WidgetSaisie.prototype.initialiserMarker = function(latLng) {
if (this.marker != undefined) {
this.marker.setPosition(latLng);
this.map.setCenter(latLng);
}
}
};
 
function deplacerMarker(latLng) {
if (marker != undefined) {
marker.setPosition(latLng);
map.setCenter(latLng);
mettreAJourMarkerPosition(latLng);
trouverCommune(latLng);
WidgetSaisie.prototype.deplacerMarker = function(latLng) {
if (this.marker != undefined) {
this.marker.setPosition(latLng);
this.map.setCenter(latLng);
this.mettreAJourMarkerPosition(latLng);
this.trouverCommune(latLng);
}
}
};
 
function mettreAJourMarkerPosition(latLng) {
WidgetSaisie.prototype.mettreAJourMarkerPosition = function(latLng) {
var lat = latLng.lat().toFixed(5);
var lng = latLng.lng().toFixed(5);
remplirChampLatitude(lat);
remplirChampLongitude(lng);
}
this.remplirChampLatitude(lat);
this.remplirChampLongitude(lng);
};
 
function remplirChampLatitude(latDecimale) {
WidgetSaisie.prototype.remplirChampLatitude = function(latDecimale) {
var lat = Math.round(latDecimale * 100000) / 100000;
$('#latitude').val(lat);
}
};
 
function remplirChampLongitude(lngDecimale) {
WidgetSaisie.prototype.remplirChampLongitude = function(lngDecimale) {
var lng = Math.round(lngDecimale * 100000) / 100000;
$('#longitude').val(lng);
}
};
 
function trouverCommune(pos) {
WidgetSaisie.prototype.trouverCommune = function(pos) {
$(function() {
 
var url_service = SERVICE_NOM_COMMUNE_URL;
407,23 → 499,20
}
});
});
}
};
//+---------------------------------------------------------------------------------------------------------+
// IDENTITÉ
$(document).ready(function() {
$("#courriel").on('blur', requeterIdentite);
$("#courriel").on('keypress', testerLancementRequeteIdentite);
});
 
function testerLancementRequeteIdentite(event) {
WidgetSaisie.prototype.testerLancementRequeteIdentite = function(event) {
if (event.which == 13) {
requeterIdentite();
event.preventDefault();
event.stopPropagation();
this.requeterIdentite();
this.event.preventDefault();
this.event.stopPropagation();
}
}
};
 
function requeterIdentite() {
WidgetSaisie.prototype.requeterIdentite = function() {
var lthis = this;
var courriel = $("#courriel").val();
//TODO: mettre ceci en paramètre de config
var urlAnnuaire = SERVICE_ANNUAIRE_ID_URL+courriel;//http://localhost/applications/annuaire/jrest/
441,12 → 530,12
$("#prenom, #nom, #courriel_confirmation").attr('disabled', 'disabled');
$("#date").focus();
} else {
surErreurCompletionCourriel();
lthis.surErreurCompletionCourriel();
}
},
error : function(jqXHR, textStatus, errorThrown) {
//console.log('ERREUR :'+textStatus);
surErreurCompletionCourriel();
lthis.surErreurCompletionCourriel();
},
complete : function(jqXHR, textStatus) {
//console.log('COMPLETE :'+textStatus);
454,22 → 543,17
$("#zone-courriel-confirmation").removeClass("hidden");
}
});
}
};
 
function surErreurCompletionCourriel() {
WidgetSaisie.prototype.surErreurCompletionCourriel = function() {
$("#prenom, #nom, #courriel_confirmation").val('');
$("#prenom, #nom, #courriel_confirmation").removeAttr('disabled');
afficherPanneau("#dialogue-courriel-introuvable");
}
};
//+---------------------------------------------------------------------------------------------------------+
//FORMULAIRE
$(document).ready(function() {
if (OBS_ID != '') {
chargerInfoObs();
}
});
 
function chargerInfoObs() {
WidgetSaisie.prototype.chargerInfoObs = function() {
var urlObs = SERVICE_OBS_URL + '/' + OBS_ID;
$.ajax({
url: urlObs,
476,7 → 560,7
type: 'GET',
success: function(data, textStatus, jqXHR) {
if (data != undefined && data != "") {
prechargerForm(data);
this.prechargerForm(data);
}
// TODO: voir s'il est pertinent d'indiquer quelque chose en cas d'erreur ou d'obs
// inexistante
485,9 → 569,9
// TODO: cf TODO ci-dessus
}
});
}
};
 
function prechargerForm(data) {
WidgetSaisie.prototype.prechargerForm = function(data) {
 
$("#milieu").val(data.milieu);
 
501,58 → 585,14
 
if(data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
var latLng = new google.maps.LatLng(data.latitude, data.longitude);
mettreAJourMarkerPosition(latLng);
marker.setPosition(latLng);
map.setCenter(latLng);
map.setZoom(16);
this.mettreAJourMarkerPosition(latLng);
this.marker.setPosition(latLng);
this.map.setCenter(latLng);
this.map.setZoom(16);
}
}
};
 
var obsNbre = 0;
 
$(document).ready(function() {
$(".alert .close").on('click', fermerPanneauAlert);
 
$("[rel=tooltip]").tooltip('enable');
$("#btn-aide").on('click', basculerAffichageAide);
 
$("#prenom").on("change", formaterPrenom);
 
$("#nom").on("change", formaterNom);
 
configurerDatePicker();
 
ajouterAutocompletionNoms();
 
configurerFormValidator();
definirReglesFormValidator();
 
$("#courriel_confirmation").on('paste', bloquerCopierCollerCourriel);
 
$("a.afficher-coord").on('click', basculerAffichageCoord);
 
$("#ajouter-obs").on('click', ajouterObs);
 
$(".obs-nbre").on('changement', surChangementNbreObs);
 
$("body").on('click', ".supprimer-obs", supprimerObs);
 
$("#transmettre-obs").on('click', transmettreObs);
 
$("#referentiel").on('change', surChangementReferentiel);
 
$("body").on('click', ".defilement-miniatures-gauche", function(event) {
event.preventDefault();
defilerMiniatures($(this));
});
 
$("body").on('click', ".defilement-miniatures-droite", function(event) {
event.preventDefault();
defilerMiniatures($(this));
});
});
 
function configurerFormValidator() {
WidgetSaisie.prototype.configurerFormValidator = function() {
$.validator.addMethod(
"dateCel",
function (value, element) {
577,7 → 617,7
if ($(element).attr('id') == 'taxon') {
if ($("#taxon").val() != '') {
// Si le taxon n'est pas lié au référentiel, on vide le data associé
if($("#taxon").data("value") != $("#taxon").val()) {
if ($("#taxon").data("value") != $("#taxon").val()) {
$("#taxon").data("numNomSel","");
$("#taxon").data("nomRet","");
$("#taxon").data("numNomRet","");
594,9 → 634,9
}
}
});
}
};
 
function definirReglesFormValidator() {
WidgetSaisie.prototype.definirReglesFormValidator = function() {
$("#form-observateur").validate({
rules: {
courriel : {
621,9 → 661,9
taxon : "required"
}
});
}
};
 
function configurerDatePicker() {
WidgetSaisie.prototype.configurerDatePicker = function() {
$.datepicker.setDefaults($.datepicker.regional["fr"]);
$("#date").datepicker({
dateFormat: "dd/mm/yy",
635,17 → 675,17
showButtonPanel: true
});
$("img.ui-datepicker-trigger").appendTo("#date-icone");
}
};
 
function fermerPanneauAlert() {
WidgetSaisie.prototype.fermerPanneauAlert = function() {
$(this).parentsUntil(".zone-alerte", ".alert").hide();
}
};
 
function formaterNom() {
WidgetSaisie.prototype.formaterNom = function() {
$(this).val($(this).val().toUpperCase());
}
};
 
function formaterPrenom() {
WidgetSaisie.prototype.formaterPrenom = function() {
var prenom = new Array();
var mots = $(this).val().split(' ');
for (var i = 0; i < mots.length; i++) {
665,9 → 705,9
}
}
$(this).val(prenom.join(' '));
}
};
 
function basculerAffichageAide() {
WidgetSaisie.prototype.basculerAffichageAide = function() {
if ($(this).hasClass('btn-warning')) {
$("[rel=tooltip]").tooltip('enable');
$(this).removeClass('btn-warning').addClass('btn-success');
677,59 → 717,65
$(this).removeClass('btn-success').addClass('btn-warning');
$('#btn-aide-txt', this).text("Activer l'aide");
}
}
};
 
function bloquerCopierCollerCourriel() {
WidgetSaisie.prototype.bloquerCopierCollerCourriel = function() {
afficherPanneau("#dialogue-bloquer-copier-coller");
return false;
}
};
 
function basculerAffichageCoord() {
WidgetSaisie.prototype.basculerAffichageCoord = function() {
$("a.afficher-coord").toggle();
$("#coordonnees-geo").toggle('slow');
//valeur false pour que le lien ne soit pas suivi
return false;
}
};
 
function ajouterObs() {
if (validerFormulaire() == true) {
obsNbre = obsNbre + 1;
$(".obs-nbre").text(obsNbre);
/**
* Ajoute une observation saisie dans le formulaire à la liste des observations à transmettre
*/
WidgetSaisie.prototype.ajouterObs = function() {
if (this.validerFormulaire() == true) {
this.obsNbre = this.obsNbre + 1;
$(".obs-nbre").text(this.obsNbre);
$(".obs-nbre").triggerHandler('changement');
afficherObs();
stockerObsData();
supprimerMiniatures();
this.afficherObs();
this.stockerObsData();
this.supprimerMiniatures();
if(!ESPECE_IMPOSEE) {
$("#taxon").val("");
$("#taxon").data("numNomSel",undefined);
}
$('#barre-progression-upload').attr('aria-valuemax', obsNbre);
$('#barre-progression-upload .sr-only').text('0/'+obsNbre+" observations transmises");
$('#barre-progression-upload').attr('aria-valuemax', this.obsNbre);
$('#barre-progression-upload .sr-only').text('0/'+this.obsNbre+" observations transmises");
} else {
afficherPanneau('#dialogue-form-invalide');
}
}
};
 
function afficherObs() {
/**
* Affiche une observation dans la liste des observations à transmettre
*/
WidgetSaisie.prototype.afficherObs = function() {
$("#liste-obs").prepend(
'<div id="obs'+obsNbre+'" class="row-fluid obs obs'+obsNbre+'">'+
'<div id="obs'+this.obsNbre+'" class="row-fluid obs obs'+this.obsNbre+'">'+
'<div class="span12">'+
'<div class="well">'+
'<div class="obs-action pull-right" rel="tooltip" data-placement="bottom" '+
'title="Supprimer cette observation de la liste à transmettre">'+
'<button class="btn btn-danger supprimer-obs" value="'+obsNbre+'" title="'+obsNbre+'">'+
'<button class="btn btn-danger supprimer-obs" value="'+this.obsNbre+'" title="'+this.obsNbre+'">'+
'<i class="icon-trash icon-white"></i>'+
'</button>'+
'</div> '+
'<div class="row-fluid">'+
'<div class="thumbnail span2">'+
ajouterImgMiniatureAuTransfert()+
this.ajouterImgMiniatureAuTransfert()+
'</div>'+
'<div class="span9">'+
'<ul class="unstyled">'+
'<li>'+
'<span class="nom-sci">'+$("#taxon").val()+'</span> '+
ajouterNumNomSel()+'<span class="referentiel-obs">'+
this.ajouterNumNomSel()+'<span class="referentiel-obs">'+
($("#taxon").data("numNomSel") == undefined ? '' : '['+NOM_SCI_REFERENTIEL+']')+'</span>'+
' observé à '+
'<span class="commune">'+$('#commune-nom').text()+'</span> '+
751,10 → 797,11
'</div>'+
'</div>'+
'</div>');
}
};
 
function stockerObsData() {
$("#liste-obs").data('obsId'+obsNbre, {
WidgetSaisie.prototype.stockerObsData = function() {
var lthis = this;
$("#liste-obs").data('obsId'+this.obsNbre, {
'date' : $("#date").val(),
'notes' : $("#notes").val(),
 
775,47 → 822,45
'milieu' : $("#milieu").val(),
 
//Ajout des champs images
'image_nom' : getNomsImgsOriginales(),
'image_b64' : getB64ImgsOriginales()
'image_nom' : lthis.getNomsImgsOriginales(),
'image_b64' : lthis.getB64ImgsOriginales()
});
}
};
 
function surChangementReferentiel() {
WidgetSaisie.prototype.surChangementReferentiel = function() {
NOM_SCI_REFERENTIEL = $('#referentiel').val();
$('#taxon').val('');
initialiserAutocompleteCommune();
initialiserGoogleMap();
}
this.initialiserAutocompleteCommune();
this.initialiserGoogleMap();
};
 
function surChangementNbreObs() {
if (obsNbre == 0) {
WidgetSaisie.prototype.surChangementNbreObs = function() {
if (this.obsNbre == 0) {
$("#transmettre-obs").attr('disabled', 'disabled');
$("#ajouter-obs").removeAttr('disabled');
} else if (obsNbre > 0 && obsNbre < OBS_MAX_NBRE) {
} else if (this.obsNbre > 0 && this.obsNbre < OBS_MAX_NBRE) {
$("#transmettre-obs").removeAttr('disabled');
$("#ajouter-obs").removeAttr('disabled');
} else if (obsNbre >= OBS_MAX_NBRE) {
} else if (this.obsNbre >= OBS_MAX_NBRE) {
$("#ajouter-obs").attr('disabled', 'disabled');
afficherPanneau("#dialogue-bloquer-creer-obs");
}
}
};
 
var nbObsEnCours = 1;
var totalObsATransmettre = 0;
function transmettreObs() {
WidgetSaisie.prototype.transmettreObs = function() {
var observations = $("#liste-obs").data();
if (observations == undefined || jQuery.isEmptyObject(observations)) {
afficherPanneau("#dialogue-zero-obs");
} else {
nbObsEnCours = 1;
nbObsTransmises = 0;
totalObsATransmettre = $.map(observations, function(n, i) { return i; }).length;
depilerObsPourEnvoi();
this.nbObsEnCours = 1;
this.nbObsTransmises = 0;
this.totalObsATransmettre = $.map(observations, function(n, i) { return i; }).length;
this.depilerObsPourEnvoi();
}
return false;
}
};
 
function depilerObsPourEnvoi() {
WidgetSaisie.prototype.depilerObsPourEnvoi = function() {
var observations = $("#liste-obs").data();
// la boucle est factice car on utilise un tableau
// dont on a besoin de n'extraire que le premier élément
823,12 → 868,12
// TODO: utiliser var.keys quand ça sera plus répandu
// ou bien utiliser un vrai tableau et pas un objet
for (var obsNum in observations) {
obsATransmettre = new Object();
obsATransmettre = {
'projet' : TAG_PROJET,
'tag-obs' : TAG_OBS,
'tag-img' : TAG_IMG
};
 
obsATransmettre['projet'] = TAG_PROJET;
obsATransmettre['tag-obs'] = TAG_OBS;
obsATransmettre['tag-img'] = TAG_IMG;
 
var utilisateur = new Object();
utilisateur.id_utilisateur = $("#id_utilisateur").val();
utilisateur.prenom = $("#prenom").val();
838,28 → 883,28
obsATransmettre[obsNum] = observations[obsNum];
var idObsNumerique = obsNum.replace('obsId', '');
if(idObsNumerique != "") {
envoyerObsAuCel(idObsNumerique, obsATransmettre);
this.envoyerObsAuCel(idObsNumerique, obsATransmettre);
}
 
break;
}
}
};
 
var nbObsTransmises = 0;
function mettreAJourProgression() {
nbObsTransmises++;
var pct = (nbObsTransmises/totalObsATransmettre)*100;
$('#barre-progression-upload').attr('aria-valuenow', nbObsTransmises);
WidgetSaisie.prototype.mettreAJourProgression = function() {
this.nbObsTransmises++;
var pct = (this.nbObsTransmises/this.totalObsATransmettre)*100;
$('#barre-progression-upload').attr('aria-valuenow', this.nbObsTransmises);
$('#barre-progression-upload').attr('style', "width: "+pct+"%");
$('#barre-progression-upload .sr-only').text(nbObsTransmises+"/"+totalObsATransmettre+" observations transmises");
$('#barre-progression-upload .sr-only').text(this.nbObsTransmises+"/"+this.totalObsATransmettre+" observations transmises");
 
if(obsNbre == 0) {
if(this.obsNbre == 0) {
$('.progress').removeClass('active');
$('.progress').removeClass('progress-striped');
}
}
};
 
function envoyerObsAuCel(idObs, observation) {
WidgetSaisie.prototype.envoyerObsAuCel = function(idObs, observation) {
var lthis = this;
var erreurMsg = "";
$.ajax({
url : SERVICE_SAISIE_URL,
877,13 → 922,13
success : function(data, textStatus, jqXHR) {
// mise à jour du nombre d'obs à transmettre
// et suppression de l'obs
supprimerObsParId(idObs);
nbObsEnCours++;
lthis.supprimerObsParId(idObs);
this.nbObsEnCours++;
// mise à jour du statut
mettreAJourProgression();
if(obsNbre > 0) {
lthis.mettreAJourProgression();
if(this.obsNbre > 0) {
// dépilement de la suivante
depilerObsPourEnvoi();
lthis.depilerObsPourEnvoi();
}
},
statusCode : {
927,18 → 972,18
.html());
$("#dialogue-obs-transaction-ko").show();
$("#chargement").hide();
initialiserBarreProgression();
lthis.initialiserBarreProgression();
} else {
if (DEBUG) {
$("#dialogue-obs-transaction-ok .alert-txt").append('<pre class="msg-debug">Débogage : '+debugMsg+'</pre>');
}
if(obsNbre == 0) {
if(this.obsNbre == 0) {
setTimeout(function() {
$("#chargement").hide();
$('#dialogue-obs-transaction-ok .alert-txt').append($('#tpl-transmission-ok').clone().html());
$("#dialogue-obs-transaction-ok").show();
window.location.hash = "dialogue-obs-transaction-ok";
initialiserObs();
lthis.initialiserObs();
}, 1500);
 
}
945,24 → 990,24
}
}
});
}
};
 
function validerFormulaire() {
WidgetSaisie.prototype.validerFormulaire = function() {
$observateur = $("#form-observateur").valid();
$station = $("#form-station").valid();
$obs = $("#form-obs").valid();
return ($observateur == true && $station == true && $obs == true) ? true : false;
}
};
 
function getNomsImgsOriginales() {
WidgetSaisie.prototype.getNomsImgsOriginales = function() {
var noms = new Array();
$(".miniature-img").each(function() {
noms.push($(this).attr('alt'));
});
return noms;
}
};
 
function getB64ImgsOriginales() {
WidgetSaisie.prototype.getB64ImgsOriginales = function() {
var b64 = new Array();
$(".miniature-img").each(function() {
if ($(this).hasClass('b64')) {
973,58 → 1018,63
});
 
return b64;
}
};
 
function supprimerObs() {
var obsId = $(this).val();
WidgetSaisie.prototype.supprimerObs = function(selector) {
var obsId = $(selector).val();
// Problème avec IE 6 et 7
if (obsId == "Supprimer") {
obsId = $(this).attr("title");
obsId = $(selector).attr("title");
}
supprimerObsParId(obsId);
}
this.supprimerObsParId(obsId);
};
 
function supprimerObsParId(obsId) {
obsNbre = obsNbre - 1;
$(".obs-nbre").text(obsNbre);
WidgetSaisie.prototype.supprimerObsParId = function(obsId) {
this.obsNbre = this.obsNbre - 1;
$(".obs-nbre").text(this.obsNbre);
$(".obs-nbre").triggerHandler('changement');
$('.obs'+obsId).remove();
$("#liste-obs").removeData('obsId'+obsId);
}
};
 
function initialiserBarreProgression() {
WidgetSaisie.prototype.initialiserBarreProgression = function() {
$('#barre-progression-upload').attr('aria-valuenow', 0);
$('#barre-progression-upload').attr('style', "width: 0%");
$('#barre-progression-upload .sr-only').text("0/0 observations transmises");
$('.progress').addClass('active');
$('.progress').addClass('progress-striped');
}
};
 
function initialiserObs() {
obsNbre = 0;
nbObsTransmises = 0;
nbObsEnCours = 0;
totalObsATransmettre = 0;
initialiserBarreProgression();
$(".obs-nbre").text(obsNbre);
WidgetSaisie.prototype.initialiserObs = function() {
this.obsNbre = 0;
this.nbObsTransmises = 0;
this.nbObsEnCours = 0;
this.totalObsATransmettre = 0;
this.initialiserBarreProgression();
$(".obs-nbre").text(this.obsNbre);
$(".obs-nbre").triggerHandler('changement');
$("#liste-obs").removeData();
$('.obs').remove();
$("#dialogue-bloquer-creer-obs").hide();
}
};
 
function ajouterImgMiniatureAuTransfert() {
var html = '';
var miniatures = '';
var premiere = true;
/**
* Ajoute une boîte de miniatures avec défilement des images,
* pour une obs de la liste des obs à transmettre
*/
WidgetSaisie.prototype.ajouterImgMiniatureAuTransfert = function() {
var html = '',
miniatures = '',
premiere = true;
if ($("#miniatures img").length >= 1) {
$("#miniatures img").each(function() {
var visible = premiere ? 'miniature-selectionnee' : 'miniature-cachee';
premiere = false;
var css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature';
var src = $(this).attr("src");
var alt = $(this).attr("alt");
miniature = '<img class="'+css+' '+visible+'" alt="'+alt+'"src="'+src+'" />';
var css = $(this).hasClass('b64') ? 'miniature b64' : 'miniature',
src = $(this).attr("src"),
alt = $(this).attr("alt"),
//miniature = '<img class="'+css+' '+visible+'" alt="'+alt+'"src="'+src+'" />';
miniature = '<div class="'+css+' '+visible+'" alt="'+alt+'" style="background-image: url('+src+')" ></div>';
miniatures += miniature;
});
visible = ($("#miniatures img").length > 1) ? '' : 'defilement-miniatures-cache';
1038,11 → 1088,11
html = '<img class="miniature" alt="Aucune photo"src="'+PAS_DE_PHOTO_ICONE_URL+'" />';
}
return html;
}
};
 
function defilerMiniatures(element) {
WidgetSaisie.prototype.defilerMiniatures = function(element) {
 
var miniatureSelectionne = element.siblings("img.miniature-selectionnee");
var miniatureSelectionne = element.siblings("div.miniature-selectionnee");
miniatureSelectionne.removeClass('miniature-selectionnee');
miniatureSelectionne.addClass('miniature-cachee');
var miniatureAffichee = miniatureSelectionne;
1063,9 → 1113,9
//console.log(miniatureAffichee);
miniatureAffichee.addClass('miniature-selectionnee');
miniatureAffichee.removeClass('miniature-cachee');
}
};
 
function ajouterNumNomSel() {
WidgetSaisie.prototype.ajouterNumNomSel = function() {
var nn = '';
if ($("#taxon").data("numNomSel") == undefined) {
nn = '<span class="alert-error">[non lié au référentiel]</span>';
1073,20 → 1123,21
nn = '<span class="nn">[nn'+$("#taxon").data("numNomSel")+']</span>';
}
return nn;
}
};
 
//+---------------------------------------------------------------------------------------------------------+
// AUTO-COMPLÉTION Noms Scientifiques
 
function ajouterAutocompletionNoms() {
WidgetSaisie.prototype.ajouterAutocompletionNoms = function() {
var lthis = this;
$('#taxon').autocomplete({
source: function(requete, add){
// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
requete = "";
if($("#referentiel").val() != "autre") {
var url = getUrlAutocompletionNomsSci();
var url = lthis.getUrlAutocompletionNomsSci();
$.getJSON(url, requete, function(data) {
var suggestions = traiterRetourNomsSci(data);
var suggestions = lthis.traiterRetourNomsSci(data);
add(suggestions);
});
}
1102,16 → 1153,16
$("#taxon").removeClass('ns-retenu');
}
});
}
};
 
function getUrlAutocompletionNomsSci() {
WidgetSaisie.prototype.getUrlAutocompletionNomsSci = function() {
var mots = $('#taxon').val();
var url = SERVICE_AUTOCOMPLETION_NOM_SCI_URL_TPL.replace('{referentiel}',NOM_SCI_REFERENTIEL);
url = url.replace('{masque}', mots);
return url;
}
};
 
function traiterRetourNomsSci(data) {
WidgetSaisie.prototype.traiterRetourNomsSci = function(data) {
var suggestions = [];
if (data.resultat != undefined) {
$.each(data.resultat, function(i, val) {
1144,7 → 1195,7
}
 
return suggestions;
}
};
 
/*
* jQuery UI Autocomplete HTML Extension
1160,7 → 1211,7
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
 
function filter( array, term ) {
WidgetSaisie.prototype.filter = function( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
/trunk/widget/modules/saisie/squelettes/defaut/css/defaut.css
42,6 → 42,19
margin:0 auto;
top:30%;
}
input#taxon {
width: 300px;
}
/* jQuery.validate dans ses versions récentes ne semble pas ajouter la classe help-inline
aux messages d'erreur */
.control-group .error {
color: #b94a48;
display: inline-block;
padding-left: 5px;
vertical-align: middle;
}
 
 
/*+--------------------------------------------------------------------------------------------------------+*/
/* Formulaire spécifique */
#map-canvas {
72,11 → 85,13
padding-top: 5px;
}
 
.miniature{
.miniature {
float: left;
height: 130px;
padding-left: 15px;
padding-right: 15px;
background-repeat: no-repeat;
background-size: cover;
}
 
.miniature-img {
/trunk/widget/modules/saisie/squelettes/defaut/defaut.tpl.html
33,23 → 33,20
 
<!-- Javascript : bibliothèques -->
<!-- Google Map v3 -->
<!--<script type="text/javascript" src="https://getfirebug.com/firebug-lite.js"></script>-->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true&amp;language=fr&amp;region=FR"></script>
 
<!-- Jquery -->
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/1.7.1/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/1.11.1/jquery-1.11.1.min.js"></script>
<!-- Jquery UI : nécessaire pour le minicalendrier et l'auto-complétion -->
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.18/js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.18/js/jquery.ui.datepicker-fr.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/jquery-ui/1.11.0/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/jquery-ui/1.11.0/js/datepicker-fr.js"></script>
<!-- Jquery Plugins -->
<!-- Jquery Validate : nécessaire pour la validation des formulaires -->
<script type="text/javascript" src="http://www.tela-botanica.org/commun/bootstrap/2.0.2/js/validate/1.9.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/validate/1.9.0/messages_fr.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/validate/1.11.1/jquery.validate.min.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/validate/1.11.1/messages_fr.js"></script>
<!-- Jquery Form :nécessaire pour l'upload des images -->
<script type="text/javascript" src="http://www.tela-botanica.org/commun/jquery/form/2.95/jquery.form.min.js"></script>
 
<script type="text/javascript" src="http://resources.tela-botanica.org/jquery/form/3.51/jquery.form.min.js"></script>
<!-- Bootstrap -->
<script type="text/javascript" src="http://www.tela-botanica.org/commun/bootstrap/2.0.2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://resources.tela-botanica.org/bootstrap/2.3.2/js/bootstrap.min.js"></script>
 
<!-- Javascript : appli saisie -->
<script type="text/javascript">
125,9 → 122,9
<script type="text/javascript" src="<?=$url_base?>modules/saisie/squelettes/defaut/js/defaut.js"></script>
 
<!-- CSS -->
<link href="http://www.tela-botanica.org/commun/jquery/jquery-ui/1.8.18/css/smoothness/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" media="screen" />
<link href="http://www.tela-botanica.org/commun/bootstrap/2.0.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="http://www.tela-botanica.org/commun/bootstrap/2.0.2/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="http://resources.tela-botanica.org/jquery/jquery-ui/1.11.0/css/themes/smoothness/jquery-ui.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="http://resources.tela-botanica.org/bootstrap/2.0.2/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="http://resources.tela-botanica.org/bootstrap/2.0.2/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" media="screen" />
<link href="<?=$url_base?>modules/saisie/squelettes/defaut/css/<?=isset($_GET['style']) ? $_GET['style'] : 'defaut'?>.css" rel="stylesheet" type="text/css" media="screen" />
<script>
208,7 → 205,7
</label>
<div class="input-prepend">
<span class="add-on"><i class="icon-envelope"></i></span>
<input id="courriel" class="input-medium" name="courriel" type="text"/>
<input id="courriel" class="input-large" name="courriel" type="text"/>
<input id="id_utilisateur" name="id_utilisateur" type="hidden"/>
</div>
</div>
220,7 → 217,7
<div class="input-prepend">
<span class="add-on">
<i class="icon-envelope"></i>
</span><input id="courriel_confirmation" class="input-medium" name="courriel_confirmation" type="text"/>
</span><input id="courriel_confirmation" class="input-large" name="courriel_confirmation" type="text"/>
</div>
</div>
</div>
/trunk/widget/bibliotheque/WidgetCommun.php
1,7 → 1,9
<?php
abstract class WidgetCommun {
 
/** contient la configuration globale pour tous les widgets (widget.ini) */
protected $config = null;
/** contient la configuration du widget courant (modules/nomduwidget/config.ini) */
protected $parametres = null;
protected $messages = array();
protected $debug = array();