Subversion Repositories eFlore/Archives.chorologie

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1                                                                                      |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of MON_PROGRAMME.                                                                  |
// |                                                                                                      |
// | Foobar is free software; you can redistribute it and/or modify                                       |
// | it under the terms of the GNU General Public License as published by                                 |
// | the Free Software Foundation; either version 2 of the License, or                                    |
// | (at your option) any later version.                                                                  |
// |                                                                                                      |
// | Foobar is distributed in the hope that it will be useful,                                            |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
// | GNU General Public License for more details.                                                         |
// |                                                                                                      |
// | You should have received a copy of the GNU General Public License                                    |
// | along with Foobar; if not, write to the Free Software                                                |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: echoro_javascript.fonct.php,v 1.1 2005-02-22 12:03:14 jpm Exp $
/**
* Contient les fonctions enregistrant le javascript.
*
* Ces fonctions PHP permettent de paramètrer les fonctions Javascript avant de les insérer dans la page
* courante.
*
*@package eFlore
*@subpackage Chorologie
//Auteur original :
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.1 $ $Date: 2005-02-22 12:03:14 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                           LISTE de FONCTIONS                                         |
// +------------------------------------------------------------------------------------------------------+
/**
* Fonction ajouterInfoBulleJs() - Ajoute javascript info bulle.
*
* Cette fonction permet de configurer une fonction javascript permettant d'afficher 
* des infos bulles.
*
* @param string couleur du texte à afficher dans l'info bulle.
* @param string couleur du fond de l'info bulle.
* @param string couleur des contours de l'info bulle.
* @param string largeur en pixel des bordures de l'info bulle.
* @return string le javascript paramétré est renvoyé.
*/
function ajouterInfoBulleJs($couleur_de_texte = 'navy', $couleur_de_fond = '#FFCC66', $couleur_de_contour = 'orange', $taille_contour = '1') 
{
    $code_javascript = "
        //D'autres scripts sur http://www.toutjavascript.com
        //Si vous utilisez ce script, merci de m'avertir !  < webmaster@toutjavascript.com >
        //Auteur original :Olivier Hondermarck  <webmaster@toutjavascript.com>
        //Modifs compatibilité Netscape 6/Mozilla : Cédric Lamalle 09/2001 <cedric@cpac.embrapa.br>
        //Correction Mac IE5 (Merci Fred)
        var IB=new Object;
        var posX=0;
        var posY=0;
        var xOffset=10;
        var yOffset=10;
        
        function AffBulle(texte) 
        {
            contenu=\"<TABLE border=0 cellspacing=0 cellpadding=\"+IB.NbPixel+\"><TR bgcolor='\"+IB.ColContour+\"'><TD><TABLE border=0 cellpadding=2 cellspacing=0 bgcolor='\"+IB.ColFond+\"'><TR><TD><FONT size='-1' face='arial' color='\"+IB.ColTexte+\"'>\"+texte+\"</FONT></TD></TR></TABLE></TD></TR></TABLE>&nbsp;\";
            
            var finalPosX=posX-xOffset;
            
            if (finalPosX<0) {
                finalPosX=0;
            }
            if (document.layers) {
                document.layers['bulle'].document.write(contenu);
                document.layers['bulle'].document.close();
                document.layers['bulle'].top=posY+yOffset;
                document.layers['bulle'].left=finalPosX;
                document.layers['bulle'].visibility=\"show\";
            }
            if (document.all) {
                bulle.innerHTML=contenu;
                document.all['bulle'].style.top = posY+yOffset;
                document.all['bulle'].style.left = finalPosX;//f.x-xOffset;
                document.all['bulle'].style.visibility = \"visible\";
            }
            //modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
            else if (document.getElementById) {
                document.getElementById('bulle').innerHTML=contenu;
                document.getElementById('bulle').style.top=posY+yOffset;
                document.getElementById('bulle').style.left=finalPosX;
                document.getElementById('bulle').style.visibility=\"visible\";
            }
            //Nous vérifions que nous utilisons bien IE ou Mozilla pour supprimer les valeurs tiltes de images fournissant les infos bulles d'aides.
            //Cela pourrait être amélioré en vérifiant aussi les liens car l'aide pourrait être donnée par l'intermédiaire de lien.
            //alert(navigator.appName);
            if (navigator.appName == 'Netscape' || navigator.appName == 'Microsoft Internet Explorer') {
                for(i=1; i<document.images.length; i++) {
                    var nom = 'info'+i;
                    if (document.images[nom] != null ) {
                        document.images[nom].title = \"\";
                    }
                }
            }
        }
        
        function getMousePos(e) 
        {
            if (document.all) {
                posX=event.x+document.body.scrollLeft; //modifs CL 09/2001 - IE : regrouper l'évènement
                posY=event.y+document.body.scrollTop;
            }
            else {
                posX=e.pageX; //modifs CL 09/2001 - NS6 : celui-ci ne supporte pas e.x et e.y
                posY=e.pageY; 
            }
        }
        
        function HideBulle() 
        {
            if (document.layers) {
                document.layers['bulle'].visibility= 'hide';
            }
            
            if (document.all) {
                document.all['bulle'].style.visibility= 'hidden';
            }
            else if (document.getElementById) {
                document.getElementById('bulle').style.visibility = 'hidden';
            }
        }
        
        function InitBulle(ColTexte,ColFond,ColContour,NbPixel) 
        {
            IB.ColTexte=ColTexte;IB.ColFond=ColFond;IB.ColContour=ColContour;IB.NbPixel=NbPixel;
            if (document.layers) {
                window.captureEvents(Event.MOUSEMOVE);
                window.onMouseMove = getMousePos;
                document.write(\"<layer name='bulle' top=0 left=0 visibility='hide'></layer>\");
            }
            if (document.all) {
                document.write(\"<div id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></div>\");
                document.onmousemove = getMousePos;
            }
            //modif CL 09/2001 - NS6 : celui-ci ne supporte plus document.layers mais document.getElementById
            else if (document.getElementById) {
                document.onmousemove = getMousePos;
                document.write(\"<div id='bulle' style='position:absolute;top:0;left:0;visibility:hidden'></div>\");
            }
        }
        
        InitBulle(\"$couleur_de_texte\",\"$couleur_de_fond\",\"$couleur_de_contour\",$taille_contour);
        //// InitBulle(couleur de texte, couleur de fond, couleur de contour, taille contour);
    ";
    // Nous retournons le javascript une fois configuré.
    return $code_javascript;
}//Fin fonction ajouterInfoBulleJs().

/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>