Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 981 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 981 Rev 984
1
/**-------------------------- Objets globaux -----------------------------------*/
1
/**-------------------------- Objets globaux -----------------------------------*/
2
/*
2
/*
3
 * Les variables suivantes sont ajoutée automatiquement dans le squelette du moteur de
3
 * Les variables suivantes sont ajoutée automatiquement dans le squelette du moteur de
4
 * recherche par php, elles sont commentées ici pour qu'elles n'aient pas l'air 
4
 * recherche par php, elles sont commentées ici pour qu'elles n'aient pas l'air 
5
 * de sortir de la cuisse de Jupiter
5
 * de sortir de la cuisse de Jupiter
6
 * 
6
 * 
7
 * var AUTOCOMPLETION_ELEMENTS_NBRE : indique le nombre d'éléments à afficher dans la liste d'autocomplétion.
7
 * var AUTOCOMPLETION_ELEMENTS_NBRE : indique le nombre d'éléments à afficher dans la liste d'autocomplétion.
8
 * 
8
 * 
9
 * var URL_SERVICE_AUTOCOMPLETION_NOM_SCI : url de base du service de complétion de noms scientifiques
9
 * var URL_SERVICE_AUTOCOMPLETION_NOM_SCI : url de base du service de complétion de noms scientifiques
10
 * pour le projet en cours de consultation. 
10
 * pour le projet en cours de consultation. 
11
 * Exemple : http://localhost/service:eflore:0.1/bdtfx/noms?recherche=etendue&retour.format=min&masque=Ace%mo
11
 * Exemple : http://localhost/service:eflore:0.1/bdtfx/noms?recherche=etendue&retour.format=min&masque=Ace%mo
12
 * 
12
 * 
13
 * var URL_SERVICE_AUTOCOMPLETION_NOM_VERNA : url de base du service de complétion de noms vernaculaires
13
 * var URL_SERVICE_AUTOCOMPLETION_NOM_VERNA : url de base du service de complétion de noms vernaculaires
14
 * pour le projet en cours de consultation. 
14
 * pour le projet en cours de consultation. 
15
 * Exemple : http://localhost/service:eflore:0.1/nvjfl/noms-vernaculaires?recherche=etendue&retour.format=oss&masque=aca&masque.lg=fra 
15
 * Exemple : http://localhost/service:eflore:0.1/nvjfl/noms-vernaculaires?recherche=etendue&retour.format=oss&masque=aca&masque.lg=fra 
16
 * 
16
 * 
17
 * var VALEUR_DEFAUT_NOM_SCI : Contient la valeur par défaut affichée dans le formulaire en mode sci
17
 * var VALEUR_DEFAUT_NOM_SCI : Contient la valeur par défaut affichée dans le formulaire en mode sci
18
 * Exemple: Rechercher un nom scientifique
18
 * Exemple: Rechercher un nom scientifique
19
 * 
19
 * 
20
 * var VALEUR_DEFAUT_NOM_VERNA : Contient la valeur par défaut affichée dans le formulaire en mode verna
20
 * var VALEUR_DEFAUT_NOM_VERNA : Contient la valeur par défaut affichée dans le formulaire en mode verna
21
 * Exemple: Recherche un nom commun
21
 * Exemple: Recherche un nom commun
22
 * 
22
 * 
23
 * var URL_BASE_POPUP : url de base pour les popup contenant du code un peu complexe
23
 * var URL_BASE_POPUP : url de base pour les popup contenant du code un peu complexe
24
 */
24
 */
25
 
25
 
26
var champs_ts = ["#au","#and","#anf","#nom","#bib"];
26
var champs_ts = ["#au","#and","#anf","#nom","#bib"];
27
var autocompletionFicheOuverte = false;
27
var autocompletionFicheOuverte = false;
28
var elementAutocompletionSelectionne = null;
28
var elementAutocompletionSelectionne = null;
29
var nomRechercheEnCours = null;
29
var nomRechercheEnCours = null;
30
 
