Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 841 Rev 915
1
/*+--------------------------------------------------------------------------------------------------------+*/
1
/*+--------------------------------------------------------------------------------------------------------+*/
2
// PARAMÊTRES et CONSTANTES
2
// PARAMÊTRES et CONSTANTES
3
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
3
var pointImageUrl = 'http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png';
4
var pointsOrigine = null;
4
var pointsOrigine = null;
5
var boundsOrigine = null;
5
var boundsOrigine = null;
6
var markerClusterer = null;
6
var markerClusterer = null;
7
var map = null;
7
var map = null;
8
var infoBulle = new google.maps.InfoWindow();
8
var infoBulle = new google.maps.InfoWindow();
9
var pointClique = null;
9
var pointClique = null;
10
var carteCentre = new google.maps.LatLng(46.4, 3.10);
10
var carteCentre = new google.maps.LatLng(46.4, 3.10);
11
var carteOptions = {
11
var carteOptions = {
12
	zoom: 6,
12
	zoom: 6,
13
	mapTypeId: google.maps.MapTypeId.ROADMAP,
13
	mapTypeId: google.maps.MapTypeId.ROADMAP,
14
	mapTypeControlOptions: {
14
	mapTypeControlOptions: {
15
		mapTypeIds: ['OSM', 
15
		mapTypeIds: ['OSM', 
16
		             google.maps.MapTypeId.ROADMAP, 
16
		             google.maps.MapTypeId.ROADMAP, 
17
		             google.maps.MapTypeId.HYBRID, 
17
		             google.maps.MapTypeId.HYBRID, 
18
		             google.maps.MapTypeId.SATELLITE, 
18
		             google.maps.MapTypeId.SATELLITE, 
19
		             google.maps.MapTypeId.TERRAIN]
19
		             google.maps.MapTypeId.TERRAIN]
20
	}
20
	}
21
};			
21
};			
22
var ctaLayer = null;
22
var ctaLayer = null;
23
var osmMapType = new google.maps.ImageMapType({
23
var osmMapType = new google.maps.ImageMapType({
24
	getTileUrl: function(coord, zoom) {
24
	getTileUrl: function(coord, zoom) {
25
		return "http://tile.openstreetmap.org/" +
25
		return "http://tile.openstreetmap.org/" +
26
		zoom + "/" + coord.x + "/" + coord.y + ".png";
26
		zoom + "/" + coord.x + "/" + coord.y + ".png";
27
	},
27
	},
28
	tileSize: new google.maps.Size(256, 256),
28
	tileSize: new google.maps.Size(256, 256),
29
	isPng: true,
29
	isPng: true,
30
	alt: "OpenStreetMap",
30
	alt: "OpenStreetMap",
31
	name: "OSM",
31
	name: "OSM",
32
	maxZoom: 19
32
	maxZoom: 19
33
});
33
});
34
 
-
 
-
 
34
var pagineur = {'limite':50, 'start':0, 'total':0, 'stationId':null, 'format':'tableau'};
-
 
35
var station = {'commune':'', 'obsNbre':0};
-
 
36
var obsStation = new Array();
-
 
37
var obsPage = new Array();
35
/*+--------------------------------------------------------------------------------------------------------+*/
38
/*+--------------------------------------------------------------------------------------------------------+*/
36
// INITIALISATION DU CODE
39
// INITIALISATION DU CODE
37
 
-
 
38
 
40
 
39
//Déclenchement d'actions quand JQuery et le document HTML sont OK
41
//Déclenchement d'actions quand JQuery et le document HTML sont OK
40
$(document).ready(function() {
42
$(document).ready(function() {
41
	initialiserWidget();
43
	initialiserWidget();
42
});
44
});
43
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
44
// FONCTIONS
-
 
45
 
45
 
46
function initialiserWidget() {
46
function initialiserWidget() {
47
	afficherStats();
47
	afficherStats();
48
	initialiserAffichageCarte();
48
	initialiserAffichageCarte();
49
	initialiserAffichagePanneauLateral();
49
	initialiserAffichagePanneauLateral();
50
	
50
	
51
	initialiserCarte();
51
	initialiserCarte();
52
	initialiserInfoBulle();
52
	initialiserInfoBulle();
53
	chargerLimitesCommunales();
53
	chargerLimitesCommunales();
54
	rafraichirCarte();
54
	rafraichirCarte();
55
}
55
}
-
 
56
 
-
 
57
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
58
// AFFICHAGE GÉNÉRAL
56
 
59
 
