Subversion Repositories eFlore/Archives.herbiers

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/presentations/scripts/hb_ouvrir_fermer.js
New file
0,0 → 1,358
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | Javascript version 1.5 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) Tela Botanica (accueil@tela-botanica.org), 2005. |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Herbier. |
// | |
// | 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: hb_ouvrir_fermer.js,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
/**
* Script ouvrir-fermer
*
* These scripts were originally found on cooltype.com.
* Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com
* Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
* compatibility for phpMyAdmin
* Rewritten and put in a libray 2nd May 2001 by Loïc Chapeaux
* Traduit en français et utilisé dans Tela-Botanica fin octobre 2000
* par Alexandre Granier et Jean-Pascal Milcent.
* Test réussi avec : (Test passed with:)
* - Mozilla 0.8.1, 0.9.0, 0.9.1, 0.9.2 for Windows (js enabled
* & disabled)
* - IE5, 5.01, 5.5 for Windows
* - Netscape 4.75 for Windows
* Test échoué avec : ((crappy DOM implementations) with:)
* - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
* - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
* be changed
* - Konqueror 2+: 'style.display' can't be changed
*
*@package Herbier
*@subpackage Javascripts
//Auteur original :
*@author cooltype.com
//Autres auteurs :
*@author Tobias Ratschiller
*@author Brian Birtles
*@author Loïc Chapeaux
*@author Alexandre Granier
*@author Jean-Pascal Milcent
*@copyright Tela-Botanica 2000-2005
*@version $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// inclusion intempestive
/**
* Variables et test normalement présent dans le fichier html dans le head entre
* des balises <script></script>
*/
var isDOM = (typeof(document.getElementsByTagName) != 'undefined') ? 1 : 0;
var isIE4 = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0;
var isNS4 = (typeof(document.layers) != 'undefined') ? 1 : 0;
var capable = (isDOM || isIE4 || isNS4) ? 1 : 0;
// Uggly fix for Konqueror and Opera that are not fully DOM compliant
// Implémentation de la variable 'capable' pour Konqueror et Opera qui
// qui ne supporte pas complêtement DOM.
if (capable && typeof(navigator.userAgent) != 'undefined') {
var browserName = ' ' + navigator.userAgent.toLowerCase();
if (browserName.indexOf('opera') > 0 || browserName.indexOf('konqueror') > 0) {
capable = 0;
}
}
var fontFamily = 'arial, geneva, sans-serif';
var isServer = true;
var isExpanded = false;
var imgOpened = new Image(9,9);
imgOpened.src = 'client/herbier/presentations/images/fermer.png';
var imgClosed = new Image(9,9);
imgClosed.src = 'client/herbier/presentations/images/ouvrir.png';
 
 
/**
*Recharge le 'frame' si la fenêtre est redimensionée sous Netscape4+.
*(Do reloads the frame if the window has been resized under Netscape4+)
*
*@access privée (private)
*/
function reDo()
{
if (innerWidth != origWidth || innerHeight != origHeight)
location.reload(true);
} // fin de la fonction 'reDo()' (end of the 'reDo()' function])
 
 
/**
* Positionnement du redimensionnement pour Netscape4+.
* (Positioned element resize bug under NS4+)
*
*/
if (isNS4) {
var origWidth = innerWidth;
var origHeight = innerHeight;
onresize = reDo;
}
 
 
/**
* Prend l'id du premier élement de plier-déplier.
* Fonction utilisée pour Netscape seulement.
* (Gets the id of the first collapsible room)
*
* @param string le nom de la première pièce du plier-déplier (the name of the first collapsible room)
*
* @return integer le numèro d'index correspondant à cette pièce (the index number corresponding to this room)
*
* @access public
*/
function nsGetIndex(el)
{
var ind = null;
var theLayers = document.layers;
var layersCnt = theLayers.length;
for (var i = 0; i < layersCnt; i++) {
if (theLayers[i].id == el) {
ind = i;
break;
}
}
return ind;
} // fin de la fonction 'nsGetIndex()' (end of the 'nsGetIndex()' function)
 
 
/**
* Positions des calques sous Netscape4+.
* (Positions layers under NS4+)
*
* @access public
*/
function nsArrangeList()
{
if (firstInd != null) {
var theLayers = document.layers;
var layersCnt = theLayers.length;
var nextY = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
for (var i = firstInd + 1; i < layersCnt; i++) {
if (theLayers[i].visibility != 'hide') {
theLayers[i].pageY = nextY;
nextY += theLayers[i].document.height;
}
}
}
} // fin de la fonction 'nsArrangeList()' (end of the 'nsArrangeList()' function)
 
 
/**
* Déplier les données au démmarage.
* Fonction utilisée pour Netscape seulement.
* (Expand databases at startup)
*
* @access public
*/
function nsShowAll()
{
var theLayers = document.layers;
var layersCnt = theLayers.length;
for (i = firstInd; i < layersCnt; i++) {
theLayers[i].visibility = 'show';
}
} // fin de la fonction 'nsShowAll()' (end of the 'nsShowAll()' function)
 
 
/**
* Pliage des données au démarrage.
* (Collapses databases at startup)
*
* @access public
*/
function initIt()
{
if (!capable || !isServer)
return;
if (isDOM) {
var tempColl = document.getElementsByTagName('DIV');
var tempCollCnt = tempColl.length;
for (var i = 0; i < tempCollCnt; i++) {
if (tempColl[i].id == expandedDb)
tempColl[i].style.display = 'block';
else if (tempColl[i].className == 'child')
tempColl[i].style.display = 'none';
}
} // Fin du cas DOM (end of the DOM case)
else if (isIE4) {
tempColl = document.all.tags('DIV');
var tempCollCnt = tempColl.length;
for (var i = 0; i < tempCollCnt; i++) {
if (tempColl(i).id == expandedDb)
tempColl(i).style.display = 'block';
else if (tempColl(i).className == 'child')
tempColl(i).style.display = 'none';
}
} // Fin du cas IE4 (end of the IE4 case)
else if (isNS4) {
var theLayers = document.layers;
var layersCnt = theLayers.length;
for (var i = 0; i < layersCnt; i++) {
if (theLayers[i].id == expandedDb)
theLayers[i].visibility = 'show';
else if (theLayers[i].id.indexOf('Child') != -1)
theLayers[i].visibility = 'hide';
else
theLayers[i].visibility = 'show';
}
nsArrangeList();
} // Fin du cas NS4 (end of the NS4 case)
} // Fin de la fonction 'initIt()' (end of the 'initIt()' function)
 
 
/**
* Plier/Déplier les données quand l'utilisateur le demande.
* (Collapses/expands a database when the user require this to be done)
*
* @param string le nom de l'élément à activer (the name of the room to act on)
* @param boolean si oui ou non le contenu des données doit être affiché (whether to expand or to collapse the database content)
*
* @access public
*/
function expandBase(el, unexpand)
{
if (!capable)
return;
if (isDOM) {
var whichEl = document.getElementById(el + 'Child');
var whichIm = document.getElementById(el + 'Img');
if (whichEl.style.display == 'none' && whichIm) {
whichEl.style.display = 'block';
whichIm.src = imgOpened.src;
}
else if (unexpand) {
whichEl.style.display = 'none';
whichIm.src = imgClosed.src;
}
} // Fin du cas DOM (end of the DOM case)
else if (isIE4) {
var whichEl = document.all(el + 'Child');
var whichIm = document.images.item(el + 'Img');
if (whichEl.style.display == 'none') {
whichEl.style.display = 'block';
whichIm.src = imgOpened.src;
}
else if (unexpand) {
whichEl.style.display = 'none';
whichIm.src = imgClosed.src;
}
} // Fin du cas IE4 (end of the IE4 case)
else if (isNS4) {
var whichEl = document.layers[el + 'Child'];
var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
if (whichEl.visibility == 'hide') {
whichEl.visibility = 'show';
whichIm.src = imgOpened.src;
}
else if (unexpand) {
whichEl.visibility = 'hide';
whichIm.src = imgClosed.src;
}
nsArrangeList();
} // Fin du cas NS4 (end of the NS4 case)
} // fin de la fonction 'expandBase()' (end of the 'expandBase()' function)
 
 
/**
* Ajout des styles permettant le positionnement des calques.
* Le style display est important pour afficher ou masquer les calques.
* Les styles child et parent doivent être utilisé pour les div du fichier html.
* (Add styles for positioned layers)
*/
if (capable) {
with (document) {
// Brian Birtles : This is not the ideal method of doing this
// but under the 7th June '00 Mozilla build (and many before
// it) Mozilla did not treat text between <style> tags as
// style information unless it was written with the one call
// to write().
if (isDOM) {
var lstyle = '<style type="text/css">'
+ 'div {color: #000000;}'
+ '.heada {font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px}'
+ '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration:none; display: block}'
+ '.child {font-family: ' + fontFamily + '; text-decoration:none; display: none}'
+ '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt;}'
+ '.tblItem:hover {color: #FF0000; text-decoration: underline}'
+ '<\/style>';
write(lstyle);
}
else {
write('<style type="text/css">');
write('div {color: #000000; }');
write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
if (isIE4) {
write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
write('.child {font-family: ' + fontFamily + '; text-decoration: none; display: none}');
write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt}');
write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
}
else {
write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
write('.child {font-family: ' + fontFamily + '; position: absolute; visibility: hidden}');
write('.item, .tblItem {color: #333399; text-decoration: none}');
}
write('<\/style>');
}
}
}
else {
with (document) {
write('<style type="text/css">');
write('div {color: #000000; }');
write('.heada {font-family: ' + fontFamily + '; font-size: 10pt ; font-weight:bold}');
write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
write('.child {font-family: ' + fontFamily + '; text-decoration: none}');
write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}');
write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
write('<\/style>');
}
} // Fin de l'ajout des styles (end of adding styles)
 
 
onload = initIt;
 
/**
* Test normalement présent dans le fichier html à la fin entre
* des balises <script></script>
*/
 
if (isNS4) {
firstEl = 'el1Parent';
firstInd = nsGetIndex(firstEl);
nsShowAll();
nsArrangeList();
}
expandedDb = '';
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.1 2005/03/08 14:14:47 jpm
* Ajout du fichier javascript permettant d'ouvrir et fermer du html.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/