30
 
31
$(document).ready(function() {
31
$(document).ready(function() {
32
	ajouterAutocompletion();
32
	ajouterAutocompletion();
33
	gererAffichageValeursParDefaut();
33
	gererAffichageValeursParDefaut();
34
	gererAccesFicheFlecheDroite();
34
	gererAccesFicheFlecheDroite();
35
	gererClicIllustrationsResultats();
35
	gererClicIllustrationsResultats();
36
	gererAccesFicheBouton();
36
	gererAccesFicheBouton();
37
});
37
});
38
 
38
 
39
/**------------------- Fonctions de gestion de l'autocompletion ---------------------------------*/
39
/**------------------- Fonctions de gestion de l'autocompletion ---------------------------------*/
40
function ajouterAutocompletion(){
40
function ajouterAutocompletion(){
41
	ajouterAutocompletionNoms();
41
	ajouterAutocompletionNoms();
42
	$('.champ_autocomplete').each(function(index) {
42
	$('.champ_autocomplete').each(function(index) {
43
		ajouterAutocompletionAvancee($(this));
43
		ajouterAutocompletionAvancee($(this));
44
	});
44
	});
45
}
45
}
46
 
46
 
47
function ajouterAutocompletionAvancee(champs){
47
function ajouterAutocompletionAvancee(champs){
48
	champs.autocomplete({			
48
	champs.autocomplete({			
49
		source: function(requete, add){  
49
		source: function(requete, add){  
50
		// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
50
		// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
51
			requete = "";
51
			requete = "";
52
			var id = champs.attr('id');
52
			var id = champs.attr('id');
53
			var url = encodeURI(getUrlAutocompletionAvancee(id));
53
			var url = encodeURI(getUrlAutocompletionAvancee(id));
54
				$.getJSON(url, requete, function(data) { 
54
				$.getJSON(url, requete, function(data) { 
55
			var suggestions = [];
55
			var suggestions = [];
56
			suggestions = traiterRetourAvance(data,champs);
56
			suggestions = traiterRetourAvance(data,champs);
57
			add(suggestions);  
57
			add(suggestions);  
58
			});
58
			});
59
		},
59
		},
60
    	html: true
60
    	html: true
61
	});
61
	});
62
}
62
}
63
 
63
 
64
function ajouterAutocompletionNoms() {
64
function ajouterAutocompletionNoms() {
65
	$('#nom').autocomplete({
65
	$('#nom').autocomplete({
66
		source: function(requete, add){  
66
		source: function(requete, add){  
67
			// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
67
			// la variable de requête doit être vidée car sinon le parametre "term" est ajouté
68
			requete = "";
68
			requete = "";
69
			var url = encodeURI(getUrlAppelCompletion());
69
			var url = encodeURI(getUrlAppelCompletion());
70
			$.getJSON(url, requete, function(data) {
70
			$.getJSON(url, requete, function(data) {
71
				var suggestions = [];
71
				var suggestions = [];
72
				if (nomVernaculaireEstDemande()) {
72
				if (nomVernaculaireEstDemande()) {
73
					suggestions = traiterRetourNomsVerna(data);
73
					suggestions = traiterRetourNomsVerna(data);
74
				} else if (nomSciEstDemande()) {
74
				} else if (nomSciEstDemande()) {
75
					suggestions = traiterRetourNomsSci(data);
75
					suggestions = traiterRetourNomsSci(data);
76
				}
76
				}
77
				add(suggestions);  
77
				add(suggestions);  
78
            });
78
            });
79
        },
79
        },
80
        search: function(event, ui) {
80
        search: function(event, ui) {
81
        	nomRechercheEnCours = 'nom_sci';
81
        	nomRechercheEnCours = 'nom_sci';
82
        },
82
        },
83
        focus: function(event, ui) {
83
        focus: function(event, ui) {
84
        	elementAutocompletionSelectionne = ui.item;
84
        	elementAutocompletionSelectionne = ui.item;
85
        },
85
        },
86
        open: function(event, ui) { 
86
        open: function(event, ui) { 
87
        	autocompletionFicheOuverte = true;
87
        	autocompletionFicheOuverte = true;
88
        	var parent = $('.autocompletion_nom.ui-menu-item').parent();
88
        	var parent = $('.autocompletion_nom.ui-menu-item').parent();
89
        	parent.width(parent.width() + 10);
89
        	parent.width(parent.width() + 10);
90
        },
90
        },
91
        close: function(event, ui) {
91
        close: function(event, ui) {
92
        	autocompletionFicheFermee = false;
92
        	autocompletionFicheFermee = false;
93
        	nomRechercheEnCours = null;
93
        	nomRechercheEnCours = null;
94
        },
94
        },
95
        html: true
95
        html: true
96
	});
96
	});
97
	
97
	
98
	$("#nom").bind("autocompleteselect", function(event, ui) {
98
	$("#nom").bind("autocompleteselect", function(event, ui) {
99
		if (ui.item.retenu == true) {
99
		if (ui.item.retenu == true) {
100
			$("#nom").addClass('ns-retenu');
100
			$("#nom").addClass('ns-retenu');
101
		} else {
101
		} else {
102
			$("#nom").removeClass('ns-retenu');
102
			$("#nom").removeClass('ns-retenu');
103
		}
103
		}
104
	});
104
	});
105
}
105
}
106
 