57
function afficherStats() {
60
function afficherStats() {
58
	// Ajout du nombre de communes où des observations ont eu lieu
61
	// Ajout du nombre de communes où des observations ont eu lieu
59
	$('#commune-nbre').append(obs.stats.communes.formaterNombre());
62
	$('#commune-nbre').append(obs.stats.communes.formaterNombre());
60
	// Ajout du nombre d'observations
63
	// Ajout du nombre d'observations
61
	$('#obs-nbre').append(obs.stats.observations.formaterNombre());
64
	$('#obs-nbre').append(obs.stats.observations.formaterNombre());
62
	// Ajout du nombre de plantes
65
	// Ajout du nombre de plantes
63
	$('.plantes-nbre').append(plantesNbre.formaterNombre());
66
	$('.plantes-nbre').append(plantesNbre.formaterNombre());
64
}
67
}
-
 
68
 
-
 
69
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
70
// CARTE
65
 
71
 
66
function initialiserAffichageCarte() {
72
function initialiserAffichageCarte() {
67
	$('#carte').height($(window).height() - 35);
73
	$('#carte').height($(window).height() - 35);
68
	$('#carte').width($(window).width() - 24);
74
	$('#carte').width($(window).width() - 24);
69
	
75
	
70
	if (nt != '*') {
76
	if (nt != '*') {
71
		$('#carte').css('left', 0);
77
		$('#carte').css('left', 0);
72
	}
78
	}
73
}
79
}
74
 
-
 
75
function initialiserAffichagePanneauLateral() {
-
 
76
	$('#panneau-lateral').height($(window).height() - 35);
-
 
77
	
-
 
78
	if (nt == '*') {
-
 
79
		$('#pl-ouverture').bind('click', afficher);
-
 
80
		$('#pl-fermeture').bind('click', cacher);
-
 
81
		$('.taxon').live('click', filtrerParTaxon);
-
 
82
	}
-
 
83
}
-
 
84
 
80
 
85
function initialiserCarte() {
81
function initialiserCarte() {
86
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
82
	map = new google.maps.Map(document.getElementById('carte'), carteOptions);
87
	// Ajout de la couche OSM à la carte
83
	// Ajout de la couche OSM à la carte
88
	map.mapTypes.set('OSM', osmMapType);
84
	map.mapTypes.set('OSM', osmMapType);
89
}
85
}
90
 
-
 
91
function initialiserInfoBulle() {
-
 
92
	google.maps.event.addListener(infoBulle, 'domready', modifierContenuInfoBulle);
-
 
93
	google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique);
-
 
94
}
86
 
95
 
87
 
96
function chargerLimitesCommunales() {
88
function chargerLimitesCommunales() {
97
	if (urlsLimitesCommunales != null) {
89
	if (urlsLimitesCommunales != null) {
98
		for (urlId in urlsLimitesCommunales) { 
90
		for (urlId in urlsLimitesCommunales) { 
99
			var url = urlsLimitesCommunales[urlId];
91
			var url = urlsLimitesCommunales[urlId];
100
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
92
			ctaLayer = new google.maps.KmlLayer(url, {preserveViewport: true});
101
			ctaLayer.setMap(map);
93
			ctaLayer.setMap(map);
102
		}
94
		}
103
	}
95
	}
104
}
96
}
105
 
97
 
