Subversion Repositories eFlore/Archives.herbiers

Rev

Rev 2 | Details | Compare with Previous | 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
// +------------------------------------------------------------------------------------------------------+
22 jp_milcent 23
// CVS : $Id: hb_ouvrir_fermer.js,v 1.2 2007-08-27 15:56:50 jp_milcent Exp $
2 jp_milcent 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
22 jp_milcent 56
*@version       $Revision: 1.2 $ $Date: 2007-08-27 15:56:50 $
2 jp_milcent 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
 
22 jp_milcent 86
/**
87
 * Pliage des donn?es au d?marrage.
88
 * (Collapses databases at startup)
89
 *
90
 * @access  public
91
 */
92
function toutPlier()
93
{
94
  if (!capable || !isServer) {
95
    return;
96
  }
97
  if (isDOM) {
98
    var tempColl    = document.getElementsByTagName('div');
99
    var tempCollCnt = tempColl.length;
100
    for (var i = 0; i < tempCollCnt; i++) {
101
      if (tempColl[i].id == expandedDb)
102
        tempColl[i].style.display = 'inline';
103
      else if (tempColl[i].className == 'child')
104
        tempColl[i].style.display = 'none';
105
    }
106
  }
107
}
2 jp_milcent 108
 
109
/**
22 jp_milcent 110
 * D?pliage de toutes les donn?es.
111
 *
112
 * @access  public
113
 */
114
function toutDeplier()
115
{
116
  if (!capable || !isServer) {
117
    return;
118
  }
119
  if (isDOM) {
120
    var tempColl    = document.getElementsByTagName('div');
121
    var tempCollCnt = tempColl.length;
122
    for (var i = 0; i < tempCollCnt; i++) {
123
      if (tempColl[i].id == expandedDb)
124
        tempColl[i].style.display = 'inline';
125
      else if (tempColl[i].className == 'child')
126
        tempColl[i].style.display = 'inline';
127
    }
128
    // Fin du cas DOM (end of the DOM case)
129
  }
130
}
131
 
132
/**
133
 * Affiche une aide sur le Plier/D?plier
134
 *
135
 * @access  public
136
 */
137
function afficherAide()
138
{
139
  with (document) {
140
    if (isDOM) {
141
      var aide = 	'<p>Cliquer sur le symbole <img src="'+imgClosed.src+'"/> pour afficher les <strong>informations complémentaires</strong>.<p />'+
142
					'<p>Vous pouvez aussi utiliser les liens ci-dessous pour controler l\'affichage de l\'ensemble des informations :<p />'+
143
					'<p><a href="#" onclick="toutPlier(); return false;">Tout plier</a> | <a href="#" onclick="toutDeplier(); return false;">Tout d&eacute;plier</a>'+
144
					'</p>';
145
      write(aide);
146
    }
147
  }
148
}
149
 
150
/**
2 jp_milcent 151
 *Recharge le 'frame' si la fenêtre est redimensionée sous Netscape4+.
152
 *(Do reloads the frame if the window has been resized under Netscape4+)
153
 *
154
 *@access  privée (private)
155
 */
156
function reDo()
157
{
158
    if (innerWidth != origWidth || innerHeight != origHeight)
159
        location.reload(true);
160
} // fin de la fonction 'reDo()' (end of the 'reDo()' function])
161
 
162
 
163
/**
164
 * Positionnement du redimensionnement pour Netscape4+.
165
 * (Positioned element resize bug under NS4+)
166
 *
167
 */
168
if (isNS4) {
169
    var origWidth  = innerWidth;
170
    var origHeight = innerHeight;
171
    onresize       = reDo;
172
}
173
 
174
 
175
/**
176
 * Prend l'id du premier élement de plier-déplier.
177
 * Fonction utilisée pour Netscape seulement.
178
 * (Gets the id of the first collapsible room)
179
 *
180
 * @param  string  le nom de la première pièce du plier-déplier (the name of the first collapsible room)
181
 *
182
 * @return  integer  le numèro d'index correspondant à cette pièce (the index number corresponding to this room)
183
 *
184
 * @access  public
185
 */
