Subversion Repositories eFlore/Archives.herbiers

Rev

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

Rev Author Line No. Line
2 jp_milcent 1
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2
// +------------------------------------------------------------------------------------------------------+
3
// | Javascript version 1.5                                                                               |
4
// +------------------------------------------------------------------------------------------------------+
5
// | Copyright (C) Tela Botanica (accueil@tela-botanica.org), 2005.                                       |
6
// +------------------------------------------------------------------------------------------------------+
7
// | This file is part of Herbier.                                                                        |
8
// |                                                                                                      |
9
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | it under the terms of the GNU General Public License as published by                                 |
11
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | (at your option) any later version.                                                                  |
13
// |                                                                                                      |
14
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | GNU General Public License for more details.                                                         |
18
// |                                                                                                      |
19
// | You should have received a copy of the GNU General Public License                                    |
20
// | along with Foobar; if not, write to the Free Software                                                |
21
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// +------------------------------------------------------------------------------------------------------+
23
// CVS : $Id: hb_ouvrir_fermer.js,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
24
/**
25
* Script ouvrir-fermer
26
*
27
* These scripts were originally found on cooltype.com.
28
* Modified 01/01/1999 by Tobias Ratschiller for linuxapps.com
29
* Modified 7th June 2000 by Brian Birtles for Mozilla 5.0
30
* compatibility for phpMyAdmin
31
* Rewritten and put in a libray 2nd May 2001 by Loïc Chapeaux
32
* Traduit en français et utilisé dans Tela-Botanica fin octobre 2000
33
* par Alexandre Granier et Jean-Pascal Milcent.
34
* Test réussi avec : (Test passed with:)
35
* - Mozilla 0.8.1, 0.9.0, 0.9.1, 0.9.2 for Windows (js enabled
36
*    & disabled)
37
* - IE5, 5.01, 5.5 for Windows
38
* - Netscape 4.75 for Windows
39
* Test échoué avec : ((crappy DOM implementations) with:)
40
* - Opera 5.02 for windows: 'getElementsByTagName' is unsupported
41
* - Opera 5.10 to 5.12 for windows, Opera 5+ for Linux: 'style.display' can't
42
*   be changed
43
* - Konqueror 2+: 'style.display' can't be changed
44
*
45
*@package Herbier
46
*@subpackage Javascripts
47
//Auteur original :
48
*@author        cooltype.com
49
//Autres auteurs :
50
*@author        Tobias Ratschiller
51
*@author        Brian Birtles
52
*@author        Loïc Chapeaux
53
*@author        Alexandre Granier
54
*@author        Jean-Pascal Milcent
55
*@copyright     Tela-Botanica 2000-2005
56
*@version       $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
57
// +------------------------------------------------------------------------------------------------------+
58
*/
59
 
60
// inclusion intempestive
61
/**
62
 * Variables et test normalement présent dans le fichier html dans le head entre
63
 * des balises <script></script>
64
 */
65
var isDOM      = (typeof(document.getElementsByTagName) != 'undefined') ? 1 : 0;
66
var isIE4      = ((typeof(document.all) != 'undefined') && (parseInt(navigator.appVersion) >= 4)) ? 1 : 0;
67
var isNS4      = (typeof(document.layers) != 'undefined') ? 1 : 0;
68
var capable    = (isDOM || isIE4 || isNS4) ? 1 : 0;
69
// Uggly fix for Konqueror and Opera that are not fully DOM compliant
70
// Implémentation de la variable 'capable' pour Konqueror et Opera qui
71
// qui ne supporte pas complêtement DOM.
72
if (capable && typeof(navigator.userAgent) != 'undefined') {
73
    var browserName = ' ' + navigator.userAgent.toLowerCase();
74
    if (browserName.indexOf('opera') > 0 || browserName.indexOf('konqueror') > 0) {
75
        capable = 0;
76
    }
77
}
78
var fontFamily = 'arial, geneva, sans-serif';
79
var isServer   = true;
80
var isExpanded   = false;
81
var imgOpened    = new Image(9,9);
82
imgOpened.src    = 'client/herbier/presentations/images/fermer.png';
83
var imgClosed    = new Image(9,9);
84
imgClosed.src    = 'client/herbier/presentations/images/ouvrir.png';
85
 
86
 
87
/**
88
 *Recharge le 'frame' si la fenêtre est redimensionée sous Netscape4+.
89
 *(Do reloads the frame if the window has been resized under Netscape4+)
90
 *
91
 *@access  privée (private)
92
 */
93
function reDo()
94
{
95
    if (innerWidth != origWidth || innerHeight != origHeight)
96
        location.reload(true);
97
} // fin de la fonction 'reDo()' (end of the 'reDo()' function])
98
 
99
 