106
function rafraichirCarte() {
98
function rafraichirCarte() {
107
	var points = [];
99
	var points = [];
108
	var bounds = new google.maps.LatLngBounds();
100
	var bounds = new google.maps.LatLngBounds();
109
	for (var i = 0; i < obs.stats.communes; ++i) {
101
	for (var i = 0; i < obs.stats.communes; ++i) {
110
		var maLatLng = new google.maps.LatLng(obs.points[i].coord_x, obs.points[i].coord_y);
102
		var maLatLng = new google.maps.LatLng(obs.points[i].coord_x, obs.points[i].coord_y);
111
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
103
		var pointImage = new google.maps.MarkerImage(pointImageUrl, new google.maps.Size(24, 32));
112
		var point = new google.maps.Marker({
104
		var point = new google.maps.Marker({
113
			position: maLatLng,
105
			position: maLatLng,
114
			map: map,
106
			map: map,
115
			icon: pointImage,
107
			icon: pointImage,
116
			stationId: obs.points[i].id
108
			stationId: obs.points[i].id
117
		});
109
		});
118
 
110
 
119
		bounds.extend(maLatLng);
111
		bounds.extend(maLatLng);
120
		
112
		
121
		google.maps.event.addListener(point, 'click', function() {
113
		google.maps.event.addListener(point, 'click', function() {
122
			pointClique =  this;
114
			pointClique =  this;
123
			
-
 
124
			infoBulle.open(map, this);
115
			infoBulle.open(map, this);
125
			
116
			
126
			var limites = map.getBounds();
117
			var limites = map.getBounds();
127
			var centre = limites.getCenter();
118
			var centre = limites.getCenter();
128
			var nordEst = limites.getNorthEast();
119
			var nordEst = limites.getNorthEast();
129
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
120
			var centreSudLatLng = new google.maps.LatLng(nordEst.lat(), centre.lng());
130
			map.panTo(centreSudLatLng);
121
			map.panTo(centreSudLatLng);
131
			
122
			
132
			afficherMsgChargement();
123
			afficherInfoBulle();
133
			chargerFormatObs(this.stationId, '*');
124
			lancerChargementObs();
134
		});
125
		});
135
		
126
		
136
		points.push(point);
127
		points.push(point);
137
	}
128
	}
138
 
129
 
139
	if (pointsOrigine == null && boundsOrigine == null) {
130
	if (pointsOrigine == null && boundsOrigine == null) {
140
		pointsOrigine = points;
131
		pointsOrigine = points;
141
		boundsOrigine = bounds;
132
		boundsOrigine = bounds;
142
	}
133
	}
143
	
134
	
144
	executerMarkerClusterer(points, bounds);
135
	executerMarkerClusterer(points, bounds);
145
}
136
}
146
 
137
 
-
 
