Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1582 Rev 1584
1
//+----------------------------------------------------------------------------------------------------------+
1
//+----------------------------------------------------------------------------------------------------------+
2
// Onglets et Portlets
2
// Onglets et Portlets
3
/**
3
/**
4
 * Les variables suivantes ont été ajoutée par php
4
 * Les variables suivantes ont été ajoutée par php
5
 * 
5
 * 
6
 * var urlTexteBrutSectionWikiTpl : url pour obtenir le texte brut d'une section de wiki
6
 * var urlTexteBrutSectionWikiTpl : url pour obtenir le texte brut d'une section de wiki
7
 * var urlEditionSectionWikiTpl : url pour éditer une section du wiki 
7
 * var urlEditionSectionWikiTpl : url pour éditer une section du wiki 
8
 * var urlTexteFormateSectionWikiTpl : url pour obtenir le texte formaté en html d'une section de wiki
8
 * var urlTexteFormateSectionWikiTpl : url pour obtenir le texte formaté en html d'une section de wiki
9
 * var pageWikiTaxon : url pour obtenir le texte formaté en html d'une section de wiki
9
 * var pageWikiTaxon : url pour obtenir le texte formaté en html d'une section de wiki
10
 * var urlPopup = url de base pour les popup contenant du code un peu complexe
10
 * var urlPopup = url de base pour les popup contenant du code un peu complexe
11
 * 
11
 * 
12
*/
12
*/
13
 
13
 
14
/**
14
/**
15
 * Variables globales du script
15
 * Variables globales du script
16
 */
16
 */
17
var modules = Array();
17
var modules = Array();
18
var REFERENTIEL = "<?php echo Registre::get('parametres.referentiel'); ?>";
18
var REFERENTIEL = "<?php echo Registre::get('parametres.referentiel'); ?>";
19
 
19
 