106
 
107
// gére l'acces direct à une fiche par l'appui sur droite
107
// gére l'acces direct à une fiche par l'appui sur droite
108
// dans la liste d'autocompletion des noms scientifiques
108
// dans la liste d'autocompletion des noms scientifiques
109
function gererAccesFicheFlecheDroite() {
109
function gererAccesFicheFlecheDroite() {
110
	$(document).keypress(function(event) {
110
	$(document).keypress(function(event) {
111
		// flèche droite
111
		// flèche droite
112
		if(event.keyCode == 39) {
112
		if(event.keyCode == 39) {
113
			if(autocompletionFicheOuverte && elementAutocompletionSelectionne != null && nomSciEstDemande()) {
113
			if(autocompletionFicheOuverte && elementAutocompletionSelectionne != null && nomSciEstDemande()) {
114
				$('#nom').val(elementAutocompletionSelectionne.value);
114
				$('#nom').val(elementAutocompletionSelectionne.value);
115
				if(elementAutocompletionSelectionne.nn != undefined && elementAutocompletionSelectionne.nn != null) {
115
				if(elementAutocompletionSelectionne.nn != undefined && elementAutocompletionSelectionne.nn != null) {
116
					var url_fiche_taxon = URL_BASE_FICHE_TAXON.replace('{num_taxon}',elementAutocompletionSelectionne.nn);
116
					var url_fiche_taxon = URL_BASE_FICHE_TAXON.replace('{num_taxon}',elementAutocompletionSelectionne.nn);
117
					window.location.href = url_fiche_taxon; 
117
					window.location.href = url_fiche_taxon; 
118
				}
118
				}
119
				$('#nom').autocomplete( "disable" );
119
				$('#nom').autocomplete( "disable" );
120
				//TODO : ajout d'un message de chargement ?
120
				//TODO : ajout d'un message de chargement ?
121
			}
121
			}
122
		}
122
		}
123
		
123
		
124
		if(event.keyCode == 13) {
124
		if(event.keyCode == 13) {
125
			if(autocompletionFicheOuverte && elementAutocompletionSelectionne == null && $('#nom').is(":focus")) {
125
			if(autocompletionFicheOuverte && elementAutocompletionSelectionne == null && $('#nom').is(":focus")) {
126
				$('#eflore_nomenclature_submit').click();
126
				$('#eflore_nomenclature_submit').click();
127
			}
127
			}
128
		}
128
		}
129
	});
129
	});
130
}
130
}
131
 
131
 