138
function deplacerCartePointClique() {
-
 
139
	map.panTo(pointClique.position);
-
 
140
}
147
function modifierContenuInfoBulle() {
141
 
148
	// Onglet Tableau : Jquery => TableSorter
142
function executerMarkerClusterer(points, bounds) {
149
	if ($("#observations table").get() != '') {
143
	if (markerClusterer) {
150
		ajouterTableauTriable("#observations table");
144
		markerClusterer.clearMarkers();
-
 
145
	}
-
 
146
	markerClusterer = new MarkerClusterer(map, points);
-
 
147
	map.fitBounds(bounds);
-
 
148
}
-
 
149
 
-
 
150
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
151
// INFO BULLE
-
 
152
 
-
 
153
function initialiserInfoBulle() {
-
 
154
	google.maps.event.addListener(infoBulle, 'domready', initialiserContenuInfoBulle);
-
 
155
	google.maps.event.addListener(infoBulle, 'closeclick', deplacerCartePointClique);
-
 
156
}
-
 
157
 
-
 
158
function afficherInfoBulle() {
151
	}
159
	var obsHtml = $("#tpl-obs").html();
-
 
160
	infoBulle.setContent(obsHtml);
-
 
161
}
-
 
162
 
152
	// Onglet Liste : Jquery => FancyBox
163
function afficherMessageChargement(element) {
-
 
164
	if ($('#chargement').get() == '') {
-
 
165
		$('#tpl-chargement').tmpl().appendTo(element);
-
 
166
	}
-
 
167
}
-
 
168
 
-
 
169
function supprimerMessageChargement() {
-
 
170
	$('#chargement').remove();
-
 
171
}
-
 
172
 
-
 
173
function lancerChargementObs() {
-
 
174
	var urlObsNbre = urlObsStation;
-
 
175
	urlObsNbre = urlObsNbre.replace(/\{action\}/g, 'observations-nombre');
-
 
176
	urlObsNbre = urlObsNbre.replace(/\{stationId\}/g, pointClique.stationId);
-
 
177
	console.log("Lancement recup nombre");
-
 
178
	$.getJSON(urlObsNbre, function(infos){
-
 
179
		console.log("Lancement charger obs");
-
 
180
		chargerObs(0, infos.obsNbre);
-
 
181
		station = infos;
-
 
182
		actualiserPagineur();
-
 
183
		creerTitreInfoBulle();
-
 
184
	});
-
 
185
}
-
 
186
 
-
 
187
function actualiserPagineur() {
-
 
188
	pagineur.stationId = pointClique.stationId;
-
 
189
	pagineur.total = station.obsNbre;
-
 
190
	console.log(pagineur.total);
-
 
191
	if (pagineur.total > 4) {
-
 
192
		pagineur.format = 'tableau';
-
 
193
	} else {
-
 
194
		pagineur.format = 'liste';
-
 
195
	}
-
 
196
}
-
 
197
 
-
 
198
function chargerObs(depart, total) {
-
 
199
	if (depart < total) {
-
 
200
		var limite = 300;
-
 
201
		if (depart == 0) {
-
 
202
			obsStation = new Array();
-
 
203
		}
-
 
204
		console.log("Chargement de "+depart+" à "+(depart+limite));
-
 
205
		var urlObs = urlObsStation+'&start={start}&limit='+limite;
-
 
206
		urlObs = urlObs.replace(/\{action\}/g, 'observations');
-
 
207
		urlObs = urlObs.replace(/\{stationId\}/g, pointClique.stationId);
-
 
208
		urlObs = urlObs.replace(/\{start\}/g, depart);
-
 
209
		
-
 
210
		$.getJSON(urlObs, function(observations){
-
 
211
			obsStation = obsStation.concat(observations.observations);
-
 
212
			console.log("Chargement ok");
-
 
213
			chargerObs(depart+limite, total);
-
 
214
		});
-
 
215
	} else {
-
 
216
		if (pagineur.limite < total) {
-
 
217
			afficherPagination();
-
 
218
		} else {
-
 
219
			surClicPagePagination(0, null);
-
 
220
		}
-
 
221
	}
-
 
222
}
-
 
223
 
-
 
224
 
-
 
225
function afficherPagination(observations) {
-
 
226
	$(".navigation").pagination(pagineur.total, {
-
 
227
		items_per_page:pagineur.limite,
-
 
228
		callback:surClicPagePagination,
-
 
229
		next_text:'Suivant',
-
 
230
		prev_text:'Précédent',
-
 
231
		prev_show_always:false,
-
 
232
		num_edge_entries:1,
-
 
233
		num_display_entries:5,
-
 
234
		load_first_page:true
-
 
235
	});
-
 
236
}
-
 
237
 
-
 
238
function surClicPagePagination(pageIndex, paginationConteneur) {
-
 
239
	var index = pageIndex * pagineur.limite;
-
 
240
	var indexMax = index + pagineur.limite;
-
 
241
	pagineur.depart = index;
-
 
242
	obsPage = new Array();
-
 
243
    for(index; index < indexMax; index++) {
-
 
244
    	obsPage.push(obsStation[index]);
-
 
245
    }
-
 
246
    
-
 
247
    supprimerMessageChargement();
-
 
248
    mettreAJourObservations();
-
 
249
	return false;
-
 
250
}
-
 
251
 
-
 
252
function mettreAJourObservations() {
-
 
253
	$("#obs-"+pagineur.format+"-lignes").empty();
-
 
254
   	$("#obs-vue-"+pagineur.format).css('display', 'block');
-
 
255
   	$(".obs-conteneur").css('counter-reset', 'item '+pagineur.depart);
-
 
256
	$("#tpl-obs-"+pagineur.format).tmpl(obsPage).appendTo("#obs-"+pagineur.format+"-lignes");
-
 
257
	
-
 
258
	// Actualisation de Fancybox
153
	if ($("#observations ol").get() != '') {
259
	if (pagineur.format == 'liste') {
154
		ajouterGaleriePhoto("a.cel-img");
260
		ajouterGaleriePhoto("a.cel-img");
155
	}
261
	}
156
}
262
}
-
 
263
 
-
 
264
function creerTitreInfoBulle() {
-
 
265
	$("#obs-total").append(station.obsNbre);
-
 
266
	$("#obs-commune").append(station.commune);	
-
 
267
}
-
 
268
 
-
 
269
function initialiserContenuInfoBulle() {
-
 
270
	afficherOnglets();
-
 
271
	afficherMessageChargement('#observations');
-
 
272
	ajouterTableauTriable("#obs-tableau");
-
 
273
	afficherTextStationId();
-
 
274
	corrigerLargeurInfoWindow();
-
 
275
}
-
 
276
 
-
 
277
function afficherOnglets() {
-
 
278
	var $tabs = $('#obs').tabs();
-
 
279
	$('#obs').bind('tabsselect', function(event, ui) {
-
 
280
		if (ui.panel.id == 'obs-vue-tableau') {
-
 
281
			surClicAffichageTableau();
-
 
282
		} else if (ui.panel.id == 'obs-vue-liste') {
-
 
283
			surClicAffichageListe();
-
 
284
		}
-
 
285
	});
-
 
286
	$tabs.tabs('select', "#obs-vue-"+pagineur.format);
-
 
287
}
-
 
288
 
-
 