20
/** Classe Module
20
/** Classe Module
21
* Définit un module de type portlet
21
* Définit un module de type portlet
22
**/
22
**/
23
function Module(id, module, onglet, statique) {
23
function Module(id, module, onglet, statique) {
24
 
24
 
25
	// Variables de classe : identifiant, titre, et le HTML du résumé à afficher dans le contenu
25
	// Variables de classe : identifiant, titre, et le HTML du résumé à afficher dans le contenu
26
	this.id = id;
26
	this.id = id;
27
	this.titre;
27
	this.titre;
28
	this.htmlResume;
28
	this.htmlResume;
29
	this.statique = statique;
29
	this.statique = statique;
30
 
-
 
31
	
30
}
32
 
31
 
33
function getUrlVars() {
32
function getUrlVars() {
34
    var vars = [], hash;
33
    var vars = [], hash;
35
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
34
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
36
    for (var i = 0; i < hashes.length; i++) {
35
    for (var i = 0; i < hashes.length; i++) {
37
        hash = hashes[i].split('=');
36
        hash = hashes[i].split('=');
38
        vars.push(hash[0]);
37
        vars.push(hash[0]);
39
        vars[hash[0]] = hash[1];
38
        vars[hash[0]] = hash[1];
40
    }
39
    }
41
    return vars;
40
    return vars;
42
}
41
}
43
 
42
 
44
 
43
 
45
// remplace des liens directs vers les onglets par des liens permettant de ne charger
44
// remplace des liens directs vers les onglets par des liens permettant de ne charger
46
// que le contenu de l'onglet (pour le plugin tab)
45
// que le contenu de l'onglet (pour le plugin tab)
47
function remplacerUrlsOnglets() {
46
function remplacerUrlsOnglets() {
48
		$(".lien-onglet").each(function() {
47
		$(".lien-onglet").each(function() {
49
		var urlOnglet = $(this).attr('href');
48
		var urlOnglet = $(this).attr('href');
50
		var urlVars = urlOnglet.slice(urlOnglet.indexOf('?') + 1);
49
		var urlVars = urlOnglet.slice(urlOnglet.indexOf('?') + 1);
51
		urlBase = base_url_application_onglets+"?"+urlVars;
50
		urlBase = base_url_application_onglets+"?"+urlVars;
52
		urlOnglet = urlBase.replace('action=fiche','action=onglet');
51
		urlOnglet = urlBase.replace('action=fiche','action=onglet');
53
		$(this).attr('href', urlOnglet);
52
		$(this).attr('href', urlOnglet);
54
	});
53
	});
55
}
54
}
56
 
55
 
57
 
56
 
58
 
57
 
59
//+----------------------------------------------------------------------------------------------------------+
58
//+----------------------------------------------------------------------------------------------------------+
60
// Wikini Flora
59
// Wikini Flora
61
var htmlWikiOriginal = '';
60
var htmlWikiOriginal = '';
62
var objetContenuWiki = null;
61
var objetContenuWiki = null;
63
 
62
 
64
function getTemplateFormulaireEditionWiki(page, section, texte) {	
63
function getTemplateFormulaireEditionWiki(page, section, texte) {	
65
	var urlWebServiceWiki = getUrlEditionPourPageEtSection(page, section);
64
	var urlWebServiceWiki = getUrlEditionPourPageEtSection(page, section);
66
	var formulaire = 
65
	var formulaire = 
67
		'<form method="post" id="formulaire_edition_wiki" name="formulaire_edition_wiki" action="'+urlWebServiceWiki+'">'+
66
		'<form method="post" id="formulaire_edition_wiki" name="formulaire_edition_wiki" action="'+urlWebServiceWiki+'">'+
68
		  '<div>'+
67
		  '<div>'+
69
		  	'<textarea id="pageContenu" name="pageContenu" class="champ_edition_wiki">'+texte+'</textarea>'+
68
		  	'<textarea id="pageContenu" name="pageContenu" class="champ_edition_wiki">'+texte+'</textarea>'+
70
		  '</div>'+
69
		  '</div>'+
71
		  '<input type="hidden" name="pageSectionTitre" id="pageSectionTitre" value="'+section+'" />'+
70
		  '<input type="hidden" name="pageSectionTitre" id="pageSectionTitre" value="'+section+'" />'+
72
		  '<input type="submit" text="sauver" />'+
71
		  '<input type="submit" text="sauver" />'+
73
	  	  '<input class="bouton_annuler_edition" type="button" value="annuler" />';
72
	  	  '<input class="bouton_annuler_edition" type="button" value="annuler" />';
74
		'</form>';		
73
		'</form>';		
75
	return formulaire;
74
	return formulaire;
76
}
75
}
77
 
76
 
78
function getSection() {
77
function getSection() {
79
	return objetContenuWiki.attr("title");
78
	return objetContenuWiki.attr("title");
80
}
79
}
81
 
80
 
82
function getPageWikiTaxon() {
81
function getPageWikiTaxon() {
83
	return pageWikiTaxon;
82
	return pageWikiTaxon;
84
}
83
}
85
 
84
 
86
function getUrlEditionPourPageEtSection(page, section) {
85
function getUrlEditionPourPageEtSection(page, section) {
87
	var url = urlEditionSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
86
	var url = urlEditionSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
88
	return url;
87
	return url;
89
}
88
}
90
 
89
 
91
function getUrlTextePourPageSectionBrute(page, section) {
90
function getUrlTextePourPageSectionBrute(page, section) {
92
	return urlTexteBrutSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
91
	return urlTexteBrutSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
93
}
92
}
94
 
93
 
95
function getUrlTextePourPageSectionFormatee(page, section) {
94
function getUrlTextePourPageSectionFormatee(page, section) {
96
	return urlTexteFormateSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
95
	return urlTexteFormateSectionWikiTpl.replace('{pageTag}', page).replace('{sectionTitre}', section);
97
}
96
}
98
 
97
 
99
function remplacerContenuWikiParFormulaireEdition(objet_contenu) {
98
function remplacerContenuWikiParFormulaireEdition(objet_contenu) {
100
	objetContenuWiki = objet_contenu;
99
	objetContenuWiki = objet_contenu;
101
	var adresse = getUrlEditionPourPageEtSection(getPageWikiTaxon(), getSection());
100
	var adresse = getUrlEditionPourPageEtSection(getPageWikiTaxon(), getSection());
102
	htmlWikiOriginal = objet_contenu.html();
101
	htmlWikiOriginal = objet_contenu.html();
103
	$.getJSON(adresse, function(data) {
102
	$.getJSON(adresse, function(data) {
104
		$(objetContenuWiki).removeClass('editable_sur_clic').html(getTemplateFormulaireEditionWiki(getPageWikiTaxon(), getSection(), data.texte));
103
		$(objetContenuWiki).removeClass('editable_sur_clic').html(getTemplateFormulaireEditionWiki(getPageWikiTaxon(), getSection(), data.texte));
105
	});
104
	});
106
}
105
}
107
 
106
 
108
function gererEvenementsWiki() {
107
function gererEvenementsWiki() {
109
	//TODO: ajout automatique d'un lien ouvrant une page d'aide (un popup) au formatage des pages wikini
108
	//TODO: ajout automatique d'un lien ouvrant une page d'aide (un popup) au formatage des pages wikini
110
	$('.editable_sur_clic').live('dblclick',function(event) {
109
	$('.editable_sur_clic').live('dblclick',function(event) {
111
		remplacerContenuWikiParFormulaireEdition($(this));
110
		remplacerContenuWikiParFormulaireEdition($(this));
112
	});
111
	});
113
	
112
	
114
	$('#formulaire_edition_wiki').live('submit',function(event) {
113
	$('#formulaire_edition_wiki').live('submit',function(event) {
115
	    event.preventDefault(); 
114
	    event.preventDefault(); 
116
		var valeurs = $(this).serialize();
115
		var valeurs = $(this).serialize();
117
		$.post($(this).attr('action'), valeurs, function(data) {
116
		$.post($(this).attr('action'), valeurs, function(data) {
118
			var adresse = getUrlTextePourPageSectionFormatee(getPageWikiTaxon(), getSection());
117
			var adresse = getUrlTextePourPageSectionFormatee(getPageWikiTaxon(), getSection());
119
			$.getJSON(adresse, function(data) {
118
			$.getJSON(adresse, function(data) {
120
				$(objetContenuWiki).addClass('editable_sur_clic').html(data.texte);
119
				$(objetContenuWiki).addClass('editable_sur_clic').html(data.texte);
121
			});
120
			});
122
		});
121
		});
123
	});
122
	});
124
	
123
	
125
	$('.bouton_annuler_edition').live('click', function(event) {
124
	$('.bouton_annuler_edition').live('click', function(event) {
126
		event.preventDefault();
125
		event.preventDefault();
127
		$(objetContenuWiki).addClass('editable_sur_clic').html(htmlWikiOriginal);
126
		$(objetContenuWiki).addClass('editable_sur_clic').html(htmlWikiOriginal);
128
	});
127
	});
129
	
128
	
130
	rendreLienAffichableDansNouvelleFenetre('.contenu_editable');
129
	rendreLienAffichableDansNouvelleFenetre('.contenu_editable');
131
}
130
}
132
 
131
 
133
//+----------------------------------------------------------------------------------------------------------+
132
//+----------------------------------------------------------------------------------------------------------+
134
//Affichage dans une nouvelle fenetre
133
//Affichage dans une nouvelle fenetre
135
function rendreLienAffichableDansNouvelleFenetre(selecteur) {
134
function rendreLienAffichableDansNouvelleFenetre(selecteur) {
136
	$(selecteur).find('a').live('click', function(event) {
135
	$(selecteur).find('a').live('click', function(event) {
137
		window.open($(this).attr('href'));
136
		window.open($(this).attr('href'));
138
		event.preventDefault();
137
		event.preventDefault();
139
		return false;
138
		return false;
140
	});
139
	});
141
}
140
}
142
 
141
 
143
//+----------------------------------------------------------------------------------------------------------+
142
//+----------------------------------------------------------------------------------------------------------+
144
// Plier / déplier
143
// Plier / déplier
145
function plierTout() {
144
function plierTout() {
146
	$('.nom').children('.imagetteMoins').removeClass('imagetteMoins').addClass('imagettePlus');
145
	$('.nom').children('.imagetteMoins').removeClass('imagetteMoins').addClass('imagettePlus');
147
	$('.plus').css('display', 'none');
146
	$('.plus').css('display', 'none');
148
}
147
}
149
 
148
 
150
function deplierTout() {
149
function deplierTout() {
151
	$('.nom').children('.imagettePlus').removeClass('imagettePlus').addClass('imagetteMoins');
150
	$('.nom').children('.imagettePlus').removeClass('imagettePlus').addClass('imagetteMoins');
152
	$('.plus').css('display', 'inline');
151
	$('.plus').css('display', 'inline');
153
}
152
}
154
 
153
 
155
function gestionBiblio(parent) {
154
function gestionBiblio(parent) {
156
	$('.nom').each(function () {
155
	$('.nom').each(function () {
157
		if ($(this).children('.plus').length == 0) {
156
		if ($(this).children('.plus').length == 0) {
158
			html = $(this).html();
157
			html = $(this).html();
159
			
158
			
160
			// La partie biblio commence au premier crochet ouvrant
159
			// La partie biblio commence au premier crochet ouvrant
161
			// ou bien au span de la biblio à exclure
160
			// ou bien au span de la biblio à exclure
162
			posCrochetGauche = html.indexOf('[');
161
			posCrochetGauche = html.indexOf('[');
163
			posbiblioAExclure = html.indexOf('<span class="bib_excl">');
162
			posbiblioAExclure = html.indexOf('<span class="bib_excl">');
164
			
163
			
165
			if(posCrochetGauche < 0 || (posbiblioAExclure > 0 && posbiblioAExclure < posCrochetGauche)) {
164
			if(posCrochetGauche < 0 || (posbiblioAExclure > 0 && posbiblioAExclure < posCrochetGauche)) {
166
				posCrochetGauche = posbiblioAExclure;
165
				posCrochetGauche = posbiblioAExclure;
167
			}
166
			}
168
			
167
			
169
			// console.log(posCrochetGauche+" "+posbiblioAExclure);
168
			// console.log(posCrochetGauche+" "+posbiblioAExclure);
170
			
169
			
171
			
170
			
172
			if (posCrochetGauche > 0) {
171
			if (posCrochetGauche > 0) {
173
				nom = html.substr(0, posCrochetGauche);
172
				nom = html.substr(0, posCrochetGauche);
174
				biblio = html.substr(posCrochetGauche, html.length);
173
				biblio = html.substr(posCrochetGauche, html.length);
175
				$(this).html(nom);
174
				$(this).html(nom);
176
				
175
				
177
				imagettePlus = document.createElement('div');
176
				imagettePlus = document.createElement('div');
178
				$(imagettePlus).addClass('imagettePlus');
177
				$(imagettePlus).addClass('imagettePlus');
179
				$(this).prepend($(imagettePlus));
178
				$(this).prepend($(imagettePlus));
180
				
179
				
181
				plus = document.createElement('span');
180
				plus = document.createElement('span');
182
				$(plus).addClass('plus');
181
				$(plus).addClass('plus');
183
				$(plus).html(biblio);
182
				$(plus).html(biblio);
184
				$(plus).hide();
183
				$(plus).hide();
185
				
184
				
186
				$(this).click(function(e) {
185
				$(this).click(function(e) {
187
					// test pour ne réagir que sur le clic sur le + ou -
186
					// test pour ne réagir que sur le clic sur le + ou -
188
					// TODO: fusionner ce bout de code en doublon avec synthese.js
187
					// TODO: fusionner ce bout de code en doublon avec synthese.js
189
					if($(e.target).hasClass("imagettePlus") || $(e.target).hasClass("imagetteMoins")) {
188
					if($(e.target).hasClass("imagettePlus") || $(e.target).hasClass("imagetteMoins")) {
190
						if (!$(this).children('.plus').is(':visible')) {
189
						if (!$(this).children('.plus').is(':visible')) {
191
							$(this).children('.imagettePlus').removeClass('imagettePlus').addClass('imagetteMoins');
190
							$(this).children('.imagettePlus').removeClass('imagettePlus').addClass('imagetteMoins');
192
							$(this).children('.plus').css('display', 'inline');
191
							$(this).children('.plus').css('display', 'inline');
193
						} else {
192
						} else {
194
							$(this).children('.imagetteMoins').removeClass('imagetteMoins').addClass('imagettePlus');
193
							$(this).children('.imagetteMoins').removeClass('imagetteMoins').addClass('imagettePlus');
195
							$(this).children('.plus').css('display', 'none');
194
							$(this).children('.plus').css('display', 'none');
196
						}
195
						}
197
					}
196
					}
198
					
197
					
199
				});
198
				});
200
					
199
					
201
				$(this).append($(plus));
200
				$(this).append($(plus));
202
				
201
				
203
			}
202
			}
204
		}
203
		}
205
	});
204
	});
206
}
205
}
207
 
206
 
208
function gererEvenementsPliage() {
207
function gererEvenementsPliage() {
209
	$('.lien_tout_deplier').live('click', function() {
208
	$('.lien_tout_deplier').live('click', function() {
210
		deplierTout();
209
		deplierTout();
211
	});
210
	});
212
	$('.lien_tout_plier').live('click', function() {
211
	$('.lien_tout_plier').live('click', function() {
213
		plierTout();
212
		plierTout();
214
	});
213
	});
215
	gestionBiblio(document);
214
	gestionBiblio(document);
216
}
215
}
217
 
216
 
218
//+----------------------------------------------------------------------------------------------------------+
217
//+----------------------------------------------------------------------------------------------------------+
219
//Pop Up images
218
//Pop Up images
220
function ouvrirPopUpImg(event) {
219
function ouvrirPopUpImg(event) {
221
	event.preventDefault();
220
	event.preventDefault();
222
	window.open($(this).attr('href'),"Photo_"+$(this).children("img").attr("data-num-image"),
221
	window.open($(this).attr('href'),"Photo_"+$(this).children("img").attr("data-num-image"),
223
			'"'+'height='+event.data.h+',width='+event.data.w+',top='+event.data.t+',left='+event.data.l 
222
			'"'+'height='+event.data.h+',width='+event.data.w+',top='+event.data.t+',left='+event.data.l 
224
			+',toolbar='+event.data.toolbar+',menubar='+event.data.menubar +',location='
223
			+',toolbar='+event.data.toolbar+',menubar='+event.data.menubar +',location='
225
			+event.data.location+',resizable='+event.data.resizable+',scrollbars='+event.data.scrollbars 
224
			+event.data.location+',resizable='+event.data.resizable+',scrollbars='+event.data.scrollbars 
226
			+',status='+event.data.status+'"');
225
			+',status='+event.data.status+'"');
227
}
226
}
228
 
227
 
229
//+----------------------------------------------------------------------------------------------------------+
228
//+----------------------------------------------------------------------------------------------------------+
230
// Message de chargement pour les graphique écologie
229
// Message de chargement pour les graphique écologie
231
function gererChargementGraphiqueEcologie() {
230
function gererChargementGraphiqueEcologie() {
232
	$('.ecologie_svg').addClass('chargement');
231
	$('.ecologie_svg').addClass('chargement');
233
}
232
}
234
 
233
 
235
function gererAffichageLegendeEcologie() {
234
function gererAffichageLegendeEcologie() {
236
	$('.voir').live('click', function() {
235
	$('.voir').live('click', function() {
237
		$(this).siblings('.legende_graphique').show();
236
		$(this).siblings('.legende_graphique').show();
238
		$(this).siblings('.cacher').show();
237
		$(this).siblings('.cacher').show();
239
		$(this).hide();
238
		$(this).hide();
240
	});
239
	});
241
	
240
	
242
	$('.cacher').live('click', function() {
241
	$('.cacher').live('click', function() {
243
		$(this).siblings('.legende_graphique').hide();
242
		$(this).siblings('.legende_graphique').hide();
244
		$(this).siblings('.voir').show();
243
		$(this).siblings('.voir').show();
245
		$(this).hide();
244
		$(this).hide();
246
	});
245
	});
247
}
246
}
248
 
247
 
249
 
248
 
250
//+----------------------------------------------------------------------------------------------------------+
249
//+----------------------------------------------------------------------------------------------------------+
251
// Initialisation
250
// Initialisation
252
var fancyboxinitialise = false;
251
var fancyboxinitialise = false;
253
var param_popup_Coste = {h: 650, w: 550, t: 100, l: 100, 
252
var param_popup_Coste = {h: 650, w: 550, t: 100, l: 100, 
254
		toolbar: 'no', menubar: 'no', location: 'no', resizable: 'yes', scrollbars: 'yes', status: 'no'};
253
		toolbar: 'no', menubar: 'no', location: 'no', resizable: 'yes', scrollbars: 'yes', status: 'no'};
255
 
254
 
256
var param_popup_Cel = {h: 750, w: 630, t: 100, l: 100, 
255
var param_popup_Cel = {h: 750, w: 630, t: 100, l: 100, 
257
		toolbar: 'no', menubar: 'no', location: 'no', resizable: 'yes', scrollbars: 'yes', status: 'no'};
256
		toolbar: 'no', menubar: 'no', location: 'no', resizable: 'yes', scrollbars: 'yes', status: 'no'};
258
 
257
 
259
//Initialisation (uniquement sur la présence de la div bloc-fiche, qui contient la fiche eflore)
258
//Initialisation (uniquement sur la présence de la div bloc-fiche, qui contient la fiche eflore)
260
$(document).one('ficheSyntheseChargee', function() {
259
$(document).one('ficheSyntheseChargee', function() {
261
	initialiserOnglets();
260
	initialiserOnglets();
262
 
261
 
263
	// TODO : devrait être .on() à la place de live()
262
	// TODO : devrait être .on() à la place de live()
264
	$('.lien_popup').live('click',function(event) {
263
	$('.lien_popup').live('click',function(event) {
265
		event.preventDefault();
264
		event.preventDefault();
266
		$.fancybox(this,{
265
		$.fancybox(this,{
267
			autoDimensions:false,
266
			autoDimensions:false,
268
			width:580
267
			width:580
269
		});
268
		});
270
	});
269
	});
271
	
270
	
272
	// TODO : devrait être .on() à la place de live()
271
	// TODO : devrait être .on() à la place de live()
273
	$('.lien_popup.lien_metadonnees').live('click',function(event) {
272
	$('.lien_popup.lien_metadonnees').live('click',function(event) {
274
		event.preventDefault();
273
		event.preventDefault();
275
		$.fancybox(this,{
274
		$.fancybox(this,{
276
			autoDimensions:true
275
			autoDimensions:true
277
		});
276
		});
278
	});
277
	});
279
		
278
		
280
	$('.lien-image-cel').live('click', param_popup_Cel , ouvrirPopUpImg);
279
	$('.lien-image-cel').live('click', param_popup_Cel , ouvrirPopUpImg);
281
	$('.lien-image-coste').live('click', param_popup_Coste , ouvrirPopUpImg);
280
	$('.lien-image-coste').live('click', param_popup_Coste , ouvrirPopUpImg);
282
	
281
	
283
	afficherOngletsPourNiveau();
282
	afficherOngletsPourNiveau();
284
 
283
 
285
	gererEvenementsWiki();
284
	gererEvenementsWiki();
286
	gererEvenementsPliage();
285
	gererEvenementsPliage();
287
	
286
	
288
	$('a.lien_retour_synthese').click(function(event) {
287
	$('a.lien_retour_synthese').click(function(event) {
289
		$('#onglet_synthese a').click();
288
		$('#onglet_synthese a').click();
290
		event.preventDefault();
289
		event.preventDefault();
291
	});
290
	});
292
	
291
	
293
	$(window).resize(function() {
292
	$(window).resize(function() {
294
		redimensionnerOnglets();
293
		redimensionnerOnglets();
295
	});
294
	});
296
	redimensionnerOnglets();
295
	redimensionnerOnglets();
297
	
296
	
298
	if($("#bloc-fiche").length > 0) {
297
	if($("#bloc-fiche").length > 0) {
299
		// initialisation de l'url avec l'onglet par défaut ou bien 
298
		// initialisation de l'url avec l'onglet par défaut ou bien 
300
		// celui qui a été explicitement demandé
299
		// celui qui a été explicitement demandé
301
		mettreAJourUrl(permalienNumNom+"-"+onglet, onglet);
300
		mettreAJourUrl(permalienNumNom+"-"+onglet, onglet);
302
	}
301
	}
303
	gererInteractionsPermaliens();
302
	gererInteractionsPermaliens();
304
});
303
});
305
 
304
 
306
function ajouterEvenement(elementHtml, nomEvenement, functionCallBack) {  
305
function ajouterEvenement(elementHtml, nomEvenement, functionCallBack) {  
307
	if(!!elementHtml && elementHtml != null) {	
306
	if(!!elementHtml && elementHtml != null) {	
308
		if(elementHtml.attachEvent) {// Internet Explorer
307
		if(elementHtml.attachEvent) {// Internet Explorer
309
			elementHtml.attachEvent("on" + nomEvenement, function() {functionCallBack.call(elementHtml);}); 
308
			elementHtml.attachEvent("on" + nomEvenement, function() {functionCallBack.call(elementHtml);}); 
310
		} else if(elementHtml.addEventListener) { // Firefox & autres
309
		} else if(elementHtml.addEventListener) { // Firefox & autres
311
			elementHtml.addEventListener(nomEvenement, functionCallBack, false);
310
			elementHtml.addEventListener(nomEvenement, functionCallBack, false);
312
		}
311
		}
313
	}
312
	}
314
}
313
}
315
 
314
 
316
$(document).one('ongletRepartitionCharge', function() {
315
$(document).one('ongletRepartitionCharge', function() {
317
	var contRepObs = $(".conteneur_repartition_observations");
316
	var contRepObs = $(".conteneur_repartition_observations");
318
	contRepObs.addClass("chargement_repartition");
317
	contRepObs.addClass("chargement_repartition");
319
	// utilisation d'une fonction native car jQuery refuse d'ajouter un évènement load
318
	// utilisation d'une fonction native car jQuery refuse d'ajouter un évènement load
320
	// sur autre chose qu'une image
319
	// sur autre chose qu'une image
321
	$('#repartition_observations').ready(function() {
320
	$('#repartition_observations').ready(function() {
322
		ajouterEvenement(document.getElementById("repartition_observations"), "load", function() {
321
		ajouterEvenement(document.getElementById("repartition_observations"), "load", function() {
323
			contRepObs.removeClass("chargement_repartition");
322
			contRepObs.removeClass("chargement_repartition");
324
		});
323
		});
325
	});
324
	});
326
	// lien "recalculer la carte de moissonnage"
325
	// lien "recalculer la carte de moissonnage"
327
	$('#lien_recalculer_carte').click(function() {
326
	$('#lien_recalculer_carte').click(function() {
328
		var carteMoissonnageSvg = $('#repartition_observations'); // c'est plutôt "moissonnage" que "répartition" => squelette pourave power
327
		var carteMoissonnageSvg = $('#repartition_observations'); // c'est plutôt "moissonnage" que "répartition" => squelette pourave power
329
		var urlCarte = carteMoissonnageSvg.attr("data");
328
		var urlCarte = carteMoissonnageSvg.attr("data");
330
		urlCarte += '&recalculer=1';
329
		urlCarte += '&recalculer=1';
331
		contRepObs.addClass("chargement_repartition");
330
		contRepObs.addClass("chargement_repartition");
332
		carteMoissonnageSvg.attr("data", urlCarte);ajouterEvenement(document.getElementById("repartition_observations"), "load", function() {
331
		carteMoissonnageSvg.attr("data", urlCarte);ajouterEvenement(document.getElementById("repartition_observations"), "load", function() {
333
			contRepObs.removeClass("chargement_repartition");
332
			contRepObs.removeClass("chargement_repartition");
334
		});
333
		});
335
		return false;
334
		return false;
336
	});
335
	});
337
});
336
});
338
 
337
 
339
 
338
 
340
// À la fin du chargement de l'onglet Illustrations
339
// À la fin du chargement de l'onglet Illustrations
341
$(document).one('ongletIllustrationsCharge', function() {
340
$(document).one('ongletIllustrationsCharge', function() {
342
	$('a.lien-images-organes.fourni').live('click', afficherOngletOrgane);
341
	$('a.lien-images-organes.fourni').live('click', afficherOngletOrgane);
343
	$('a.lien-grande-image-organe').live('click', afficherGrandeImageOrgane);
342
	$('a.lien-grande-image-organe').live('click', afficherGrandeImageOrgane);
344
	// pour que la galerie soit ouverte par défaut sur le premier organe non vide
343
	// pour que la galerie soit ouverte par défaut sur le premier organe non vide
345
	var premier = $('a.lien-images-organes.fourni').first().data('tag');
344
	var premier = $('a.lien-images-organes.fourni').first().data('tag');
346
	afficherOngletOrgane(null, premier);
345
	afficherOngletOrgane(null, premier);
347
	
346
	
348
	$('a.lien_telechargement_image').live('click',function(e) {
347
	$('a.lien_telechargement_image').live('click',function(e) {
349
		if($(e.target).data('oneclicked')!='yes')
348
		if($(e.target).data('oneclicked')!='yes')
350
		{
349
		{
351
			$(e.target).data('oneclicked','yes');
350
			$(e.target).data('oneclicked','yes');
352
			$(this).fancybox({
351
			$(this).fancybox({
353
				"type" : "iframe",
352
				"type" : "iframe",
354
				"autoDimensions" : false,
353
				"autoDimensions" : false,
355
				"width" : 800,
354
				"width" : 800,
356
				"height" : 405,
355
				"height" : 405,
357
				"titleShow" : false
356
				"titleShow" : false
358
			}).click();
357
			}).click();
359
		}
358
		}
360
 
359
 
361
		e.preventDefault();
360
		e.preventDefault();
362
		return false;
361
		return false;
363
	});
362
	});
364
});
363
});
365
 
364
 
366
// Affiche les n images ayant le plus de votes, pour l'organe $tag
365
// Affiche les n images ayant le plus de votes, pour l'organe $tag
367
function afficherOngletOrgane(e, tag) {
366
function afficherOngletOrgane(e, tag) {
368
	var onglets = $('div.onglet-organe'),
367
	var onglets = $('div.onglet-organe'),
369
		contenu = $('#galerie-organes-contenu'),
368
		contenu = $('#galerie-organes-contenu'),
370
		organeOnglet;
369
		organeOnglet;
371
 
370
 
372
	if (tag === undefined) {
371
	if (tag === undefined) {
373
		tag = $(this).data('tag')
372
		tag = $(this).data('tag')
374
	}
373
	}
375
	if ($(this).parent().hasClass('active')) { // replier
374
	if ($(this).parent().hasClass('active')) { // replier
376
		$(this).parent().removeClass('active')
375
		$(this).parent().removeClass('active')
377
		contenu.hide();
376
		contenu.hide();
378
		return false;
377
		return false;
379
	}
378
	}
380
 
379
 
381
	onglets.each(function() {
380
	onglets.each(function() {
382
		organeOnglet = $(this).data('tag');
381
		organeOnglet = $(this).data('tag');
383
		var li = $('a.lien-images-organes[data-tag="' + organeOnglet + '"]').parent();
382
		var li = $('a.lien-images-organes[data-tag="' + organeOnglet + '"]').parent();
384
		if (organeOnglet == tag) {
383
		if (organeOnglet == tag) {
385
			$(this).show();
384
			$(this).show();
386
			li.addClass('active');
385
			li.addClass('active');
387
		} else {
386
		} else {
388
			$(this).hide();
387
			$(this).hide();
389
			li.removeClass('active');
388
			li.removeClass('active');
390
		}
389
		}
391
	});
390
	});
392
 
391
 
393
	contenu.show();
392
	contenu.show();
394
 
393
 
395
	var premierLienGrandeImage = $('div.onglet-organe:visible').find('a.lien-grande-image-organe').first(),
394
	var premierLienGrandeImage = $('div.onglet-organe:visible').find('a.lien-grande-image-organe').first(),
396
		grandeImage = $('#grande-image-organe').find('img');
395
		grandeImage = $('#grande-image-organe').find('img');
397
	premierLienGrandeImage.trigger('click');
396
	premierLienGrandeImage.trigger('click');
398
	grandeImage.show('fast');
397
	grandeImage.show('fast');
399
 
398
 
400
	return false;
399
	return false;
401
}
400
}
402
 
401
 
403
// Affiche en grand sous les miniatures l'image d'organe sur laquelle on a cliqué
402
// Affiche en grand sous les miniatures l'image d'organe sur laquelle on a cliqué
404
function afficherGrandeImageOrgane() {
403
function afficherGrandeImageOrgane() {
405
	if ($(this).data('id-image') === "") {
404
	if ($(this).data('id-image') === "") {
406
		return false;
405
		return false;
407
	}
406
	}
408
	var grandeImage = $('#grande-image-organe').find('img'),
407
	var grandeImage = $('#grande-image-organe').find('img'),
409
		source = $(this).find('img').attr('src');
408
		source = $(this).find('img').attr('src');
410
	source = obtenirUrlMoyenFormatIdImage($(this).data('id-image'));
409
	source = obtenirUrlMoyenFormatIdImage($(this).data('id-image'));
411
	// chargement image et lien popup
410
	// chargement image et lien popup
412
	grandeImage.attr('src', source);
411
	grandeImage.attr('src', source);
413
	// important pour Pinterest et cie.
412
	// important pour Pinterest et cie.
414
	grandeImage.attr('alt', $(this).data('auteur') + ' - ' + $(this).data('titre'));
413
	grandeImage.attr('alt', $(this).data('auteur') + ' - ' + $(this).data('titre'));
415
	grandeImage.parent().attr('href',obtenirUrlGrandFormatIdImage($(this).data('id-image')));
414
	grandeImage.parent().attr('href',obtenirUrlGrandFormatIdImage($(this).data('id-image')));
416
	// métadonnées
415
	// métadonnées
417
	var metadonnees = ['id-image', 'titre', 'description', 'localisation', 'auteur'],
416
	var metadonnees = ['id-image', 'titre', 'description', 'localisation', 'auteur'],
418
		clef;
417
		clef;
419
	for (var i = 0; i < metadonnees.length; i++) {
418
	for (var i = 0; i < metadonnees.length; i++) {
420
		clef = metadonnees[i];
419
		clef = metadonnees[i];
421
		var contenu = $(this).data(clef);
420
		var contenu = $(this).data(clef);
422
		if(clef == 'id-image') {
421
		if(clef == 'id-image') {
423
			contenu += 
422
			contenu += 
424
				'    <a title="T\xE9l\xE9charger cette image" class="lien_telechargement_image" href="'+urlBaseWidget+'telechargement?id_image='+$(this).data(clef)+'">'+
423
				'    <a title="T\xE9l\xE9charger cette image" class="lien_telechargement_image" href="'+urlBaseWidget+'telechargement?id_image='+$(this).data(clef)+'">'+
425
					'<img class="icone_action_ill" src="'+urlCssImages+'sauver.png" />'+
424
					'<img class="icone_action_ill" src="'+urlCssImages+'sauver.png" />'+
426
				'</a>    '+
425
				'</a>    '+
427
				'<a title="Voir plus d\'informations sur cette image (s\'ouvre dans un popup)" class="lien-image-cel" href="'+urlPopup+'?module=popup-illustrations&action=fiche&referentiel=bdtfx&id=' + $(this).data('id-image')+'">'+
426
				'<a title="Voir plus d\'informations sur cette image (s\'ouvre dans un popup)" class="lien-image-cel" href="'+urlPopup+'?module=popup-illustrations&action=fiche&referentiel=bdtfx&id=' + $(this).data('id-image')+'">'+
428
					'<img class="icone_action_ill" src="'+urlCssImages+'infos_image.png" />'+
427
					'<img class="icone_action_ill" src="'+urlCssImages+'infos_image.png" />'+
429
				'</a>'+
428
				'</a>'+
430
				'<a style="float:right" title="Signaler une mauvaise identification ou en proposer une autre via l\'outil identiplante" class="signaler-mauvaise-identification" href="' + $(this).data('url-mauvaise-ident') + '" target="_blank">' +
429
				'<a style="float:right" title="Signaler une mauvaise identification ou en proposer une autre via l\'outil identiplante" class="signaler-mauvaise-identification" href="' + $(this).data('url-mauvaise-ident') + '" target="_blank">' +
431
					'<img class="icone_action_ill" src="'+urlCssImages+'mauvaise_id.png">Signaler une mauvaise identification' +
430
					'<img class="icone_action_ill" src="'+urlCssImages+'mauvaise_id.png">Signaler une mauvaise identification' +
432
				'</a>';
431
				'</a>';
433
		}
432
		}
434
		$('#grande-image-legende-' + clef).html(contenu);
433
		$('#grande-image-legende-' + clef).html(contenu);
435
 
434
 
436
	}
435
	}
437
	// valeurs génériques
436
	// valeurs génériques
438
	$('#grande-image-legende-' + clef).html($(this).data(clef));
437
	$('#grande-image-legende-' + clef).html($(this).data(clef));
439
	$('#grande-image-legende-date').html(formaterDateVersFrancais($(this).data('date')));
438
	$('#grande-image-legende-date').html(formaterDateVersFrancais($(this).data('date')));
440
	$('#grande-image-legende-id-destinataire').attr('href', urlPopup+'?module=popup-contact&action=form&referentiel='+REFERENTIEL+'&id_destinataire=' +
439
	$('#grande-image-legende-id-destinataire').attr('href', urlPopup+'?module=popup-contact&action=form&referentiel='+REFERENTIEL+'&id_destinataire=' +
441
			$(this).data('id-destinataire') + '&id_img=' + $(this).data('id-image'));
440
			$(this).data('id-destinataire') + '&id_img=' + $(this).data('id-image'));
442
	$('#grande-image-legende-id-destinataire').attr('title', "Envoyer un message \xE0 l'auteur \xE0 propos de cette image (n\xE9cessite d'\xEAtre identifi\xE9)");
441
	$('#grande-image-legende-id-destinataire').attr('title', "Envoyer un message \xE0 l'auteur \xE0 propos de cette image (n\xE9cessite d'\xEAtre identifi\xE9)");
443
	$('#grande-image-legende-auteur').attr('href', 'http://tela-botanica.org/profil:' + $(this).data('id-destinataire'));
442
	$('#grande-image-legende-auteur').attr('href', 'http://tela-botanica.org/profil:' + $(this).data('id-destinataire'));
444
	$('#grande-image-legende-auteur').attr('target', '_blank');
443
	$('#grande-image-legende-auteur').attr('target', '_blank');
445
	$('#grande-image-legende-auteur').attr('title', "Voir le profil de cet utilisateur (n\xE9cessite d'\xEAtre identifi\xE9)");
444
	$('#grande-image-legende-auteur').attr('title', "Voir le profil de cet utilisateur (n\xE9cessite d'\xEAtre identifi\xE9)");
446
 
445
 
447
 
446
 
448
	$('#grande-image-legende-id-image a.lien_telechargement_image').unbind('click.fb').fancybox({
447
	$('#grande-image-legende-id-image a.lien_telechargement_image').unbind('click.fb').fancybox({
449
		"type" : "iframe",
448
		"type" : "iframe",
450
		"autoDimensions" : false,
449
		"autoDimensions" : false,
451
		"width" : 800,
450
		"width" : 800,
452
		"height" : 405,
451
		"height" : 405,
453
		"titleShow" : false
452
		"titleShow" : false
454
	});
453
	});
455
}
454
}
456
 
455
 
457
function obtenirUrlMoyenFormatIdImage(idImage) {
456
function obtenirUrlMoyenFormatIdImage(idImage) {
458
	idImage = remplirChaineDebut(idImage, "0", 9);
457
	idImage = remplirChaineDebut(idImage, "0", 9);
459
	return urlImagesOrganesMoyenFormatTpl.replace('{id_image}', idImage);
458
	return urlImagesOrganesMoyenFormatTpl.replace('{id_image}', idImage);
460
}
459
}
461
 
460
 
462
function obtenirUrlGrandFormatIdImage(idImage) {
461
function obtenirUrlGrandFormatIdImage(idImage) {
463
	idImage = remplirChaineDebut(idImage, "0", 9);
462
	idImage = remplirChaineDebut(idImage, "0", 9);
464
	return urlImagesOrganesGrandFormatTpl.replace('{id_image}', idImage);
463
	return urlImagesOrganesGrandFormatTpl.replace('{id_image}', idImage);
465
}
464
}
466
 
465
 
467
function remplirChaineDebut(chaine, remplissage, longueur) {
466
function remplirChaineDebut(chaine, remplissage, longueur) {
468
	while(chaine.toString().length < longueur) {
467
	while(chaine.toString().length < longueur) {
469
		chaine = remplissage.toString()+chaine.toString();
468
		chaine = remplissage.toString()+chaine.toString();
470
	}
469
	}
471
	return chaine;
470
	return chaine;
472
}
471
}
473
 
472
 
474
// transforme une date du type "2012-04-06" en "06 avril 2012"
473
// transforme une date du type "2012-04-06" en "06 avril 2012"
475
function formaterDateVersFrancais(date) {
474
function formaterDateVersFrancais(date) {
476
	var mois = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
475
	var mois = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
477
		amj_hms = date.split(' '),
476
		amj_hms = date.split(' '),
478
		amj = amj_hms[0].split('-');
477
		amj = amj_hms[0].split('-');
479
	return amj[2] + ' ' + mois[parseInt(amj[1]) - 1] + ' ' + amj[0];
478
	return amj[2] + ' ' + mois[parseInt(amj[1]) - 1] + ' ' + amj[0];
480
}
479
}
481
 
480
 
482
 
481
 
483
// ouvre le popup de galerie lors d'un clic sur l'illustration dans la fiche synthèse
482
// ouvre le popup de galerie lors d'un clic sur l'illustration dans la fiche synthèse
484
function gererClicIllustrationsFiche() {
483
function gererClicIllustrationsFiche() {
485
	$('.illustration_cel').live('click', function() {
484
	$('.illustration_cel').live('click', function() {
486
		var url_image = $(this).attr('src');
485
		var url_image = $(this).attr('src');
487
		var titre = $('.nomenclature').first().text();
486
		var titre = $('.nomenclature').first().text();
488
		var url = urlPopup+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('data-num-nom')+"&titre="+encodeURIComponent(titre)+"&url_image="+encodeURIComponent(url_image)+"&referentiel="+REFERENTIEL;
487
		var url = urlPopup+"?module=popup-galerie&action=fiche&num_nom="+$(this).attr('data-num-nom')+"&titre="+encodeURIComponent(titre)+"&url_image="+encodeURIComponent(url_image)+"&referentiel="+REFERENTIEL;
489
		//var url = urlPopup+"?module=popup-galerie-organes&action=fiche&num_nom="+$(this).attr('data-num-nom')+"&titre="+encodeURIComponent(titre)+"&url_image="+encodeURIComponent(url_image)+"&referentiel="+REFERENTIEL;
488
		//var url = urlPopup+"?module=popup-galerie-organes&action=fiche&num_nom="+$(this).attr('data-num-nom')+"&titre="+encodeURIComponent(titre)+"&url_image="+encodeURIComponent(url_image)+"&referentiel="+REFERENTIEL;
490
		//alert(url);
489
		//alert(url);
491
		//return false;
490
		//return false;
492
		window.open(url, $(this).attr('data-num-nom'), 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(400)+', height='+(375));
491
		window.open(url, $(this).attr('data-num-nom'), 'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no, width='+(400)+', height='+(375));
493
	}); 
492
	}); 
494
}
493
}
495
 
494
 
496
function ouvrirFenetreIllustrationFiche(url, titre, hauteur, largeur) {
495
function ouvrirFenetreIllustrationFiche(url, titre, hauteur, largeur) {
497
	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));
496
	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));