132
function gererAccesFicheBouton() {
132
function gererAccesFicheBouton() {
133
	$('#eflore_nomenclature_fiche').click(function(event) {
133
	$('#eflore_nomenclature_fiche').click(function(event) {
134
		if(elementAutocompletionSelectionne != null && nomSciEstDemande()) {
134
		if(elementAutocompletionSelectionne != null && nomSciEstDemande()) {
135
			$('#nom').val(elementAutocompletionSelectionne.value);
135
			$('#nom').val(elementAutocompletionSelectionne.value);
136
			if(elementAutocompletionSelectionne.nn != undefined && elementAutocompletionSelectionne.nn != null) {
136
			if(elementAutocompletionSelectionne.nn != undefined && elementAutocompletionSelectionne.nn != null) {
137
				var url_fiche_taxon = URL_BASE_FICHE_TAXON.replace('{num_taxon}',elementAutocompletionSelectionne.nn);
137
				var url_fiche_taxon = URL_BASE_FICHE_TAXON.replace('{num_taxon}',elementAutocompletionSelectionne.nn);
138
				window.location.href = url_fiche_taxon; 
138
				window.location.href = url_fiche_taxon; 
139
			}
139
			}
140
			event.preventDefault();
140
			event.preventDefault();
141
		}
141
		}
142
	});
142
	});
143
}
143
}
144
 
144
 
145
function traiterRetourNomsSci(data) {
145
function traiterRetourNomsSci(data) {
146
	var suggestions = [];  
146
	var suggestions = [];  
147
	if (data.resultat != undefined) {
147
	if (data.resultat != undefined) {
148
		$.each(data.resultat, function(i, val) {
148
		$.each(data.resultat, function(i, val) {
149
			val.nn = i;
149
			val.nn = i;
150
			var nom = {label : '', value : '', retenu : false};
150
			var nom = {label : '', value : '', retenu : false};
151
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
151
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
152
				nom.label = "...";
152
				nom.label = "...";
153
				nom.value = $('#nom').val();
153
				nom.value = $('#nom').val();
154
				suggestions.push(nom);
154
				suggestions.push(nom);
155
				return false;
155
				return false;
156
			} else {
156
			} else {
157
				nom.label = val.nom_sci_complet;
157
				nom.label = val.nom_sci_complet;
158
				nom.value = val.nom_sci;
158
				nom.value = val.nom_sci;
159
				nom.nn = val.nn;
159
				nom.nn = val.nn;
160
				if(val.retenu != "absent") {
160
				if(val.retenu != "absent") {
161
					nom.retenu = (val.retenu == 'true') ? true : false;
161
					nom.retenu = (val.retenu == 'true') ? true : false;
162
					suggestions.push(nom);
162
					suggestions.push(nom);
163
				}
163
				}
164
			}
164
			}
165
		});
165
		});
166
	}
166
	}
167
	return suggestions;
167
	return suggestions;
168
}
168
}
169
 
169
 
170
 
170
 
171
function traiterRetourAvance(data, champs) {
171
function traiterRetourAvance(data, champs) {
172
	var suggestions = [];  
172
	var suggestions = [];  
173
	if (jQuery.type(data) == "array") { 
173
	if (jQuery.type(data) == "array") { 
174
		$.each(data[1], function(i, val) {
174
		$.each(data[1], function(i, val) {
175
			var ch = {label : '', value : ''};
175
			var ch = {label : '', value : ''};
176
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
176
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
177
				ch.label = "...";
177
				ch.label = "...";
178
				ch.value = champs.val();
178
				ch.value = champs.val();
179
				suggestions.push(ch);
179
				suggestions.push(ch);
180
				return false;
180
				return false;
181
			} else {
181
			} else {
182
				ch.label = val;
182
				ch.label = val;
183
				ch.value = val;
183
				ch.value = val;
184
				suggestions.push(ch);
184
				suggestions.push(ch);
185
			}
185
			}
186
		});
186
		});
187
	}
187
	}
188
	return suggestions;
188
	return suggestions;
