Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 969 Rev 973
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
	return url;
260
	return url;
261
}
261
}
262
 
262
 
263
function getUrlAutocompletionNomsVerna(requete) {
263
function getUrlAutocompletionNomsVerna(requete) {
264
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_VERNA, requete, 'oss')+
264
	var url = getUrlAutocompletion(URL_SERVICE_AUTOCOMPLETION_NOM_VERNA, requete, 'oss')+
265
		"&masque.lg=fra";
265
		"&masque.lg=fra";
266
	return url;
266
	return url;
267
}
267
}
268
 
268
 
269
function getUrlAutocompletion(baseUrl, requete, format) {
269
function getUrlAutocompletion(baseUrl, requete, format) {
270
	var url = baseUrl+"?"+
270
	var url = baseUrl+"?"+
271
		"masque="+requete+"&"+
271
		"masque="+requete+"&"+
272
		"recherche=etendue&"+
272
		"recherche=etendue&"+
273
		"retour.format="+format+"&"+
273
		"retour.format="+format+"&"+
274
		"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE;
274
		"navigation.limite="+AUTOCOMPLETION_ELEMENTS_NBRE;
275
	return url;
275
	return url;
276
}
276
}
277
 
277
 
278
/**------------ Fonctions de détection de l'état du formulaire ------------------*/
278
/**------------ Fonctions de détection de l'état du formulaire ------------------*/
279
function nomSciEstDemande()  {
279
function nomSciEstDemande()  {
280
	var boutonRadioNomSci = $('#type_nom_scientifique');
280
	var boutonRadioNomSci = $('#type_nom_scientifique');
281
	return (($('#type_nom_vernaculaire').length <= 0) || (boutonRadioNomSci != null && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked"));
281
	return (($('#type_nom_vernaculaire').length <= 0) || (boutonRadioNomSci != null && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked"));
282
}
282
}
283
 
283
 
284
function nomVernaculaireEstDemande()  {
284
function nomVernaculaireEstDemande()  {
285
	var boutonRadioNomSci = $('#type_nom_vernaculaire');
285
	var boutonRadioNomSci = $('#type_nom_vernaculaire');
286
	return (boutonRadioNomSci.length > 0 && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
286
	return (boutonRadioNomSci.length > 0 && boutonRadioNomSci.attr("checked") != "undefined" && boutonRadioNomSci.attr("checked") == "checked");
287
}
287
}
288
 
288
 
289
/**------------ Fonctions de gestion de l'affichage des valeurs par defaut ----------------------*/
289
/**------------ Fonctions de gestion de l'affichage des valeurs par defaut ----------------------*/
290
function gererAffichageValeursParDefaut() {
290
function gererAffichageValeursParDefaut() {
291
		$('input[name="type_nom"]').click(function() {
291
		$('input[name="type_nom"]').click(function() {
292
			changerPlaceHolderNom();
292
			changerPlaceHolderNom();
293
		});
293
		});
294
		changerPlaceHolderNom();
294
		changerPlaceHolderNom();
-
 
295
		$('input').click(function() {
-
 
296
			$(this).attr('placeholder', '');			
-
 
297
		});
295
}
298
}
296
 
299
 
297
function changerPlaceHolderNom() {
300
function changerPlaceHolderNom() {
298
	if(nomSciEstDemande()) {
301
	if(nomSciEstDemande()) {
299
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_SCI);
302
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_SCI);
300
	} else {
303
	} else {
301
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_VERNA);
304
		$('#nom').attr('placeholder',VALEUR_DEFAUT_NOM_VERNA);
302
	}
305
	}
303
}
306
}
304
 
307
 
305
/**------------ Fonctions de gestion du zoom sur les images affichées dans les résultats de recherche ----------------------*/
308
/**------------ Fonctions de gestion du zoom sur les images affichées dans les résultats de recherche ----------------------*/
306
function gererClicIllustrationsResultats() {
309
function gererClicIllustrationsResultats() {
307
	$('.illustration_resultat_cel').click(function() {
310
	$('.illustration_resultat_cel').click(function() {
308
		var url = $(this).attr('src');
311
		var url = $(this).attr('src');
309
		var titre = trouverNomTaxon($(this));
312
		var titre = trouverNomTaxon($(this));
310
		var url = URL_BASE_POPUP+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('title')+"&titre="+titre+"&referentiel="+REFERENTIEL;
313
		var url = URL_BASE_POPUP+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('title')+"&titre="+titre+"&referentiel="+REFERENTIEL;
311
		window.open(url, '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(700)+', height='+(650));
314
		window.open(url, '', 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(700)+', height='+(650));
312
	}); 
315
	}); 
313
	
316
	
314
	$('.illustration_resultat_choro').click(function() {
317
	$('.illustration_resultat_choro').click(function() {
315
		var url = $(this).attr('src').replace('108x101','432x404');
318
		var url = $(this).attr('src').replace('108x101','432x404');
316
		var titre = 'Chorologie du taxon '+trouverNomTaxon($(this));
319
		var titre = 'Chorologie du taxon '+trouverNomTaxon($(this));
317
		ouvrirFenetreIllustrationResultat(url, titre, 432, 404);
320
		ouvrirFenetreIllustrationResultat(url, titre, 432, 404);
318
	}); 
321
	}); 
319
	
322
	
320
	$('.illustration_resultat_coste').click(function() {
323
	$('.illustration_resultat_coste').click(function() {
321
		var url = $(this).attr('src');
324
		var url = $(this).attr('src');
322
		var titre = 'Illustration de Coste du taxon '+trouverNomTaxon($(this));
325
		var titre = 'Illustration de Coste du taxon '+trouverNomTaxon($(this));
323
		ouvrirFenetreIllustrationResultat(url, titre, 400, 400);
326
		ouvrirFenetreIllustrationResultat(url, titre, 400, 400);
324
	}); 
327
	}); 
325
}
328
}
326
 
329
 
327
function trouverNomTaxon(objet) {
330
function trouverNomTaxon(objet) {
328
	nom = "";
331
	nom = "";
329
	if(nomVernaculaireEstDemande()) {
332
	if(nomVernaculaireEstDemande()) {
330
		nom = objet.parent().parent().find('a.lien_fiche_eflore').text();
333
		nom = objet.parent().parent().find('a.lien_fiche_eflore').text();
331
	} else {
334
	} else {
332
		nom = objet.parent().find('.nom-sci a.lien_fiche_eflore').text();
335
		nom = objet.parent().find('.nom-sci a.lien_fiche_eflore').text();
333
	}
336
	}
334
	return nom;
337
	return nom;
335
}
338
}
336
 
339
 
337
function ouvrirFenetreIllustrationResultat(url, titre, hauteur, largeur) {
340
function ouvrirFenetreIllustrationResultat(url, titre, hauteur, largeur) {
338
	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));
341
	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));
339
	var tmp = fenetre.document;
342
	var tmp = fenetre.document;
340
	tmp.write('<html><head><title>'+titre+'</title>');
343
	tmp.write('<html><head><title>'+titre+'</title>');
341
	tmp.write('</head><body>');
344
	tmp.write('</head><body>');
342
	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>');
345
	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>');
343
	tmp.write('</body></html>');
346
	tmp.write('</body></html>');
344
	tmp.close();
347
	tmp.close();
345
}
348
}
346
 