498
	var tmp = fenetre.document;
497
	var tmp = fenetre.document;
499
	tmp.write('<html><head><title>'+titre+'</title>');
498
	tmp.write('<html><head><title>'+titre+'</title>');
500
	tmp.write('</head><body>');
499
	tmp.write('</head><body>');
501
	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>');
500
	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>');
502
	tmp.write('</body></html>');
501
	tmp.write('</body></html>');
503
	tmp.close();
502
	tmp.close();
504
}
503
}
505
 
504
 
506
 
505
 
507
// met à jour l'url dans la barre du navigateur ainsi que dans le permalien en bas
506
// met à jour l'url dans la barre du navigateur ainsi que dans le permalien en bas
508
// de la fiche
507
// de la fiche
509
function mettreAJourUrl(nouvelleUrl, etat) {
508
function mettreAJourUrl(nouvelleUrl, etat) {
510
	$('#permalien_num_nom').val(nouvelleUrl);
509
	$('#permalien_num_nom').val(nouvelleUrl);
511
	if (!!(window.history && window.history.pushState)) {
510
	if (!!(window.history && window.history.pushState)) {
512
		var currentState = window.history.state;
511
		var currentState = window.history.state;
513
		if (currentState != nouvelleUrl && !!etat) {
512
		if (currentState != nouvelleUrl && !!etat) {
514
			window.history.pushState(etat, "", nouvelleUrl);
513
			window.history.pushState(etat, "", nouvelleUrl);
515
		}
514
		}
516
	}
515
	}
517
}
516
}
518
 