189
}
189
}
190
 
190
 
191
function traiterRetourNomsVerna(data) {
191
function traiterRetourNomsVerna(data) {
192
	var suggestions = [];
192
	var suggestions = [];
193
	if (jQuery.type(data) == "array") {
193
	if (jQuery.type(data) == "array") {
194
		$.each(data[1], function(i, val){
194
		$.each(data[1], function(i, val){
195
			var nom = {label : '', value : ''};
195
			var nom = {label : '', value : ''};
196
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
196
			if (suggestions.length >= AUTOCOMPLETION_ELEMENTS_NBRE) {
197
				nom.label = "...";
197
				nom.label = "...";
198
				nom.value = $('#nom').val();
198
				nom.value = $('#nom').val();
199
				suggestions.push(nom);
199
				suggestions.push(nom);
200
				return false;
200
				return false;
201
			} else {
201
			} else {
202
				nom.label = val;
202
				nom.label = val;
203
				nom.value = val;
203
				nom.value = val;
204
				suggestions.push(val);
204
				suggestions.push(val);
205
			}
205
			}
206
		});
206
		});
207
	}
207
	}
208
	return suggestions;
208
	return suggestions;
209
}
209
}
210
 
210
 
211
 
211
 
212
/**------------ Fonctions de gestion des urls d'autocompletion et des fiches ------------------*/
212
/**------------ Fonctions de gestion des urls d'autocompletion et des fiches ------------------*/
213
 
213
 
214
function getUrlAutocompletionAvancee(parametre) {
214
function getUrlAutocompletionAvancee(parametre) {
215
	var valeur = getValeurMasque(parametre);
215
	var valeur = getValeurMasque(parametre);
216
	var ns_str = getValeurNsStructure(parametre);
216
	var ns_str = getValeurNsStructure(parametre);
217
	var url = URL_SERVICE_AUTOCOMPLETION_NOM_SCI+"?recherche=etendue&"+
217
	var url = URL_SERVICE_AUTOCOMPLETION_NOM_SCI+"?recherche=etendue&"+
218
	"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE +'&masque.'+parametre+'='+valeur+
218
	"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE +'&masque.'+parametre+'='+valeur+
219
	'&retour.format=oss&distinct=1&ns.structure='+ns_str;
219
	'&retour.format=oss&distinct=1&ns.structure='+ns_str;
220
	return url;
220
	return url;
221
}
221
}
222
 
222
 
223
function getValeurMasque(parametre) {
223
function getValeurMasque(parametre) {
224
	var valeur = $('#'+parametre).val();
224
	var valeur = $('#'+parametre).val();
225
	if (parametre == 'au' ){
225
	if (parametre == 'au' ){
226
		valeur = valeur +',(' + valeur + ')';
226
		valeur = valeur +',(' + valeur + ')';
227
	} else if (parametre == 'bib' ){
227
	} else if (parametre == 'bib' ){
228
		valeur = valeur +', %; ' + valeur ;
228
		valeur = valeur +', %; ' + valeur ;
229
	}
229
	}
230
	return valeur;
230
	return valeur;
231
}
231
}
232
 
232
 
233
function getValeurNsStructure(parametre) {
233
function getValeurNsStructure(parametre) {
234
	var ns = '';
234
	var ns = '';
235
	if (parametre == 'au' || parametre == 'bib'){
235
	if (parametre == 'au' || parametre == 'bib'){
236
		ns = parametre +'_ss';
236
		ns = parametre +'_ss';
237
	} else {
237
	} else {
238
		ns = parametre;
238
		ns = parametre;
239
	}
239
	}
240
	return ns;
240
	return ns;
241
}
241
}
242
 
242
 
243
 
243
 