289
function afficherTextStationId() {
-
 
290
	$('#obs-station-id').text(pointClique.stationId);
-
 
291
}
-
 
292
 
-
 
293
function corrigerLargeurInfoWindow() {
-
 
294
	$("#info-bulle").width($("#info-bulle").width() - 16);
-
 
295
}
-
 
296
 
-
 
297
function surClicAffichageTableau(event) {
-
 
298
	console.log('tableau');
-
 
299
	pagineur.format = 'tableau';
-
 
300
	mettreAJourObservations();
-
 
301
	mettreAJourTableauTriable("#obs-tableau");
-
 
302
}
-
 
303
 
-
 
304
function surClicAffichageListe(event) {
-
 
305
	console.log('liste');
-
 
306
	pagineur.format = 'liste';
-
 
307
	mettreAJourObservations();
-
 
308
	ajouterGaleriePhoto("a.cel-img");
-
 
309
}
157
 
310
 
158
function ajouterTableauTriable(element) {
311
function ajouterTableauTriable(element) {
159
	// add parser through the tablesorter addParser method 
312
	// add parser through the tablesorter addParser method 
160
	$.tablesorter.addParser({ 
313
	$.tablesorter.addParser({ 
161
		// Définition d'un id unique pour ce parsseur 
314
		// Définition d'un id unique pour ce parsseur 
162
		id: 'date_cel', 
315
		id: 'date_cel', 
163
		is: function(s) { 
316
		is: function(s) { 
164
			// retourne false si le parsseur n'est pas autodétecté 
317
			// doit retourner false si le parsseur n'est pas autodétecté
165
			return false; 
318
			return /^\s*\d{2}[\/-]\d{2}[\/-]\d{4}\s*$/.test(s);
166
		}, 
319
		}, 
167
		format: function(s) { 
320
		format: function(date) { 
168
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
321
			// Transformation date jj/mm/aaaa en aaaa/mm/jj
169
			s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1");
322
			date = date.replace(/^\s*(\d{2})[\/-](\d{2})[\/-](\d{4})\s*$/, "$3/$2/$1");
170
			// Remplace la date par un nombre de millisecondes pour trier numériquement
323
			// Remplace la date par un nombre de millisecondes pour trier numériquement
171
			return $.tablesorter.formatFloat(new Date(s).getTime());
324
			return $.tablesorter.formatFloat(new Date(date).getTime());
172
		}, 
325
		}, 
173
		// set type, either numeric or text 
326
		// set type, either numeric or text 
174
		type: 'numeric' 
327
		type: 'numeric' 
175
	});
328
	});
176
	$(element).tablesorter({ 
329
	$(element).tablesorter({ 
177
        headers: { 
330
        headers: { 
178
            1: { 
331
			1: { 
179
                sorter:'date_cel' 
332
            	sorter:'date_cel' 
180
            } 
-
 
181
        } 
333
        	} 
182
    });
334
    	} 
183
}
-
 
184
 
-
 
185
function ajouterGaleriePhoto(element) {
-
 
186
	$(element).fancybox({
-
 
187
		transitionIn : 'elastic',
-
 
188
		transitionOut : 'elastic',
-
 
189
		speedIn	 : 600, 
-
 
190
		speedOut : 200, 
-
 
191
		overlayShow : true
-
 
192
	}).live('click', function(e) {
-
 
193
		if (e.stopPropagation) {
-
 
194
			e.stopPropagation();
-
 
195
		}
-
 
196
		return false;
-
 
197
	});
335
	});
198
}
336
}
199
 
337
 
200
function deplacerCartePointClique() {
338
function mettreAJourTableauTriable(element) {
201
	map.panTo(pointClique.position);
339
	$(element).trigger('update');
202
}
340
}
203
 
341
 