517
 
519
function gererInteractionsPermaliens() {	
518
function gererInteractionsPermaliens() {	
520
	$(".conteneur_permalien > a").each(function() {
519
	$(".conteneur_permalien > a").each(function() {
521
		var txt = '<input type="text" id="'+$(this).attr('id')+'" readonly="readonly" class="lien_externe" value="'+$(this).attr('href')+'">';
520
		var txt = '<input type="text" id="'+$(this).attr('id')+'" readonly="readonly" class="lien_externe" value="'+$(this).attr('href')+'">';
522
		$(this).replaceWith(txt);
521
		$(this).replaceWith(txt);
523
	});
522
	});
524
	$(".conteneur_permalien > input").each(function() {
523
	$(".conteneur_permalien > input").each(function() {
525
		$(this).attr('size', $(this).val().length - 7);
524
		$(this).attr('size', $(this).val().length - 7);
526
	});
525
	});
527
	$(".conteneur_permalien > input").hover(
526
	$(".conteneur_permalien > input").hover(
528
		function() {
527
		function() {
529
			 $(this).select();
528
			 $(this).select();
530
		}, function() {
529
		}, function() {
531
			// rien à faire sur le mouseout
530
			// rien à faire sur le mouseout
532
		}
531
		}
533
	);
532
	);
534
}
533
}
535
 