100
/**
101
 * Positionnement du redimensionnement pour Netscape4+.
102
 * (Positioned element resize bug under NS4+)
103
 *
104
 */
105
if (isNS4) {
106
    var origWidth  = innerWidth;
107
    var origHeight = innerHeight;
108
    onresize       = reDo;
109
}
110
 
111
 
112
/**
113
 * Prend l'id du premier élement de plier-déplier.
114
 * Fonction utilisée pour Netscape seulement.
115
 * (Gets the id of the first collapsible room)
116
 *
117
 * @param  string  le nom de la première pièce du plier-déplier (the name of the first collapsible room)
118
 *
119
 * @return  integer  le numèro d'index correspondant à cette pièce (the index number corresponding to this room)
120
 *
121
 * @access  public
122
 */
123
function nsGetIndex(el)
124
{
125
    var ind = null;
126
    var theLayers = document.layers;
127
    var layersCnt = theLayers.length;
128
    for (var i = 0; i < layersCnt; i++) {
129
        if (theLayers[i].id == el) {
130
            ind = i;
131
            break;
132
        }
133
    }
134
    return ind;
135
} // fin de la fonction 'nsGetIndex()' (end of the 'nsGetIndex()' function)
136
 
137
 
138
/**
139
 * Positions des calques sous Netscape4+.
140
 * (Positions layers under NS4+)
141
 *
142
 * @access  public
143
 */
144
function nsArrangeList()
145
{
146
    if (firstInd != null) {
147
        var theLayers = document.layers;
148
        var layersCnt = theLayers.length;
149
        var nextY     = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
150
        for (var i = firstInd + 1; i < layersCnt; i++) {
151
            if (theLayers[i].visibility != 'hide') {
152
                theLayers[i].pageY = nextY;
153
                nextY              += theLayers[i].document.height;
154
            }
155
        }
156
    }
157
} // fin de la fonction 'nsArrangeList()' (end of the 'nsArrangeList()' function)
158
 
159
 
160
/**
161
 * Déplier les données au démmarage.
162
 * Fonction utilisée pour Netscape seulement.
163
 * (Expand databases at startup)
164
 *
165
 * @access  public
166
 */
167
function nsShowAll()
168
{
169
    var theLayers = document.layers;
170
    var layersCnt = theLayers.length;
171
    for (i = firstInd; i < layersCnt; i++) {
172
        theLayers[i].visibility = 'show';
173
    }
174
} // fin de la fonction 'nsShowAll()' (end of the 'nsShowAll()' function)
175
 
176
 
177
/**
178
 * Pliage des données au démarrage.
179
 * (Collapses databases at startup)
180
 *
181
 * @access  public
182
 */
183
function initIt()
184
{
185
    if (!capable || !isServer)
186
       return;
187
 
188
    if (isDOM) {
189
        var tempColl    = document.getElementsByTagName('DIV');
190
        var tempCollCnt = tempColl.length;
191
        for (var i = 0; i < tempCollCnt; i++) {
192
            if (tempColl[i].id == expandedDb)
193
                tempColl[i].style.display = 'block';
194
            else if (tempColl[i].className == 'child')
195
                tempColl[i].style.display = 'none';
196
        }
197
    } // Fin du cas DOM (end of the DOM case)
198
    else if (isIE4) {
199
        tempColl        = document.all.tags('DIV');
200
        var tempCollCnt = tempColl.length;
201
        for (var i = 0; i < tempCollCnt; i++) {
202
            if (tempColl(i).id == expandedDb)
203
                tempColl(i).style.display = 'block';
204
            else if (tempColl(i).className == 'child')
205
                tempColl(i).style.display = 'none';
206
        }
207
    } // Fin du cas IE4 (end of the IE4 case)
208
    else if (isNS4) {
209
        var theLayers  = document.layers;
210
        var layersCnt  = theLayers.length;
211
        for (var i = 0; i < layersCnt; i++) {
212
            if (theLayers[i].id == expandedDb)
213
                theLayers[i].visibility   = 'show';
214
            else if (theLayers[i].id.indexOf('Child') != -1)
215
                theLayers[i].visibility   = 'hide';
216
            else
217
                theLayers[i].visibility   = 'show';
218
        }
219
        nsArrangeList();
220
    } // Fin du cas NS4 (end of the NS4 case)
221
} // Fin de la fonction 'initIt()' (end of the 'initIt()' function)
222
 
223
 
224
/**
225
 * Plier/Déplier les données quand l'utilisateur le demande.
226
 * (Collapses/expands a database when the user require this to be done)
227
 *
228
 * @param  string  le nom de l'élément à activer (the  name of the room to act on)
229
 * @param  boolean si oui ou non le contenu des données doit être affiché (whether to expand or to collapse the database content)
230
 *
231
 * @access  public
232
 */
