Subversion Repositories eFlore/Applications.cel

Rev

Rev 1438 | Rev 1445 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1438 Rev 1442
Line 63... Line 63...
63
	initialiserWidget();
63
	initialiserWidget();
64
});
64
});
Line 65... Line 65...
65
 
65
 
66
function initialiserWidget() {
66
function initialiserWidget() {
67
	urlVars = getUrlVars();
67
	urlVars = getUrlVars();
-
 
68
	definirTailleOverlay();
68
	definirTailleTitre();
69
	attribuerListenersOverlay();
69
	centrerTitreEtStats();
70
	centrerTitreEtStats();
70
	initialiserAffichageCarte();
71
	initialiserAffichageCarte();
71
	initialiserAffichagePanneauLateral();
72
	initialiserAffichagePanneauLateral();
72
	initialiserCarte();
73
	initialiserCarte();
73
	initialiserGestionnaireMarqueurs()
74
	initialiserGestionnaireMarqueurs()
74
	initialiserInfoBulle();
75
	initialiserInfoBulle();
75
	initialiserFormulaireContact();
76
	initialiserFormulaireContact();
76
	chargerLimitesCommunales();
77
	chargerLimitesCommunales();
77
	attribuerListenerCarte();
-
 
78
	programmerRafraichissementCarte();
78
	attribuerListenerCarte();
Line 79... Line 79...
79
}
79
}
80
 
80
 
81
function getUrlVars()
81
function getUrlVars()
Line 151... Line 151...
151
		$('#zone-stats > h1').text(stats);
151
		$('#zone-stats > h1').text(stats);
152
	}
152
	}
153
	centrerTitreEtStats();
153
	centrerTitreEtStats();
154
}
154
}
Line 155... Line 155...
155
 
155
 
-
 
156
function attribuerListenersOverlay() {
-
 
157
	
-
 
158
	$(window).resize(function() {
-
 
159
		programmerRafraichissementCarte();
-
 
160
		definirTailleOverlay();
-
 
161
		centrerTitreEtStats();
-
 
162
		google.maps.event.trigger($('#carte'), 'resize');
-
 
163
	});
-
 
164
	
-
 
165
	$('#lien_plein_ecran a').click(function(event) {
-
 
166
		window.open(window.location.href);
-
 
167
	});
-
 
168
	
-
 
169
	$('#lien_voir_cc a').click(function(event) {
-
 
170
		window.open($(this).attr('href'));
-
 
171
	});
-
 
172
}
156
var tailleTitreOriginelle = null;
173
 