244
function getUrlAppelCompletion() {
244
function getUrlAppelCompletion() {
245
	var url = '';
245
	var url = '';
246
	var mots = $('#nom').val();
246
	var mots = $('#nom').val();
247
	if (nomSciEstDemande()) {
247
	if (nomSciEstDemande()) {
248
		url = getUrlAutocompletionNomsSci(mots);
248
		url = getUrlAutocompletionNomsSci(mots);
249
	} else if (nomVernaculaireEstDemande()) {
249
	} else if (nomVernaculaireEstDemande()) {
250
		mots = mots.replace('  ',' ');
250
		mots = mots.replace('  ',' ');
251
		mots = mots.replace(' ','_');
251
		mots = mots.replace(' ','_');
252
		url = getUrlAutocompletionNomsVerna(mots);
252
		url = getUrlAutocompletionNomsVerna(mots);
253
	}
253
	}
254
	return url;
254
	return url;
255
}
255
}
256
 
256
 
257
function getUrlAutocompletionNomsSci(requete) {
257
function getUrlAutocompletionNomsSci(requete) {
258
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_SCI, requete, 'min')+
258
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_SCI, requete, 'min')+
259
		"&ns.structure=au,an"+
259
		"&ns.structure=au,an"+
260
		"&retour.tri=retenu";
260
		"&retour.tri=retenu";
261
	return url;
261
	return url;
262
}
262
}
263
 
263
 
264
function getUrlAutocompletionNomsVerna(requete) {
264
function getUrlAutocompletionNomsVerna(requete) {
265
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_VERNA, requete, 'oss')+
265
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_VERNA, requete, 'oss')+
266
		"&masque.lg=fra";
266
		"&masque.lg=fra";
267
	return url;
267
	return url;
268
}
268
}
269
 
269
 
270
function getUrlAutocompletion(baseUrl, requete, format) {
270
function getUrlAutocompletion(baseUrl, requete, format) {
271
	var url = baseUrl+"?"+
271
	var url = baseUrl+"?"+
272
		"masque="+requete+"&"+
272
		"masque="+requete+"&"+
273
		"recherche=etendue&"+
273
		"recherche=etendue&"+
274
		"retour.format="+format+"&"+
274
		"retour.format="+format+"&"+
275
		"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE;
275
		"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE;
276
	return url;
276
	return url;
277
}
277
}
278
 
278
 