186
function nsGetIndex(el)
187
{
188
    var ind = null;
189
    var theLayers = document.layers;
190
    var layersCnt = theLayers.length;
191
    for (var i = 0; i < layersCnt; i++) {
192
        if (theLayers[i].id == el) {
193
            ind = i;
194
            break;
195
        }
196
    }
197
    return ind;
198
} // fin de la fonction 'nsGetIndex()' (end of the 'nsGetIndex()' function)
199
 
200
 
201
/**
202
 * Positions des calques sous Netscape4+.
203
 * (Positions layers under NS4+)
204
 *
205
 * @access  public
206
 */
207
function nsArrangeList()
208
{
209
    if (firstInd != null) {
210
        var theLayers = document.layers;
211
        var layersCnt = theLayers.length;
212
        var nextY     = theLayers[firstInd].pageY + theLayers[firstInd].document.height;
213
        for (var i = firstInd + 1; i < layersCnt; i++) {
214
            if (theLayers[i].visibility != 'hide') {
215
                theLayers[i].pageY = nextY;
216
                nextY              += theLayers[i].document.height;
217
            }
218
        }
219
    }
220
} // fin de la fonction 'nsArrangeList()' (end of the 'nsArrangeList()' function)
221
 
222
 
223
/**
224
 * Déplier les données au démmarage.
225
 * Fonction utilisée pour Netscape seulement.
226
 * (Expand databases at startup)
227
 *
228
 * @access  public
229
 */
230
function nsShowAll()
231
{
232
    var theLayers = document.layers;
233
    var layersCnt = theLayers.length;
234
    for (i = firstInd; i < layersCnt; i++) {
235
        theLayers[i].visibility = 'show';
236
    }
237
} // fin de la fonction 'nsShowAll()' (end of the 'nsShowAll()' function)
238
 
239
 
240
/**
241
 * Pliage des données au démarrage.
242
 * (Collapses databases at startup)
243
 *
244
 * @access  public
245
 */
246
function initIt()
247
{
248
    if (!capable || !isServer)
249
       return;
250
 
251
    if (isDOM) {
252
        var tempColl    = document.getElementsByTagName('DIV');
253
        var tempCollCnt = tempColl.length;
254
        for (var i = 0; i < tempCollCnt; i++) {
255
            if (tempColl[i].id == expandedDb)
256
                tempColl[i].style.display = 'block';
257
            else if (tempColl[i].className == 'child')
258
                tempColl[i].style.display = 'none';
259
        }
260
    } // Fin du cas DOM (end of the DOM case)
261
    else if (isIE4) {
262
        tempColl        = document.all.tags('DIV');
263
        var tempCollCnt = tempColl.length;
264
        for (var i = 0; i < tempCollCnt; i++) {
265
            if (tempColl(i).id == expandedDb)
266
                tempColl(i).style.display = 'block';
267
            else if (tempColl(i).className == 'child')
268
                tempColl(i).style.display = 'none';
269
        }
270
    } // Fin du cas IE4 (end of the IE4 case)
271
    else if (isNS4) {
272
        var theLayers  = document.layers;
273
        var layersCnt  = theLayers.length;
274
        for (var i = 0; i < layersCnt; i++) {
275
            if (theLayers[i].id == expandedDb)
276
                theLayers[i].visibility   = 'show';
277
            else if (theLayers[i].id.indexOf('Child') != -1)
278
                theLayers[i].visibility   = 'hide';
279
            else
280
                theLayers[i].visibility   = 'show';
281
        }
282
        nsArrangeList();
283
    } // Fin du cas NS4 (end of the NS4 case)
284
} // Fin de la fonction 'initIt()' (end of the 'initIt()' function)
285
 
286
 
287
/**
288
 * Plier/Déplier les données quand l'utilisateur le demande.
289
 * (Collapses/expands a database when the user require this to be done)
290
 *
291
 * @param  string  le nom de l'élément à activer (the  name of the room to act on)
292
 * @param  boolean si oui ou non le contenu des données doit être affiché (whether to expand or to collapse the database content)
293
 *
294
 * @access  public
295
 */