204
function executerMarkerClusterer(points, bounds) {
342
function ajouterGaleriePhoto(element) {
-
 
343
	$(element).fancybox({
-
 
344
		transitionIn:'elastic',
205
	if (markerClusterer) {
345
		transitionOut:'elastic',
-
 
346
		speedIn	:600, 
-
 
347
		speedOut:200,
-
 
348
		overlayShow:true,
206
		markerClusterer.clearMarkers();
349
		titleShow:true,
-
 
350
		titlePosition:'inside',
207
	}
351
		titleFormat:function (titre, currentArray, currentIndex, currentOpts) {
-
 
352
			var motif = /urn:lsid:tela-botanica[.]org:cel:img([0-9]+)$/;
-
 
353
			motif.exec(titre);
-
 
354
			var id = RegExp.$1;
-
 
355
			var info = $('#cel-info-'+id).clone().html();
-
 
356
			var tpl = 
-
 
357
				'<div class="cel-legende">'+
-
 
358
				'<p class="cel-legende-vei">'+'Image n°' + (currentIndex + 1) + ' sur ' + currentArray.length +'<\/p>'+	
-
 
359
				(titre && titre.length ? '<p>'+info+'<\/p>' : '' )+
208
	markerClusterer = new MarkerClusterer(map, points);
360
				'<\/div>';
209
	map.fitBounds(bounds);
-
 
210
}
361
			return tpl;
211
 
362
		}
212
function afficherMsgChargement() {
363
		}).live('click', function(e) {
-
 
364
			if (e.stopPropagation) {
213
	var chargement = document.getElementById('chargement').cloneNode(true);
365
				e.stopPropagation();
-
 
366
			}
214
	chargement.setAttribute('id', 'chargement-copie');
367
			return false;
215
	infoBulle.setContent(chargement);
-
 
216
}
-
 
217
 
-
 
218
var pagineur = {'limite':150, 'obsTotal':0, 'stationId':null, 'format':null};
-
 
219
 
368
		});
220
function handlePaginationClick(new_page_index, pagination_container) {
-
 
221
	$('.obs-liste-conteneur').css('display', 'none');
-
 
222
	$('#chargement').clone().attr('id', 'chargement-copie').appendTo('#observations').css('display', 'block');
-
 
223
	console.log($('#chargement').get());
369
}
224
	
-
 
225
	var start = new_page_index * pagineur.limite;
-
 
226
	var url = urlObs+
-
 
227
	'&format='+pagineur.format+
-
 
228
	'&station='+pagineur.stationId+
-
 
229
	'&start='+start+
-
 
230
	'&limit='+pagineur.limite;
-
 
231
	$.get(url, function(observations) {
-
 
232
		$('#chargement-copie').remove();
-
 
233
		$('.obs-liste-conteneur').css('display', 'block');
-
 
234
		$('#obs-liste').empty();
-
 
235
		$('#obs-liste').append(observations);
-
 
236
	});
370
 
237
	return false;
371
/*+--------------------------------------------------------------------------------------------------------+*/
238
}
-
 
239
 
-
 
240
function chargerFormatObs(stationId, format) {
-
 
241
	pagineur.obsTotal = parseInt($('#obs-total').text());
-
 
242
	pagineur.stationId = stationId;
-
 
243
	pagineur.format = format;
-
 
244
	
372
// PANNEAU LATÉRAL
245
	var start = 1 * pagineur.limite;
-
 
246
	var url = urlStation+
373
 
247
		'&format='+format+
-
 
248
		'&station='+stationId+
-
 
249
		'&start='+start+
-
 
250
		'&limit='+pagineur.limite;
374
function initialiserAffichagePanneauLateral() {
251
	$.get(url, function(observations){
-
 
252
		infoBulle.setContent(observations);
-
 
253
		// First Parameter: number of items
-
 
254
		// Second Parameter: options object
-
 
255
		$("#pagination").pagination(pagineur.obsTotal, {
-
 
256
			items_per_page:pagineur.limite,
-
 
257
			callback:handlePaginationClick
-
 
258
		});
-
 
259
	});
-
 
260
}
-
 
261
 
375
	$('#panneau-lateral').height($(window).height() - 35);
262
function arreter(event) {
376
	
263
	if (event.stopPropagation) {
-
 
264
		event.stopPropagation();
377
	if (nt == '*') {
265
	} else if (window.event) {
378
		$('#pl-ouverture').bind('click', afficherPanneauLateral);
266
		window.event.cancelBubble = true;
379
		$('#pl-fermeture').bind('click', cacherPanneauLateral);
267
	}
380
		$('.taxon').live('click', filtrerParTaxon);
268
	return false;
381
	}
269
}
382
}
270
 
383
 
271
function afficher() {
384
function afficherPanneauLateral() {
272
	$('#panneau-lateral').width(300);
385
	$('#panneau-lateral').width(300);
273
	$('#pl-contenu').css('display', 'block');
386
	$('#pl-contenu').css('display', 'block');
274
	$('#pl-ouverture').css('display', 'none');
387
	$('#pl-ouverture').css('display', 'none');
275
	$('#pl-fermeture').css('display', 'block');
388
	$('#pl-fermeture').css('display', 'block');
276
	$('#carte').css('left', '300px');
389
	$('#carte').css('left', '300px');
277
 
390
 
278
	google.maps.event.trigger(map, 'resize');
391
	google.maps.event.trigger(map, 'resize');
279
};
392
};
280
 