534
 
536
function gererTemplatesChargementALaDemande() {
535
function gererTemplatesChargementALaDemande() {
537
	$('.lien-ajax-tpl a.lien-ajax-tpl-chargement').on('click', function(e) {
536
	$('.lien-ajax-tpl a.lien-ajax-tpl-chargement').on('click', function(e) {
538
		if($(this).attr('data-loading') != "true") {
537
		if($(this).attr('data-loading') != "true") {
539
			$(this).attr('data-loading', "true");
538
			$(this).attr('data-loading', "true");
540
			e.preventDefault();
539
			e.preventDefault();
541
			urlTpl = $(this).attr('href');
540
			urlTpl = $(this).attr('href');
542
			$(this).hide();
541
			$(this).hide();
543
			thisElementParent = $(this).parent();
542
			thisElementParent = $(this).parent();
544
			thisElementParent.append("<div class='tab-chargement'>Chargement des informations...</div>");
543
			thisElementParent.append("<div class='tab-chargement'>Chargement des informations...</div>");
545
			$.get(urlTpl, function( data ) {
544
			$.get(urlTpl, function( data ) {
546
				thisElementParent.replaceWith( data );
545
				thisElementParent.replaceWith( data );
547
			});
546
			});
548
			return false;
547
			return false;
549
		}
548
		}
550
	});
549
	});
551
}
550
}
552
 
551
 
553
$(document).ready(function() {
552
$(document).ready(function() {
554
	gererChargementGraphiqueEcologie();
553
	gererChargementGraphiqueEcologie();
555
	gererAffichageLegendeEcologie();
554
	gererAffichageLegendeEcologie();
556
	gererTemplatesChargementALaDemande();
555
	gererTemplatesChargementALaDemande();
557
	if (document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1') == false) {
556
	if (document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1') === false) {
558
		$('.svg').each(function() {
557
		$('.svg').each(function() {
559
			alt = $(this).attr('alt');
-
 
560
			img = document.createElement('img');
558
			var img = document.createElement('img');
561
			img.src = alt;
559
			img.src = $(this).attr('alt');
562
			$(this).replaceWith(img);
560
			$(this).replaceWith(img);
563
		});
561
		});
564
	}
562
	}
565
});
563
});
566
 
564