296
function expandBase(el, unexpand)
297
{
22 jp_milcent 298
  if (!capable)
299
    return;
300
 
301
  if (isDOM) {
302
    var whichEl = document.getElementById(el + 'Child');
303
    var whichIm = document.getElementById(el + 'Img');
304
    if (whichEl.style.display == 'none' && whichIm) {
305
      whichEl.style.display  = 'inline';
306
      whichIm.src            = imgOpened.src;
307
      whichIm.alt            = imgOpened.alt;
308
      whichIm.title          = imgOpened.title;
309
    } else if (unexpand) {
310
      whichEl.style.display  = 'none';
311
      whichIm.src            = imgClosed.src;
312
      whichIm.alt            = imgClosed.alt;
313
      whichIm.title          = imgClosed.title;
2 jp_milcent 314
 
22 jp_milcent 315
    }
316
  }
317
}
2 jp_milcent 318
 
319
/**
320
 * Ajout des styles permettant le positionnement des calques.
321
 * Le style display est important pour afficher ou masquer les calques.
322
 * Les styles child et parent doivent être utilisé pour les div du fichier html.
323
 * (Add styles for positioned layers)
324
 */
325
if (capable) {
326
    with (document) {
327
        // Brian Birtles : This is not the ideal method of doing this
328
        // but under the 7th June '00 Mozilla build (and many before
329
        // it) Mozilla did not treat text between <style> tags as
330
        // style information unless it was written with the one call
331
        // to write().
332
        if (isDOM) {
333
            var lstyle = '<style type="text/css">'
334
                    + 'div {color: #000000;}'
335
                    + '.heada {font-family: Arial, Helvetica, Verdana, sans-serif; font-size: 12px}'
336
                    + '.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration:none; display: block}'
337
                    + '.child {font-family: ' + fontFamily + '; text-decoration:none; display: none}'
338
                    + '.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt;}'
339
                    + '.tblItem:hover {color: #FF0000; text-decoration: underline}'
340
                    + '<\/style>';
341
            write(lstyle);
342
        }
343
        else {
344
            write('<style type="text/css">');
345
            write('div {color: #000000; }');
346
            write('.heada {font-family: ' + fontFamily + '; font-size: 10pt}');
347
            if (isIE4) {
348
                write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; display: block}');
349
                write('.child {font-family: ' + fontFamily + '; text-decoration: none; display: none}');
350
                write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none; font-size: 8pt}');
351
                write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
352
            }
353
            else {
354
                write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none; position: absolute; visibility: hidden}');
355
                write('.child {font-family: ' + fontFamily + '; position: absolute; visibility: hidden}');
356
                write('.item, .tblItem {color: #333399; text-decoration: none}');
357
            }
358
            write('<\/style>');
359
        }
360
    }
361
}
362
else {
363
    with (document) {
364
        write('<style type="text/css">');
365
        write('div {color: #000000; }');
366
        write('.heada {font-family: ' + fontFamily + '; font-size: 10pt ; font-weight:bold}');
367
        write('.parent {font-family: ' + fontFamily + '; color: #000000; text-decoration: none}');
368
        write('.child {font-family: ' + fontFamily + '; text-decoration: none}');
369
        write('.item, .item:active, .item:hover, .tblItem, .tblItem:active {color: #333399; text-decoration: none}');
370
        write('.tblItem:hover {color: #FF0000; text-decoration: underline}');
371
        write('<\/style>');
372
    }
373
} // Fin de l'ajout des styles (end of adding styles)
374
 
375
 
376
onload = initIt;
377
 
378
/**
379
 * Test normalement présent dans le fichier html à la fin entre
380
 * des balises <script></script>
381
 */
382
 
383
if (isNS4) {
384
    firstEl  = 'el1Parent';
385
    firstInd = nsGetIndex(firstEl);
386
    nsShowAll();
387
    nsArrangeList();
388
}
389
expandedDb = '';
390
 
391
/* +--Fin du code ----------------------------------------------------------------------------------------+
392
*
393
* $Log: not supported by cvs2svn $
22 jp_milcent 394
* Revision 1.1  2005-11-23 10:32:32  jp_milcent
395
* Ajout au dépot de l'application Herbiers.
396
* Elle doit à terme migrer dans eFlore.
397
*
2 jp_milcent 398
* Revision 1.1  2005/03/08 14:14:47  jpm
399
* Ajout du fichier javascript permettant d'ouvrir et fermer du html.
400
*
401
*
402
* +-- Fin du code ----------------------------------------------------------------------------------------+
403
*/