157
function definirTailleTitre() {
174
function definirTailleOverlay() {
158
	var largeurViewPort = $(window).width();
175
	var largeurViewPort = $(window).width();
-
 
176
	var taille = null;
-
 
177
	var tailleMaxLogo = 50;
-
 
178
	var tailleMaxIcones = 20;
159
	var taille = null;
179
	var padding_icones = 8;
160
	if (largeurViewPort < 400) {
180
	if (largeurViewPort <= 500) {
-
 
181
		taille = '0.8';
-
 
182
		tailleMaxLogo = 20;
-
 
183
		tailleMaxIcones = 10;
-
 
184
		padding_icones = 2;
161
		taille = '0.8';
185
		
162
	} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
186
	} else if (largeurViewPort > 500 && largeurViewPort <= 800) {
-
 
187
		taille = '1.0';
-
 
188
		tailleMaxLogo = 40;
-
 
189
		tailleMaxIcones = 15;
163
		taille = '1.0';
190
		padding_icones = 6;
164
	} else if (largeurViewPort >= 800) {
191
	} else if (largeurViewPort > 800) {
-
 
192
		taille = '1.6';
-
 
193
		tailleMaxLogo = 50;
-
 
194
		tailleMaxIcones = 20;
165
		taille = '1.6';
195
		padding_icones = 8;
Line 166... Line 196...
166
	}
196
	}
167
	
197
	
-
 
198
	// Aménagement de la taille de police selon l'écran
168
	// Aménagement de la taille de police selon l'écran
199
	$("#carte-titre").css('font-size', taille+'em');
-
 
200
	
-
 
201
	$("#zone-stats h1").css('font-size', taille+'em');
-
 
202
	$("#zone-stats").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px");
-
 
203
	
-
 
204
	$('.icone').height(tailleMaxIcones);
-
 
205
	$('#lien_plein_ecran').css("padding", padding_icones+"px "+padding_icones+"px "+Math.ceil(padding_icones/2)+"px");
-
 
206
	$('#lien_voir_cc').css("padding", padding_icones+"px "+padding_icones+"px "+Math.ceil(padding_icones/2)+"px");
Line 169... Line 207...
169
	$("#carte-titre").css('font-size', taille+'em');
207
	
170
	$("#zone-stats h1").css('font-size', taille+'em');
208
	$('#zone-stats').height(tailleMaxIcones*1.5);
171
	
209
	
172
	// Dimensionnement du titre et du logo
210
	// Dimensionnement du titre et du logo
173
	if(urlLogo != "null") {
211
	if(urlLogo != "null") {
174
		hauteurLogo = $('#logo img').height();
212
		hauteurLogo = $('#logo img').height();
175
		// Redimensionnement du logo s'il est trop grand
213
		// Redimensionnement du logo s'il est trop grand
176
		// on perd en qualité mais ça vaut mieux que de casser l'affichage
214
		// on perd en qualité mais ça vaut mieux que de casser l'affichage
177
		if(hauteurLogo > 60) {
215
		if(hauteurLogo > tailleMaxLogo) {
Line 178... Line 216...
178
			hauteurLogo = 60;
216
			hauteurLogo = tailleMaxLogo;
179
			$('#logo img').height(60);
217
			$('#logo img').height(tailleMaxLogo);
180
		}
218
		}
181
		
219
		
182
		if(hauteurLogo == 0) {
220
		if(hauteurLogo == 0) {
183
			$('#logo img').load(function(event) {
221
			$('#logo img').load(function(event) {
Line 184... Line 222...
184
				definirTailleTitre();
222
				definirTailleOverlay();
Line 193... Line 231...
193
		$('#zone-titre').css("width", (largeurLogo+largeurTitre+16)+"px");
231
		$('#zone-titre').css("width", (largeurLogo+largeurTitre+16)+"px");
Line 194... Line 232...
194
		
232
		
195
		if(titreCarte != 'null' && titreCarte != 0) {
233
		if(titreCarte != 'null' && titreCarte != 0) {
196
			$('#carte-titre-infos').css("position", "absolute");
234
			$('#carte-titre-infos').css("position", "absolute");
197
			$('#carte-titre-infos').css("left", (largeurLogo+16)+"px");
235
			$('#carte-titre-infos').css("left", (largeurLogo+16)+"px");
198
			$('#carte-titre-infos').css("top", (hauteurLogo/2 - 8)+"px");
236
			$('#carte-titre-infos').css("top", (hauteurLogo/2)+"px");
199
		}
237
		}
200
	}
238
	}
Line 201... Line 239...
201
}
239
}
-
 
240
 
-
 
241
function centrerTitreEtStats() {
-
 
242
	centrerTitre();
-
 
243
	centrerStats();
-
 
244
}
202
 
245
 
203
function centrerTitreEtStats() {
246
function centrerTitre() {
204
	var largeurViewPort = $(window).width();
247
	var largeurViewPort = $(window).width();
205
	var largeurTitre = $('#zone-titre').width();
248
	var largeurTitre = $('#zone-titre').width();
-
 
249
	var marge = (largeurViewPort - largeurTitre)/2;
206
	var marge = (largeurViewPort - largeurTitre)/2;
250
	$('#zone-titre').css("margin-left",marge);
-
 
251
}
-
 
252
 
207
	$('#zone-titre').css("margin-left",marge);
253
function centrerStats() {
208
	
254
	var largeurViewPort = $(window).width();
209
	var largeurStats = $('#zone-stats').width();
255
	var largeurStats = $('#zone-stats').width();
210
	var marge = (largeurViewPort - largeurStats)/2;
256
	var marge = (largeurViewPort - largeurStats)/2;
Line 295... Line 341...
295
		rafraichirMarqueurs(data);
341
		rafraichirMarqueurs(data);
296
		cacherMessageChargementPoints();
342
		cacherMessageChargementPoints();
297
	});
343
	});
298
}
344
}
Line -... Line 345...
-
 
345
 
-
 
346
function centrerDansLaPage(selecteur) {
-
 
347
	var largeurViewport = $(window).width();
-
 
348
	var hauteurViewport = $(window).height();
-
 
349
	selecteur.css('display','block');
-
 
350
	var left = (largeurViewport/2) - (selecteur.width())/2;
-
 
351
	var top = (hauteurViewport/2) - (selecteur.height())/2
-
 
352
	selecteur.css('left',left);
-
 
353
	selecteur.css('top',top);
-
 
354
}
299
 
355
 
-
 
356
function afficherMessageChargementPoints() {
300
function afficherMessageChargementPoints() {
357
	centrerDansLaPage($('#zone-chargement-point'));
301
	$('#zone-chargement-point').css('display','block');
358
	$('#zone-chargement-point').css('display','block');
Line 302... Line 359...
302
}
359
}
303
 
360
 
304
function cacherMessageChargementPoints() {
361
function cacherMessageChargementPoints() {
Line -... Line 362...
-
 
362
	$('#zone-chargement-point').css('display','none');
-
 
363
}
-
 
364
 
-
 
365
function afficherMessageAucuneObs() {
-
 
366
	centrerDansLaPage($('#message-aucune-obs'));
305
	$('#zone-chargement-point').css('display','none');
367
	selecteur.show();
306
}
368
}
307
 
369
 
308
premierChargement = true;
370
premierChargement = true;
Line 309... Line 371...
309
function doitCentrerCarte() {
371
function doitCentrerCarte() {
-
 
372
	return premierChargement && urlVars != null && urlVars.length > 0;
310
	return premierChargement && urlVars != null && urlVars.length > 0;
373
}
311
}
374
 
312
 
375
function rafraichirMarqueurs(data) {
313
function rafraichirMarqueurs(data) {
376
	if(data.points.length > 0) {
314
	$.each(marqueurs, function(index, marqueur) {
377
		$.each(marqueurs, function(index, marqueur) {
315
		marqueur.setMap(null);
378
			marqueur.setMap(null);
316
	});
379
		});
317
	marqueurs = new Array();
380
		marqueurs = new Array();
318
	
381
		
319
	stations = data;
382
		stations = data;
320
	afficherTitreCarteEtStats();
383
		afficherTitreCarteEtStats();
321
	
384
		
-
 
385
		$.each(stations.points, function (index, station) {		
-
 
386
			if(station != null) {
-
 
387
				var nouveauMarqueur = creerMarqueur(station);
-
 
388
				marqueurs.push(nouveauMarqueur);
-
 
389
			}
-
 
390
		});
-
 
391
		
-
 
392
		if(doitCentrerCarte()) {
-
 
393
			premierChargement = false;
-
 
394
			var bounds = new google.maps.LatLngBounds();
-
 
395
			var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
322
	$.each(stations.points, function (index, station) {		
396
			var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
323
		if(station != null) {
397
			bounds.extend(latMax);
324
			var nouveauMarqueur = creerMarqueur(station);
-
 
325
			marqueurs.push(nouveauMarqueur);
-
 
326
		}
-
 
327
	});
-
 
328
	
-
 
329
	if(doitCentrerCarte()) {
-
 
330
		premierChargement = false;
-
 
331
		var bounds = new google.maps.LatLngBounds();
-
 
332
		var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
398
			bounds.extend(latMin);
333
		var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
399
			rendrePointsVisibles(bounds);	
334
		bounds.extend(latMax);
400
		}
Line 335... Line 401...
335
		bounds.extend(latMin);
401
	} else {
336
		rendrePointsVisibles(bounds);	
402
		afficherMessageAucuneObs();