393
 
281
function cacher() {
394
function cacherPanneauLateral() {
282
	$('#panneau-lateral').width(24);
395
	$('#panneau-lateral').width(24);
283
	$('#pl-contenu').css('display', 'none');
396
	$('#pl-contenu').css('display', 'none');
284
	$('#pl-ouverture').css('display', 'block');
397
	$('#pl-ouverture').css('display', 'block');
285
	$('#pl-fermeture').css('display', 'none');
398
	$('#pl-fermeture').css('display', 'none');
286
	$('#carte').css('left', '24px');
399
	$('#carte').css('left', '24px');
287
	
400
	
288
	google.maps.event.trigger(map, 'resize');
401
	google.maps.event.trigger(map, 'resize');
289
};
402
};
290
 
403
 
291
function ouvrirPopUp(url, nom) {
404
function ouvrirPopUp(url, nom) {
292
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
405
	window.open(url, nom, 'scrollbars=yes,width=650,height=600,directories=no,location=no,menubar=no,status=no,toolbar=no');
293
};
406
};
294
 
407
 
295
function filtrerParTaxon() {
408
function filtrerParTaxon() {
296
	var ntAFiltrer = $('.nt', this).text();
409
	var ntAFiltrer = $('.nt', this).text();
297
	infoBulle.close();
410
	infoBulle.close();
298
	$('#taxon-'+nt).removeClass('taxon-actif');
411
	$('#taxon-'+nt).removeClass('taxon-actif');
299
	if (nt == ntAFiltrer) {
412
	if (nt == ntAFiltrer) {
300
		nt = '*';
413
		nt = '*';
301
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
414
		executerMarkerClusterer(pointsOrigine, boundsOrigine);
302
	} else {
415
	} else {
303
		var url = urlObsCarte+'&'+
416
		var url = urlObsCarte+'&'+
304
			'num_taxon='+ntAFiltrer+'&'+
417
			'num_taxon='+ntAFiltrer+'&'+
305
			'formatRetour=jsonp'+'&'+
418
			'formatRetour=jsonp'+'&'+
306
			'callback=?';
419
			'callback=?';
307
		$.getJSON(url, function (observations) {
420
		$.getJSON(url, function (observations) {
308
			obs = observations;
421
			obs = observations;
309
			nt = ntAFiltrer;
422
			nt = ntAFiltrer;
310
			$('#taxon-'+nt).addClass('taxon-actif');
423
			$('#taxon-'+nt).addClass('taxon-actif');
311
			rafraichirCarte();
424
			rafraichirCarte();
312
		});
425
		});
313
	}
426
	}
314
};
427
};
-
 
428
 
-
 
429
/*+--------------------------------------------------------------------------------------------------------+*/
-
 
430
// FONCTIONS UTILITAIRES
-
 
431
 
-
 
432
function arreter(event) {
-
 
433
	if (event.stopPropagation) {
-
 
434
		event.stopPropagation();
-
 
435
	} else if (window.event) {
-
 
436
		window.event.cancelBubble = true;
-
 
437
	}
-
 
438
	return false;
-
 
439
}
315
 
440
 
316
/**
441
/**
317
 * +-------------------------------------+
442
 * +-------------------------------------+
318
 * Number.prototype.formaterNombre
443
 * Number.prototype.formaterNombre
319
 * +-------------------------------------+
444
 * +-------------------------------------+
320
 * Params (facultatifs):
445
 * Params (facultatifs):
321
 * - Int decimales: nombre de decimales (exemple: 2)
446
 * - Int decimales: nombre de decimales (exemple: 2)
322
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
447
 * - String signe: le signe precedent les decimales (exemple: "," ou ".")
323
 * - String separateurMilliers: comme son nom l'indique
448
 * - String separateurMilliers: comme son nom l'indique
324
 * Returns:
449
 * Returns:
325
 * - String chaine formatee
450
 * - String chaine formatee
326
 * @author	::mastahbenus::
451
 * @author	::mastahbenus::
327
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
452
 * @author	Jean-Pascal MILCENT <jpm@tela-botanica.org> : ajout détection auto entier/flotant
328
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
453
 * @souce	http://www.javascriptfr.com/codes/FORMATER-NOMBRE-FACON-NUMBER-FORMAT-PHP_40060.aspx
329
 */