279
/**------------ Fonctions de détection de l'état du formulaire ------------------*/
279
/**------------ Fonctions de détection de l'état du formulaire ------------------*/
280
function nomSciEstDemande()  {
280
function nomSciEstDemande()  {
281
	var boutonRadioNomSci = $('#type_nom_scientifique');
281
	var boutonRadioNomSci = $('#type_nom_scientifique');
282
	return (($('#type_nom_vernaculaire').length <= 0) || (boutonRadioNomSci != null && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked"));
282
	return (($('#type_nom_vernaculaire').length <= 0) || (boutonRadioNomSci != null && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked"));
283
}
283
}
284
 
284
 
285
function nomVernaculaireEstDemande()  {
285
function nomVernaculaireEstDemande()  {
286
	var boutonRadioNomSci = $('#type_nom_vernaculaire');
286
	var boutonRadioNomSci = $('#type_nom_vernaculaire');
287
	return (boutonRadioNomSci.length > 0 && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
287
	return (boutonRadioNomSci.length > 0 && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
288
}
288
}
289
 
289
 
290
/**------------ Fonctions de gestion de l'affichage des valeurs par defaut ----------------------*/
290
/**------------ Fonctions de gestion de l'affichage des valeurs par defaut ----------------------*/
291
function gererAffichageValeursParDefaut() {
291
function gererAffichageValeursParDefaut() {
292
		$('input[name="type_nom"]').click(function() {
292
		$('input[name="type_nom"]').click(function() {
293
			changerPlaceHolderNom();
293
			changerPlaceHolderNom();
294
		});
294
		});
295
		changerPlaceHolderNom();
295
		changerPlaceHolderNom();
296
		$('input').click(function() {
296
		$('input').click(function() {
297
			$(this).attr('placeholder', '');			
297
			$(this).attr('placeholder', '');			
298
		});
298
		});
299
}
299
}
300
 
300
 
301
function changerPlaceHolderNom() {
301
function changerPlaceHolderNom() {
302
	if(nomSciEstDemande()) {
302
	if(nomSciEstDemande()) {
303
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_SCI);
303
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_SCI);
304
	} else {
304
	} else {
305
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_VERNA);
305
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_VERNA);
306
	}
306
	}
307
}
307
}
308
 
308
 
309
/**------------ Fonctions de gestion du zoom sur les images affichées dans les résultats de recherche ----------------------*/
309
/**------------ Fonctions de gestion du zoom sur les images affichées dans les résultats de recherche ----------------------*/
310
function gererClicIllustrationsResultats() {
310
function gererClicIllustrationsResultats() {
311
	$('.illustration_resultat_cel').click(function() {
311
	$('.illustration_resultat_cel').click(function() {
312
		var url = $(this).attr('src');
312
		var url = $(this).attr('src');
313
		var titre = trouverNomTaxon($(this));
313
		var titre = trouverNomTaxon($(this));
314
		var url = URL_BASE_POPUP+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('title')+"&titre="+titre+"&referentiel="+REFERENTIEL;
314
		var url = URL_BASE_POPUP+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('data-num-nom')+"&titre="+titre+"&referentiel="+REFERENTIEL;
315
		window.open(url, '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(700)+', height='+(650));
315
		window.open(url, '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(700)+', height='+(650));
316
	}); 
316
	}); 
317
	
317
	
318
	$('.illustration_resultat_choro').click(function() {
318
	$('.illustration_resultat_choro').click(function() {
319
		var url = $(this).attr('src').replace('108x101','432x404');
319
		var url = $(this).attr('src').replace('108x101','432x404');
320
		var titre = 'Chorologie du taxon '+trouverNomTaxon($(this));
320
		var titre = 'Chorologie du taxon '+trouverNomTaxon($(this));
321
		ouvrirFenetreIllustrationResultat(url, titre, 432, 404);
321
		ouvrirFenetreIllustrationResultat(url, titre, 432, 404);
322
	}); 
322
	}); 
323
	
323
	
324
	$('.illustration_resultat_coste').click(function() {
324
	$('.illustration_resultat_coste').click(function() {
325
		var url = $(this).attr('src');
325
		var url = $(this).attr('src');
326
		var titre = 'Illustration de Coste du taxon '+trouverNomTaxon($(this));
326
		var titre = 'Illustration de Coste du taxon '+trouverNomTaxon($(this));
327
		ouvrirFenetreIllustrationResultat(url, titre, 400, 400);
327
		ouvrirFenetreIllustrationResultat(url, titre, 400, 400);
328
	}); 
328
	}); 
329
}
329
}
330
 
330
 
331
function trouverNomTaxon(objet) {
331
function trouverNomTaxon(objet) {
332
	nom = "";
332
	nom = "";
333
	if(nomVernaculaireEstDemande()) {
333
	if(nomVernaculaireEstDemande()) {
334
		nom = objet.parent().parent().find('a.lien_fiche_eflore').text();
334
		nom = objet.parent().parent().find('a.lien_fiche_eflore').text();
335
	} else {
335
	} else {
336
		nom = objet.parent().find('.nom-sci a.lien_fiche_eflore').text();
336
		nom = objet.parent().find('.nom-sci a.lien_fiche_eflore').text();
337
	}
337
	}
338
	return nom;
338
	return nom;
339
}
339
}
340
 
340
 
341
function ouvrirFenetreIllustrationResultat(url, titre, hauteur, largeur) {
341
function ouvrirFenetreIllustrationResultat(url, titre, hauteur, largeur) {
342
	var fenetre = window.open('_blank', '','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(largeur+17)+', height='+(hauteur+17));
342
	var fenetre = window.open('_blank', '','directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(largeur+17)+', height='+(hauteur+17));
343
	var tmp = fenetre.document;
343
	var tmp = fenetre.document;
344
	tmp.write('<html><head><title>'+titre+'</title>');
344
	tmp.write('<html><head><title>'+titre+'</title>');
345
	tmp.write('</head><body>');
345
	tmp.write('</head><body>');
346
	tmp.write('<p style="height='+hauteur+'px;text-align:center;line-height='+hauteur+'px;"><img id="image_agrandie" height="'+hauteur+'" width="'+largeur+'" style="vertical-align:middle;" src="'+url+'" /></p>');
346
	tmp.write('<p style="height='+hauteur+'px;text-align:center;line-height='+hauteur+'px;"><img id="image_agrandie" height="'+hauteur+'" width="'+largeur+'" style="vertical-align:middle;" src="'+url+'" /></p>');
347
	tmp.write('</body></html>');
347
	tmp.write('</body></html>');
348
	tmp.close();
348
	tmp.close();
349
}
349
}
350
 
350
 
351
/*
351
/*
352
 * jQuery UI Autocomplete HTML Extension
352
 * jQuery UI Autocomplete HTML Extension
353
 *
353
 *
354
 * Copyright 2010, Scott González (http://scottgonzalez.com)
354
 * Copyright 2010, Scott González (http://scottgonzalez.com)
355
 * Dual licensed under the MIT or GPL Version 2 licenses.
355
 * Dual licensed under the MIT or GPL Version 2 licenses.
356
 *
356
 *
357
 * http://github.com/scottgonzalez/jquery-ui-extensions
357
 * http://github.com/scottgonzalez/jquery-ui-extensions
358
 * 
358
 * 
359
 * Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides
359
 * Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides
360
 */
360
 */
361
(function( $ ) {
361
(function( $ ) {
362
	var proto = $.ui.autocomplete.prototype,
362
	var proto = $.ui.autocomplete.prototype,
363
		initSource = proto._initSource;
363
		initSource = proto._initSource;
364
	
364
	
365
	function filter( array, term ) {
365
	function filter( array, term ) {
366
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
366
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
367
		return $.grep( array, function(value) {
367
		return $.grep( array, function(value) {
368
			return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
368
			return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
369
		});
369
		});
370
	}
370
	}
371
	
371
	
372
	$.extend( proto, {
372
	$.extend( proto, {
373
		_initSource: function() {
373
		_initSource: function() {
374
			if (this.options.html && $.isArray(this.options.source) ) {
374
			if (this.options.html && $.isArray(this.options.source) ) {
375
				this.source = function( request, response ) {
375
				this.source = function( request, response ) {
376
					response( filter( this.options.source, request.term ) );
376
					response( filter( this.options.source, request.term ) );
377
				};
377
				};
378
			} else {
378
			} else {
379
				initSource.call( this );
379
				initSource.call( this );
380
			}
380
			}
381
		},
381
		},
382
		_renderItem: function( ul, item) {
382
		_renderItem: function( ul, item) {
383
			if (item.retenu == true) {
383
			if (item.retenu == true) {
384
				item.label = "<strong>"+item.label+"</strong>";
384
				item.label = "<strong>"+item.label+"</strong>";
385
			}
385
			}
386
			var classe = (nomRechercheEnCours == 'nom_sci' && nomSciEstDemande()) ? 'class="autocompletion_nom"' : '';
386
			var classe = (nomRechercheEnCours == 'nom_sci' && nomSciEstDemande()) ? 'class="autocompletion_nom"' : '';
387
			return $("<li "+classe+"></li>")
387
			return $("<li "+classe+"></li>")
388
				.data("item.autocomplete", item)
388
				.data("item.autocomplete", item)
389
				.append( $("<a></a>")[ this.options.html ? "html" : "text" ](item.label))
389
				.append( $("<a></a>")[ this.options.html ? "html" : "text" ](item.label))
390
				.appendTo(ul);
390
				.appendTo(ul);
391
		}
391
		}
392
	});
392
	});
393
})( jQuery );
393
})( jQuery );