Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 984 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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