233
function expandBase(el, unexpand)
234
{
235
    if (!capable)
236
        return;
237
 
238
    if (isDOM) {
239
        var whichEl = document.getElementById(el + 'Child');
240
        var whichIm = document.getElementById(el + 'Img');
241
        if (whichEl.style.display == 'none' && whichIm) {
242
            whichEl.style.display  = 'block';
243
            whichIm.src            = imgOpened.src;
244
        }
245
        else if (unexpand) {
246
            whichEl.style.display  = 'none';
247
            whichIm.src            = imgClosed.src;
248
        }
249
    } // Fin du cas DOM (end of the DOM case)
250
    else if (isIE4) {
251
        var whichEl = document.all(el + 'Child');
252
        var whichIm = document.images.item(el + 'Img');
253
        if (whichEl.style.display == 'none') {
254
            whichEl.style.display  = 'block';
255
            whichIm.src            = imgOpened.src;
256
        }
257
        else if (unexpand) {
258
            whichEl.style.display  = 'none';
259
            whichIm.src            = imgClosed.src;
260
        }
261
    } // Fin du cas IE4 (end of the IE4 case)
262
    else if (isNS4) {
263
        var whichEl = document.layers[el + 'Child'];
264
        var whichIm = document.layers[el + 'Parent'].document.images['imEx'];
265
        if (whichEl.visibility == 'hide') {
266
            whichEl.visibility  = 'show';
267
            whichIm.src         = imgOpened.src;
268
        }
269
        else if (unexpand) {
270
            whichEl.visibility  = 'hide';
271
            whichIm.src         = imgClosed.src;
272
        }
273
        nsArrangeList();
274
    } // Fin du cas NS4 (end of the NS4 case)
275
} // fin de la fonction 'expandBase()' (end of the 'expandBase()' function)
276
 
277
 
278
/**
279
 * Ajout des styles permettant le positionnement des calques.
280
 * Le style display est important pour afficher ou masquer les calques.
281
 * Les styles child et parent doivent être utilisé pour les div du fichier html.
282
 * (Add styles for positioned layers)
283
 */
284
if (capable) {
285
    with (document) {
286
        // Brian Birtles : This is not the ideal method of doing this
287
        // but under the 7th June '00 Mozilla build (and many before
288
        // it) Mozilla did not treat text between <style> tags as
289
        // style information unless it was written with the one call
290
        // to write().
291
        if (isDOM) {
292
            var lstyle = '<style type="text/css">'
293
                    + 'div {color: #000000;}'
294
                    + '.heada {font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px}'
295
                    + '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration:none; display: block}'
296
                    + '.child {font-family: ' + fontFamily + '; text-decoration:none; display: none}'
297
                    + '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt;}'
298
                    + '.tblItem:hover {color: #FF0000; text-decoration: underline}'
299
                    + '<\/style>';
300
            write(lstyle);
301
        }
302
        else {
303
            write('<style type="text/css">');
304
            write('div {color: #000000; }');
305
            write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
306
            if (isIE4) {
307
                write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
308
                write('.child {font-family: ' + fontFamily + '; text-decoration: none; display: none}');
309
                write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt}');
310
                write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
311
            }
312
            else {
313
                write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
314
                write('.child {font-family: ' + fontFamily + '; position: absolute; visibility: hidden}');
315
                write('.item, .tblItem {color: #333399; text-decoration: none}');
316
            }
317
            write('<\/style>');
318
        }
319
    }
320
}
321
else {
322
    with (document) {
323
        write('<style type="text/css">');
324
        write('div {color: #000000; }');
325
        write('.heada {font-family: ' + fontFamily + '; font-size: 10pt ; font-weight:bold}');
326
        write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
327
        write('.child {font-family: ' + fontFamily + '; text-decoration: none}');
328
        write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}');
329
        write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
330
        write('<\/style>');
331
    }
332
} // Fin de l'ajout des styles (end of adding styles)
333
 
334
 
335
onload = initIt;
336
 
337
/**
338
 * Test normalement présent dans le fichier html à la fin entre
339
 * des balises <script></script>
340
 */
341
 
342
if (isNS4) {
343
    firstEl  = 'el1Parent';
344
    firstInd = nsGetIndex(firstEl);
345
    nsShowAll();
346
    nsArrangeList();
347
}
348
expandedDb = '';
349
 
350
/* +--Fin du code ----------------------------------------------------------------------------------------+
351
*
352
* $Log: not supported by cvs2svn $
353
* Revision 1.1  2005/03/08 14:14:47  jpm
354
* Ajout du fichier javascript permettant d'ouvrir et fermer du html.
355
*
356
*
357
* +-- Fin du code ----------------------------------------------------------------------------------------+
358
*/