454
 */
330
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
455
Number.prototype.formaterNombre = function (decimales, signe, separateurMilliers) {
331
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
456
	var _sNombre = String(this), i, _sRetour = "", _sDecimales = "";
332
	
457
	
333
	function is_int(nbre) {
458
	function is_int(nbre) {
334
		nbre = nbre.replace(',', '.');
459
		nbre = nbre.replace(',', '.');
335
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
460
		return !(parseFloat(nbre)-parseInt(nbre) > 0);
336
	}
461
	}
337
 
462
 
338
	if (decimales == undefined) {
463
	if (decimales == undefined) {
339
		if (is_int(_sNombre)) {
464
		if (is_int(_sNombre)) {
340
			decimales = 0;
465
			decimales = 0;
341
		} else {
466
		} else {
342
			decimales = 2;
467
			decimales = 2;
343
		}
468
		}
344
	}
469
	}
345
	if (signe == undefined) {
470
	if (signe == undefined) {
346
		if (is_int(_sNombre)) {
471
		if (is_int(_sNombre)) {
347
			signe = '';
472
			signe = '';
348
		} else {
473
		} else {
349
			signe = '.';
474
			signe = '.';
350
		}
475
		}
351
	}
476
	}
352
	if (separateurMilliers == undefined) {
477
	if (separateurMilliers == undefined) {
353
		separateurMilliers = ' ';
478
		separateurMilliers = ' ';
354
	}
479
	}
355
	
480
	
356
	function separeMilliers (sNombre) {
481
	function separeMilliers (sNombre) {
357
		var sRetour = "";
482
		var sRetour = "";
358
		while (sNombre.length % 3 != 0) {
483
		while (sNombre.length % 3 != 0) {
359
			sNombre = "0"+sNombre;
484
			sNombre = "0"+sNombre;
360
		}
485
		}
361
		for (i = 0; i < sNombre.length; i += 3) {
486
		for (i = 0; i < sNombre.length; i += 3) {
362
			if (i == sNombre.length-1) separateurMilliers = '';
487
			if (i == sNombre.length-1) separateurMilliers = '';
363
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
488
			sRetour += sNombre.substr(i, 3) + separateurMilliers;
364
		}
489
		}
365
		while (sRetour.substr(0, 1) == "0") {
490
		while (sRetour.substr(0, 1) == "0") {
366
			sRetour = sRetour.substr(1);
491
			sRetour = sRetour.substr(1);
367
		}
492
		}
368
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
493
		return sRetour.substr(0, sRetour.lastIndexOf(separateurMilliers));
369
	}
494
	}
370
	
495
	
371
	if (_sNombre.indexOf('.') == -1) {
496
	if (_sNombre.indexOf('.') == -1) {
372
		for (i = 0; i < decimales; i++) {
497
		for (i = 0; i < decimales; i++) {
373
			_sDecimales += "0";
498
			_sDecimales += "0";
374
		}
499
		}
375
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
500
		_sRetour = separeMilliers(_sNombre) + signe + _sDecimales;
376
	} else {
501
	} else {
377
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
502
		var sDecimalesTmp = (_sNombre.substr(_sNombre.indexOf('.')+1));
378
		if (sDecimalesTmp.length > decimales) {
503
		if (sDecimalesTmp.length > decimales) {
379
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
504
			var nDecimalesManquantes = sDecimalesTmp.length - decimales;
380
			var nDiv = 1;
505
			var nDiv = 1;
381
			for (i = 0; i < nDecimalesManquantes; i++) {
506
			for (i = 0; i < nDecimalesManquantes; i++) {
382
				nDiv *= 10;
507
				nDiv *= 10;
383
			}
508
			}
384
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
509
			_sDecimales = Math.round(Number(sDecimalesTmp) / nDiv);
385
		}
510
		}
386
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
511
		_sRetour = separeMilliers(_sNombre.substr(0, _sNombre.indexOf('.')))+String(signe)+_sDecimales;
387
	}
512
	}
388
	return _sRetour;
513
	return _sRetour;
-
 
514
}
-
 
515
 
-
 
516
function debug(objet) {
-
 
517
	var msg = '';
-
 
518
	if (objet != null) {
-
 
519
		$.each(objet, function (cle, valeur) {
-
 
520
			msg += cle+":"+valeur + "\n";
-
 
521
		});
-
 
522
	} else {
-
 
523
		msg = "La variable vaut null.";
-
 
524
	}
-
 
525
	console.log(msg);
389
}
526
}
390
527