349
 
347
/*
350
/*
348
 * jQuery UI Autocomplete HTML Extension
351
 * jQuery UI Autocomplete HTML Extension
349
 *
352
 *
350
 * Copyright 2010, Scott González (http://scottgonzalez.com)
353
 * Copyright 2010, Scott González (http://scottgonzalez.com)
351
 * Dual licensed under the MIT or GPL Version 2 licenses.
354
 * Dual licensed under the MIT or GPL Version 2 licenses.
352
 *
355
 *
353
 * http://github.com/scottgonzalez/jquery-ui-extensions
356
 * http://github.com/scottgonzalez/jquery-ui-extensions
354
 * 
357
 * 
355
 * Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides
358
 * Adaptation par Aurélien Peronnet pour la mise en gras des noms de taxons valides
356
 */
359
 */
357
(function( $ ) {
360
(function( $ ) {
358
	var proto = $.ui.autocomplete.prototype,
361
	var proto = $.ui.autocomplete.prototype,
359
		initSource = proto._initSource;
362
		initSource = proto._initSource;
360
	
363
	
361
	function filter( array, term ) {
364
	function filter( array, term ) {
362
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
365
		var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
363
		return $.grep( array, function(value) {
366
		return $.grep( array, function(value) {
364
			return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
367
			return matcher.test( $( "<div>" ).html( value.label || value.value || value ).text() );
365
		});
368
		});
366
	}
369
	}
367
	
370
	
368
	$.extend( proto, {
371
	$.extend( proto, {
369
		_initSource: function() {
372
		_initSource: function() {
370
			if (this.options.html && $.isArray(this.options.source) ) {
373
			if (this.options.html && $.isArray(this.options.source) ) {
371
				this.source = function( request, response ) {
374
				this.source = function( request, response ) {
372
					response( filter( this.options.source, request.term ) );
375
					response( filter( this.options.source, request.term ) );
373
				};
376
				};
374
			} else {
377
			} else {
375
				initSource.call( this );
378
				initSource.call( this );
376
			}
379
			}
377
		},
380
		},
378
		_renderItem: function( ul, item) {
381
		_renderItem: function( ul, item) {
379
			if (item.retenu == true) {
382
			if (item.retenu == true) {
380
				item.label = "<strong>"+item.label+"</strong>";
383
				item.label = "<strong>"+item.label+"</strong>";
381
			}
384
			}
382
			var classe = (nomRechercheEnCours == 'nom_sci' && nomSciEstDemande()) ? 'class="autocompletion_nom"' : '';
385
			var classe = (nomRechercheEnCours == 'nom_sci' && nomSciEstDemande()) ? 'class="autocompletion_nom"' : '';
383
			return $("<li "+classe+"></li>")
386
			return $("<li "+classe+"></li>")
384
				.data("item.autocomplete", item)
387
				.data("item.autocomplete", item)
385
				.append( $("<a></a>")[ this.options.html ? "html" : "text" ](item.label))
388
				.append( $("<a></a>")[ this.options.html ? "html" : "text" ](item.label))
386
				.appendTo(ul);
389
				.appendTo(ul);
387
		}
390
		}
388
	});
391
	});
389
})( jQuery );
392
})( jQuery );