Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1441 → Rev 1442

/trunk/widget/modules/cartopoint/squelettes/scripts/carto.js
65,7 → 65,8
 
function initialiserWidget() {
urlVars = getUrlVars();
definirTailleTitre();
definirTailleOverlay();
attribuerListenersOverlay();
centrerTitreEtStats();
initialiserAffichageCarte();
initialiserAffichagePanneauLateral();
75,7 → 76,6
initialiserFormulaireContact();
chargerLimitesCommunales();
attribuerListenerCarte();
programmerRafraichissementCarte();
}
 
function getUrlVars()
153,35 → 153,73
centrerTitreEtStats();
}
 
var tailleTitreOriginelle = null;
function definirTailleTitre() {
function attribuerListenersOverlay() {
$(window).resize(function() {
programmerRafraichissementCarte();
definirTailleOverlay();
centrerTitreEtStats();
google.maps.event.trigger($('#carte'), 'resize');
});
$('#lien_plein_ecran a').click(function(event) {
window.open(window.location.href);
});
$('#lien_voir_cc a').click(function(event) {
window.open($(this).attr('href'));
});
}
 
function definirTailleOverlay() {
var largeurViewPort = $(window).width();
var taille = null;
if (largeurViewPort < 400) {
var tailleMaxLogo = 50;
var tailleMaxIcones = 20;
var padding_icones = 8;
if (largeurViewPort <= 500) {
taille = '0.8';
} else if (largeurViewPort >= 400 && largeurViewPort < 800) {
tailleMaxLogo = 20;
tailleMaxIcones = 10;
padding_icones = 2;
} else if (largeurViewPort > 500 && largeurViewPort <= 800) {
taille = '1.0';
} else if (largeurViewPort >= 800) {
tailleMaxLogo = 40;
tailleMaxIcones = 15;
padding_icones = 6;
} else if (largeurViewPort > 800) {
taille = '1.6';
tailleMaxLogo = 50;
tailleMaxIcones = 20;
padding_icones = 8;
}
// Aménagement de la taille de police selon l'écran
$("#carte-titre").css('font-size', taille+'em');
$("#zone-stats h1").css('font-size', taille+'em');
$("#zone-stats").css('padding', padding_icones+"px "+padding_icones+"px "+Math.round(padding_icones/4)+"px");
$('.icone').height(tailleMaxIcones);
$('#lien_plein_ecran').css("padding", padding_icones+"px "+padding_icones+"px "+Math.ceil(padding_icones/2)+"px");
$('#lien_voir_cc').css("padding", padding_icones+"px "+padding_icones+"px "+Math.ceil(padding_icones/2)+"px");
$('#zone-stats').height(tailleMaxIcones*1.5);
// Dimensionnement du titre et du logo
if(urlLogo != "null") {
hauteurLogo = $('#logo img').height();
// Redimensionnement du logo s'il est trop grand
// on perd en qualité mais ça vaut mieux que de casser l'affichage
if(hauteurLogo > 60) {
hauteurLogo = 60;
$('#logo img').height(60);
if(hauteurLogo > tailleMaxLogo) {
hauteurLogo = tailleMaxLogo;
$('#logo img').height(tailleMaxLogo);
}
if(hauteurLogo == 0) {
$('#logo img').load(function(event) {
definirTailleTitre();
definirTailleOverlay();
});
return;
}
195,17 → 233,25
if(titreCarte != 'null' && titreCarte != 0) {
$('#carte-titre-infos').css("position", "absolute");
$('#carte-titre-infos').css("left", (largeurLogo+16)+"px");
$('#carte-titre-infos').css("top", (hauteurLogo/2 - 8)+"px");
$('#carte-titre-infos').css("top", (hauteurLogo/2)+"px");
}
}
}
 
function centrerTitreEtStats() {
centrerTitre();
centrerStats();
}
 
function centrerTitre() {
var largeurViewPort = $(window).width();
var largeurTitre = $('#zone-titre').width();
var marge = (largeurViewPort - largeurTitre)/2;
$('#zone-titre').css("margin-left",marge);
}
 
function centrerStats() {
var largeurViewPort = $(window).width();
var largeurStats = $('#zone-stats').width();
var marge = (largeurViewPort - largeurStats)/2;
$('#zone-stats').css("left",marge);
297,7 → 343,18
});
}
 
function centrerDansLaPage(selecteur) {
var largeurViewport = $(window).width();
var hauteurViewport = $(window).height();
selecteur.css('display','block');
var left = (largeurViewport/2) - (selecteur.width())/2;
var top = (hauteurViewport/2) - (selecteur.height())/2
selecteur.css('left',left);
selecteur.css('top',top);
}
 
function afficherMessageChargementPoints() {
centrerDansLaPage($('#zone-chargement-point'));
$('#zone-chargement-point').css('display','block');
}
 
305,6 → 362,11
$('#zone-chargement-point').css('display','none');
}
 
function afficherMessageAucuneObs() {
centrerDansLaPage($('#message-aucune-obs'));
selecteur.show();
}
 
premierChargement = true;
function doitCentrerCarte() {
return premierChargement && urlVars != null && urlVars.length > 0;
311,29 → 373,33
}
 
function rafraichirMarqueurs(data) {
$.each(marqueurs, function(index, marqueur) {
marqueur.setMap(null);
});
marqueurs = new Array();
stations = data;
afficherTitreCarteEtStats();
$.each(stations.points, function (index, station) {
if(station != null) {
var nouveauMarqueur = creerMarqueur(station);
marqueurs.push(nouveauMarqueur);
if(data.points.length > 0) {
$.each(marqueurs, function(index, marqueur) {
marqueur.setMap(null);
});
marqueurs = new Array();
stations = data;
afficherTitreCarteEtStats();
$.each(stations.points, function (index, station) {
if(station != null) {
var nouveauMarqueur = creerMarqueur(station);
marqueurs.push(nouveauMarqueur);
}
});
if(doitCentrerCarte()) {
premierChargement = false;
var bounds = new google.maps.LatLngBounds();
var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
bounds.extend(latMax);
bounds.extend(latMin);
rendrePointsVisibles(bounds);
}
});
if(doitCentrerCarte()) {
premierChargement = false;
var bounds = new google.maps.LatLngBounds();
var latMax = new google.maps.LatLng(data.stats.coordmax.latMax, data.stats.coordmax.lngMax);
var latMin = new google.maps.LatLng(data.stats.coordmax.latMin, data.stats.coordmax.lngMin);
bounds.extend(latMax);
bounds.extend(latMin);
rendrePointsVisibles(bounds);
} else {
afficherMessageAucuneObs();
}
}