IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

Menu dynamique style xp


Sujet :

JavaScript

  1. #1
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut Menu dynamique style xp
    Bonjour,
    J'utilise ce très bon script pour mon menu, mais j'aimerai que quand je clique sur un nouvel onglet il me referme l'onglet précédent (ou par défaut tous les onglets). Voici le code;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
     
    // -= Variables globales =-
    //==========================
    var Interval = 50;
    var SumInt = 0;
    var imgOButton = "Images/OButton.jpg";
    var imgFButton = "Images/FButton.jpg";
     
    var PosXStart = 0;
    var PosYStart = 0;
    var intSepar = 20;
    var bFader = false;
     
    var strFader = "filter: alpha(opacity=0);";
     
    var arrListMenu = new Array();
     
     
    // -= Fonctions =-
    //=================
    function DoNothing() {}
     
    function StartMenu(){
    	for( var i = 0; i < arrListMenu.length; i++ )  fctWrite(i);			
    }
     
    function InitMenu( StartX, StartY, Separ, Fader ){
    	PosXStart = StartX;
    	PosYStart = StartY;
    	intSepar = Separ;
    	bFader = Fader;
    }
     
    function getObject( id ){
    	for( var Cpt = 0; Cpt < arrListMenu.length; Cpt++ ){
    	 	if( id == arrListMenu[Cpt].Name ) return arrListMenu[Cpt];
    		for( var Cpt2 = 0; Cpt2 < arrListMenu[Cpt].Option.length; Cpt2++ ){
    	 		if( id == arrListMenu[Cpt].Option[Cpt2].Name ) return arrListMenu[Cpt].Option[Cpt2];
    		}
    	}
    }
     
    function fctMove( strObj, intTo, intVitesse ){
    	// But:		Bouger le menu de sa position 'Y' actuelle vers la position 'Y' "intTo".
    	// Event:	/
    	// Param.:	- Index = Numéro du menu. 
    	//			- intTo = Position 'Y' finale du menu ou de l'option.
    	//			- intVitesse = Vitesse de mouvement.
     
    	var Obj = getObject( strObj );
     
    	if( parseInt(intTo) != Obj.PosY ){
    		if( parseInt(intTo) < Obj.PosY ){
    			Obj.PosY -= 5 * intVitesse;
    			if( Obj.PosY <= parseInt(intTo) ) Obj.PosY = parseInt(intTo);
    		}
    		else {
    			Obj.PosY += 5 * intVitesse;
    			if( Obj.PosY >= parseInt(intTo) ) Obj.PosY = parseInt(intTo);
    		}
    		document.getElementById( Obj.Name ).style.top = Obj.PosY;
    		setTimeout("fctMove('" + Obj.Name + "', " + intTo + ", " + intVitesse + ")", Interval);
    	}
    }
     
    function fctAnim( Index ){
    	// But:		Animation du menu
    	// Event:	Qd on clique sur l'en-tête du menu.
    	// Param.:	- Index = Numéro du menu.
     
    	var Menu = arrListMenu[Index];
     
    	var To = 0;
    	var intCpt = 0;
     
    	if( !Menu.isShowed ){
    		document.getElementById( Menu.ImageName ).src = "Images/FButton.jpg";
    		if( bFader ) fctSetOpacity(Index, "+");
    		else document.getElementById( Menu.OptionName ).style.display = "";
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
    			fctMove(Menu.Option[intCpt].Name, 0, intCpt);
    			To += 20;
    		}
    		for( intCpt = Menu.Index + 1; intCpt < arrListMenu.length; intCpt++ ){
    			fctMove(arrListMenu[intCpt].Name, To + arrListMenu[intCpt].PosY, Menu.Option.length + 1 );
    		}
    		Menu.isShowed = true;
    	}
    	else {
    		document.getElementById( Menu.ImageName ).src = "Images/OButton.jpg";
    		if( bFader ) fctSetOpacity(Index, "-");
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
    			fctMove(Menu.Option[intCpt].Name,-30*(intCpt), intCpt + 1);
    			To += 20;
    			SumInt += Interval/2;
    		}
    		for( intCpt = Index + 1; intCpt < arrListMenu.length; intCpt++ ){
    			fctMove(arrListMenu[intCpt].Name, arrListMenu[intCpt].PosY - To, Menu.Option.length + 1 );
    			SumInt += Interval/2;
    		}
    		Menu.isShowed = false;
    		if( !bFader ) setTimeout("document.getElementById('" + Menu.OptionName + "').style.display = 'none'", SumInt);
    		SumInt = 0;
    	}
    }
     
    function fctSetOpacity( Index, strOp ){
    	// But:		Initialisé l'opacité du menu.
    	// Event:	/
    	// Param.:	- Index = Numéro du menu.
    	//			- strOp = Opération à effectuer sur l'opcaté du menu
     
    	var Menu = arrListMenu[Index];
     
    	if( Menu.Opac <= 101 && Menu.Opac >= -1 ){
    		if( strOp == "+" ){
    			Menu.Opac = Menu.Opac + 20;	
    		}
    		else {
    			Menu.Opac = Menu.Opac - 20;
    		}
    		for( var i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name).filters.alpha.opacity = Menu.Opac;
    		document.getElementById( Menu.OptionName).style.display = "";
    		setTimeout("fctSetOpacity(" + Index + ", '" + strOp + "')", Interval);
    	}
    	else {
    		if( strOp == "+" ){
    			Menu.Opac = 100;	
    		}
    		else {
    			Menu.Opac = 0;
    			document.getElementById( Menu.OptionName).style.display = "none";
    		}
    		for( var i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name ).filters.alpha.opacity = Menu.Opac;
    	}
    }
     
    function fctWrite( Index ){
    	// But:		Ecriture du menu dans le browser.
    	// Event:	/
    	var strRBorder = "solid";
    	var strLBorder = "solid";
    	var strBBorder = "none";
    	var strReturn = "";
     
    	var Menu = arrListMenu[Index];
     
    strReturn += "<table border='0' width = '204' summary='' cellpadding = '0' cellspacing = '0' style='Position:absolute;top:" + Menu.PosY + ";left:" + Menu.PosX + ";' id = '" + Menu.Name + "'>"
    strReturn += "<tr style='z-index:1'><td><table border='0' summary='' cellpadding = '0' cellspacing = '0' style=''><tr onClick = \"fctAnim(" + Index + ")\" style='cursor:hand;'>";
    strReturn += "<td height = '25' width = '16'><img src='Images/LBorder.jpg' border='0' width='16' height='25' alt=''></td>";
    //strReturn += "<td><img src='" + Menu.Image + "' border='0' width='52' height='52' align='right'></td>";
    strReturn += "<td height = '25' width = '161' background='Images/bgHeader.jpg' style='color: #3399FF;font: bold  Tahoma;'>" + Menu.Caption + "</td>";
    strReturn += "<td><img id='" + Menu.ImageName + "' src='Images/OButton.jpg' border='0' width='22' height='25' alt=''></td>";
    strReturn += "<td height = '25' width = '5'><img src='Images/RBorder.jpg' border='0' width='5' height='25' alt=''></td>";
    strReturn += "</tr></table></td></tr><tr style=''><td>";
    strReturn += "<table border='0' width='100%' cellpadding='0' cellspacing='0'  id='" + Menu.OptionName + "' style=';z-index:0;display: none'>";
     
    for( var intCpt = 0; intCpt < Menu.Option.length; intCpt++ ){
    	if( Menu.Option.length-1 == intCpt ){
    		strBBorder = "solid";
    	}
    	strReturn += "<tr id='" + Menu.Option[intCpt].Name + "' style='position: relative; top:" + Menu.Option[intCpt].PosY + "; left:" + Menu.Option[intCpt].PosX + ";z-index: 0;" + ((bFader)? strFader : "")  + "'>";
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none none " + strBBorder + " " + strLBorder + "; border-color: #E6F6F2; border-width: 1; color: #E6F6F2; background: #D6DFF7;'>&nbsp;</td>";
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none none " + strBBorder + " none; border-color: #E6F6F2; border-width: 1; color: #E6F6F2; background: #D6DFF7;'><img src='" + Menu.Option[intCpt].Image + "' border='0' width='16' height='16' align='left'></td>";
    	strReturn += "<td height = '15' style = 'border-style: none none " + strBBorder + " none; border-color: #E6F6F2; border-width: 1; color: #E6F6F2; background: #D6DFF7;'><a href = '" + Menu.Option[intCpt].Links + Menu.Option[intCpt].Param + "' Target = '" + Menu.Option[intCpt].Target + "' style='color:#E6F6F2'>&nbsp;" + Menu.Option[intCpt].Caption + "&nbsp;</a></td>";
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none " + strRBorder + " " + strBBorder + " none; border-color: #E6F6F2; border-width: 1; color: #E6F6F2; background: #D6DFF7;'>&nbsp;</td>";
    }
    strReturn += "</tr></Table></td></tr></table>";
    document.write( strReturn );
    }
     
    function fctCreateOption( strName, strTitre, strHref, strParam, strTarget, strImage){
    	this.Option[this.Option.length] = new OptionObject(strName, strTitre, strHref, strParam, strTarget, strImage, 0, -30*(this.Option.length));
    }
     
     
    // -= Objet "Menu" =-
    //====================
    function MenuObject( strMenuName, strImage, strImageName, strTitre, intPosX, intPosY ){
    	this.Name = strMenuName;
    	this.Image = strImage;
    	this.ImageName = strImageName;
    	this.Caption = "<font face=Tahoma color=#215DC6><b><span style='font-size: 8pt'>" + strTitre + "</span></b></font>";
    	this.PosX = PosXStart;
    	this.PosY = PosYStart + arrListMenu.length * (35 + intSepar);
    	this.OptionName = strMenuName + "Option";
    	this.isShowed = false;
     
    	this.Opac = 0;
    	this.Index = arrListMenu.length;
    	arrListMenu[arrListMenu.length] = this;
    	this.Option = new Array();
     
    	this.CreateOption = fctCreateOption;
    }
     
     
    // -= Objet "Option " =-
    //======================
    function OptionObject( strName, strTitre, strHref, strParam, strTarget, strImage, intPosX, intPosY){
    	this.PosX = intPosX;
    	this.PosY = intPosY;
    	this.Name = strName;
    	this.Image = strImage;
    	this.Caption = "<font face=tahoma color=#215DC6><span style='font-size: 8pt'>" + strTitre + "</span></font>";
    	this.Param = strParam;
    	this.Target = strTarget;
    	this.Links = strHref;
    }
    Je ne suis pas assez calé pour modifier le code, mais je pense que c'est la fonction "function fctAnim" dans la partie 'if menu is not showed'..

    Si quelqu'un pouvait me donner un coup de main..

    merci

  2. #2
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    if( !bFader ) setTimeout("document.getElementById('" + Menu.OptionName + "').style.display = 'none'", SumInt);
    A méditer dessus

  3. #3
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    Merci pour ton aide matthieu, mais je tourne en rond,
    j'ai trouvé sur le net une autre version de ce script et cette ligne ressemble à ça;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    if( !bFader )	setTimeout("document.all." + Menu.OptionName + ".style.display = 'none'", SumInt);
    Mais après avoir testé, ça ne m'avance pas..

  4. #4
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    pour tous les fermer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    for( i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name ).style.display = 'none';

  5. #5
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    arg, j'arrive pas à placer ta ligne au bon endroit
    partout où je la place je clique une première fois sur l'onglet le sous-menu apparaît, je reclique il se referme, je reclique ça se réouvre mais plus aucun sous-menu, et pas d'intéraction avec un autre onglet (ce que je cherche)

  6. #6
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    il ne faudrait pas que j'intègre une fonction Move pour tout refermer avant que d'ouvrir l'onglet désiré?
    (désolé, je cherche je cherche )

  7. #7
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    A priori, tu devrais avoir des menu et sous menu.
    Les menu sont dans la table
    arrListMenu

    function fctAnim( Index ){
    a pour paramètre l'indice de ton menu.

    Si c'est ces menus que tu parles (onglet),

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    for( i = 0; i < arrListMenu.length; i++ )  {
       fctSetOpacity(i, "-");
    }
    ou
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    function closeAllMenu(  ){
    for( i = 0; i < arrListMenu.length; i++ )  {
    if(arrListMenu[i].isShowed){
     fctAnim( i );
     }
     
    }

    si c'est les sous menus, c'est l'autre code

  8. #8
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    Merci pour ton aide mat.
    Pour l'instant voici mon code qui ne marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
     
    // -= Variables globales =-
     
    //==========================
     
    var Interval = 50;
     
    var SumInt = 0;
     
    var imgOButton = "menu/Images/OButton.gif";
     
    var imgFButton = "menu/Images/FButton.gif";
     
     
     
    var PosXStart = 0;
     
    var PosYStart = 0;
     
    var intSepar = 20;
     
    var bFader = false;
     
     
     
    var strFader = "filter: alpha(opacity=0);";
     
     
     
    var arrListMenu = new Array();
     
     
     
     
     
    // -= Fonctions =-
     
    //=================
     
    function DoNothing() {}
     
     
     
    function StartMenu(){ 
       for( var i = 0; i < arrListMenu.length; i++ )  fctWrite(i); 
     
    }
     
     
     
    function InitMenu( StartX, StartY, Separ, Fader ){
     
    	PosXStart = StartX;
     
    	PosYStart = StartY;
     
    	intSepar = Separ;
     
    	bFader = Fader;
     
    }
     
     
     
    function getObject( id ){
     
    	for( var Cpt = 0; Cpt < arrListMenu.length; Cpt++ ){
     
    	 	if( id == arrListMenu[Cpt].Name ) return arrListMenu[Cpt];
     
    		for( var Cpt2 = 0; Cpt2 < arrListMenu[Cpt].Option.length; Cpt2++ ){
     
    	 		if( id == arrListMenu[Cpt].Option[Cpt2].Name ) return arrListMenu[Cpt].Option[Cpt2];
     
    		}
     
    	}
     
    }
     
     
     
    function fctMove( strObj, intTo, intVitesse ){
     
    	// But:		Bouger le menu de sa position 'Y' actuelle vers la position 'Y' "intTo".
     
    	// Event:	/
     
    	// Param.:	- Index = Numéro du menu. 
     
    	//			- intTo = Position 'Y' finale du menu ou de l'option.
     
    	//			- intVitesse = Vitesse de mouvement.
     
     
     
    	var Obj = getObject( strObj );
     
     
     
    	if( parseInt(intTo) != Obj.PosY ){
     
    		if( parseInt(intTo) < Obj.PosY ){
     
    			Obj.PosY -= 5 * intVitesse;
     
    			if( Obj.PosY <= parseInt(intTo) ) Obj.PosY = parseInt(intTo);
     
    		}
     
    		else {
     
    			Obj.PosY += 5 * intVitesse;
     
    			if( Obj.PosY >= parseInt(intTo) ) Obj.PosY = parseInt(intTo);
     
    		}
     
    		document.getElementById( Obj.Name ).style.top = Obj.PosY;
     
    		setTimeout("fctMove('" + Obj.Name + "', " + intTo + ", " + intVitesse + ")", Interval);
     
    	}
     
    }
     
     
     
    function fctAnim( Index ){
     
    	// But:		Animation du menu
     
    	// Event:	Qd on clique sur l'en-tête du menu.
     
    	// Param.:	- Index = Numéro du menu.
     
     
     
    	var Menu = arrListMenu[Index];
     
     
     
    	var To = 0;
     
    	var intCpt = 0;
     
     
     
    	if( !Menu.isShowed ){
     
    		document.getElementById( Menu.ImageName ).src = "menu/Images/FButton.gif";
     
    		if( bFader ) fctSetOpacity(Index, "+");
     
    		else document.getElementById( Menu.OptionName ).style.display = "";
     
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
     
    			fctMove(Menu.Option[intCpt].Name, 0, intCpt);
     
    			To += 20;
     
    		}
     
    		for( intCpt = Menu.Index + 1; intCpt < arrListMenu.length; intCpt++ ){
     
    			fctMove(arrListMenu[intCpt].Name, To + arrListMenu[intCpt].PosY, Menu.Option.length + 1 );
     
    		}
     
    		Menu.isShowed = true;
     
    	}
     
    	else {
     
    		document.getElementById( Menu.ImageName ).src = "menu/Images/OButton.gif";
     
    		if( bFader ) fctSetOpacity(Index, "-");
     
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
     
    			fctMove(Menu.Option[intCpt].Name,-30*(intCpt), intCpt + 1);
     
    			To += 20;
     
    			SumInt += Interval/2;
     
    		}
     
    		for( intCpt = Index + 1; intCpt < arrListMenu.length; intCpt++ ){
     
    			fctMove(arrListMenu[intCpt].Name, arrListMenu[intCpt].PosY - To, Menu.Option.length + 1 );
     
    			SumInt += Interval/2;
     
    		}
     
    		Menu.isShowed = false;
     
    		if( !bFader ) setTimeout("document.getElementById('" + Menu.OptionName + "').style.display = 'none'", SumInt);
                closeAllMenu(  )
    		SumInt = 0;
     
    	}
     
    }
     
    function closeAllMenu(  ){
    for( i = 0; i < arrListMenu.length; i++ )  {
    if(arrListMenu[i].isShowed){
     fctAnim( i );
     }
     
    }}
     
    function fctSetOpacity( Index, strOp ){
     
    	// But:		Initialisé l'opacité du menu.
     
    	// Event:	/
     
    	// Param.:	- Index = Numéro du menu.
     
    	//			- strOp = Opération à effectuer sur l'opcaté du menu
     
     
     
    	var Menu = arrListMenu[Index];
     
     
     
    	if( Menu.Opac <= 101 && Menu.Opac >= -1 ){
     
    		if( strOp == "+" ){
     
    			Menu.Opac = Menu.Opac + 20;	
     
    		}
     
    		else {
     
    			Menu.Opac = Menu.Opac - 20;
     
    		}
     
    		for( var i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name).filters.alpha.opacity = Menu.Opac;
     
    		document.getElementById( Menu.OptionName).style.display = "";
     
    		setTimeout("fctSetOpacity(" + Index + ", '" + strOp + "')", Interval);
     
    	}
     
    	else {
     
    		if( strOp == "+" ){
     
    			Menu.Opac = 100;	
     
    		}
     
    		else {
     
    			Menu.Opac = 0;
     
    			document.getElementById( Menu.OptionName).style.display = "none";
     
    		}
     
    		for( var i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name ).filters.alpha.opacity = Menu.Opac;
     
    	}
     
    }
     
     
     
    function fctWrite( Index ){
     
    	// But:		Ecriture du menu dans le browser.
     
    	// Event:	/
     
    	var strRBorder = "solid";
     
    	var strLBorder = "solid";
     
    	var strBBorder = "none";
     
    	var strReturn = "";
     
     
     
    	var Menu = arrListMenu[Index];
     
     
     
    strReturn += "<table border='0' width = '233' summary='' cellpadding = '0' cellspacing = '0' style='Position:absolute;top:" + Menu.PosY + ";left:" + Menu.PosX + ";' id = '" + Menu.Name + "'>"
     
    strReturn += "<tr style='z-index:1'><td><table border='0' summary='' cellpadding = '0' cellspacing = '0' style=''><tr onClick = \"fctAnim(" + Index + ")\" style='cursor:hand;'>";
     
    strReturn += "<td height = '25' width = '10'><img src='menu/Images/LBorder.gif' border='0' width='10' height='25' alt=''></td>";
     
    strReturn += "<td background='menu/Images/0.gif'><img src='"+Menu.Image+"' border='0' width='20' height='25' ></td>";
     
    strReturn += "<td height = '25' width = '3'><img src='menu/Images/0.gif' border='0' width='3' height='25' alt=''></td>";
     
    strReturn += "<td height = '25' width = '190' background='menu/Images/bgHeader.gif' style='color: #3399FF;font:  italic Tahoma;'>" + Menu.Caption + "</td>";
     
    strReturn += "<td><img id='" + Menu.ImageName + "' src='menu/Images/OButton.gif' border='0' width='22' height='25' alt=''></td>";
     
    strReturn += "<td height = '25' width = '5'><img src='menu/Images/RBorder.gif' border='0' width='5' height='25' alt=''></td>";
     
    strReturn += "</tr></table></td></tr><tr style=''><td>";
     
    strReturn += "<table border='0' width='100%' cellpadding='0' cellspacing='0'  id='" + Menu.OptionName + "' style=';z-index:0;display: none'>";
     
     
     
    for( var intCpt = 0; intCpt < Menu.Option.length; intCpt++ ){
     
    	if( Menu.Option.length-1 == intCpt ){
     
    		strBBorder = "solid";
     
    	}
     
    	strReturn += "<tr id='" + Menu.Option[intCpt].Name + "' style='position: relative; top:" + Menu.Option[intCpt].PosY + "; left:" + Menu.Option[intCpt].PosX + ";z-index: 0;" + ((bFader)? strFader : "")  + "'>";
     
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none none " + strBBorder + " " + strLBorder + "; border-color: #E6F6F2; border-width: 0; color: #E6F6F2;'>&nbsp;</td>";
     
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none none " + strBBorder + " none; border-color: #E6F6F2; border-width: 0; color: #E6F6F2;'><img src='" + Menu.Option[intCpt].Image + "' border='0' width='20' height='20' align='left'></td>";
     
    	strReturn += "<td height = '15' style = 'border-style: none none " + strBBorder + " none; border-color: #E6F6F2; border-width: 0; color: #E6F6F2; background-image: url(menu/Images/bgHeader.gif);'><a href = '" + Menu.Option[intCpt].Links + Menu.Option[intCpt].Param + "' Target = '" + Menu.Option[intCpt].Target + "' style='color:#E6F6F2'>" + Menu.Option[intCpt].Caption + "</a></td>";
     
    	strReturn += "<td height = '15' width = '1%' style = 'border-style: none " + strRBorder + " " + strBBorder + " none; border-color: #E6F6F2; border-width: 0; color: #E6F6F2; background-image: url(menu/Images/RBorder.gif);'>&nbsp;</td>";
     
    }
     
    strReturn += "</tr></Table></td></tr></table>";
     
    document.write( strReturn );
     
    }
     
     
     
    function fctCreateOption( strName, strTitre, strHref, strParam, strTarget, strImage){
     
    	this.Option[this.Option.length] = new OptionObject(strName, strTitre, strHref, strParam, strTarget, strImage, 0, -30*(this.Option.length));
     
    }
     
     
     
     
     
    // -= Objet "Menu" =-
     
    //====================
     
    function MenuObject( strMenuName, strImage, strImageName, strTitre, intPosX, intPosY ){
     
    	this.Name = strMenuName;
     
    	this.Image = strImage;
     
    	this.ImageName = strImageName;
     
    	this.Caption = "<font face=Tahoma color=#FFFFFF><span style='font-size: 11pt'>" + strTitre + "</span></font>";
     
    	this.PosX = PosXStart;
     
    	this.PosY = PosYStart + arrListMenu.length * (40 + intSepar);
     
    	this.OptionName = strMenuName + "Option";
     
    	this.isShowed = false;
     
     
     
    	this.Opac = 0;
     
    	this.Index = arrListMenu.length;
     
    	arrListMenu[arrListMenu.length] = this;
     
    	this.Option = new Array();
     
     
     
    	this.CreateOption = fctCreateOption;
     
    }
     
     
     
     
     
    // -= Objet "Option " =-
     
    //======================
     
    function OptionObject( strName, strTitre, strHref, strParam, strTarget, strImage, intPosX, intPosY){
     
    	this.PosX = intPosX;
     
    	this.PosY = intPosY;
     
    	this.Name = strName;
     
    	this.Image = strImage;
     
    	this.Caption = "<font face=Tahoma color=#FFFFFF><span style='font-size: 9pt'>" + strTitre + "</span></font>";
     
    	this.Param = strParam;
     
    	this.Target = strTarget;
     
    	this.Links = strHref;
     
    }
    En fait le type de menu que j'essaye de faire avec de script est un menu type accordéon, du style; http://www.dynamicdrive.com/dynamici...enu-bullet.htm

    J'ai déjà esseyé ce script mais il me provoque des erreures sous ie avec d'autres javascript de mon site, c'est pourquoi j'aimerai adapter celui que j'ai déjà. (t'avais raison; mes onglets sont les menus et c'est le sous-menu du précédent menu affiché que j'aimerai cacher avant d'afficher le nouveau

  9. #9
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    function fctAnim( Index ){
    closeAllMenu( );
    ....

  10. #10
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    Je te mets juste la partie du code intéressée;
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
     
    function fctAnim( Index ){
                 closeAllMenu(  )
    	// But:		Animation du menu
     
    	// Event:	Qd on clique sur l'en-tête du menu.
     
    	// Param.:	- Index = Numéro du menu.
     
     
     
    	var Menu = arrListMenu[Index];
     
     
     
    	var To = 0;
     
    	var intCpt = 0;
     
     
     
    	if( !Menu.isShowed ){
     
    		document.getElementById( Menu.ImageName ).src = "menu/Images/FButton.gif";
     
    		if( bFader ) fctSetOpacity(Index, "+");
     
    		else document.getElementById( Menu.OptionName ).style.display = "";
     
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
     
    			fctMove(Menu.Option[intCpt].Name, 0, intCpt);
     
    			To += 20;
     
    		}
     
    		for( intCpt = Menu.Index + 1; intCpt < arrListMenu.length; intCpt++ ){
     
    			fctMove(arrListMenu[intCpt].Name, To + arrListMenu[intCpt].PosY, Menu.Option.length + 1 );
     
    		}
     
    		Menu.isShowed = true;
     
    	}
     
    	else {
     
    		document.getElementById( Menu.ImageName ).src = "menu/Images/OButton.gif";
     
    		if( bFader ) fctSetOpacity(Index, "-");
     
    		for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
     
    			fctMove(Menu.Option[intCpt].Name,-30*(intCpt), intCpt + 1);
     
    			To += 20;
     
    			SumInt += Interval/2;
     
    		}
     
    		for( intCpt = Index + 1; intCpt < arrListMenu.length; intCpt++ ){
     
    			fctMove(arrListMenu[intCpt].Name, arrListMenu[intCpt].PosY - To, Menu.Option.length + 1 );
     
    			SumInt += Interval/2;
     
    		}
     
    		Menu.isShowed = false;
     
    		if( !bFader ) setTimeout("document.getElementById('" + Menu.OptionName + "').style.display = 'none'", SumInt);
     
    		SumInt = 0;
     
    	}
     
    }
     
    function closeAllMenu(  ){
    for( i = 0; i < arrListMenu.length; i++ )  {
    if(arrListMenu[i].isShowed){
     fctAnim( i );
     }
     
    }}
    Avec ça je clique une première fois sur le menu, le sous-menu se déroule, et quand je clique sur un autre menu, j'ai cette erreure; Stack overflow at line 213 (la ligne juste après fctAnim( i ); dans function closeAllMenu( )

    J'ai aussi testé ça comme function closeAllMenu( )
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    function closeAllMenu(  ){
    for( i = 0; i < Menu.Option.length; i++ ) document.getElementById( Menu.Option[i].Name ).style.display = 'none';
    }
    et là le menu n'est plus du tout réactif

  11. #11
    Membre émérite
    Inscrit en
    Septembre 2002
    Messages
    2 307
    Détails du profil
    Informations forums :
    Inscription : Septembre 2002
    Messages : 2 307
    Points : 2 814
    Points
    2 814
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    function fctAnim( Index ){
     
    	// But:		Animation du menu
    	// Event:	Qd on clique sur l'en-tête du menu.
    	// Param.:	- Index = Numéro du menu.
     
     
     
    	var To = 0;
    	var intCpt = 0;
     
    	for(k=0;k<arrListMenu.length;k++){	
    		if(k!=Index){		
    		var Menu = arrListMenu[k];
    			if( Menu.isShowed ){
    				document.getElementById( Menu.ImageName ).src = "Images/OButton.jpg";				
    				for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
    					fctMove(Menu.Option[intCpt].Name,-30*(intCpt), intCpt + 1);
     
    					To += 20;					
    				}
    				for( intCpt = k + 1; intCpt < arrListMenu.length; intCpt++ ){					
    					document.getElementById( arrListMenu[intCpt].Name ).style.top = arrListMenu[intCpt].PosY - To;	
    					arrListMenu[intCpt].PosY=arrListMenu[intCpt].PosY - To;					
    				}
    				document.getElementById( Menu.OptionName ).style.display = 'none';
    				Menu.isShowed = false;
    			}
     
    		}
    	}
    	 To = 0;
    	 intCpt = 0;
     
    	var Menu = arrListMenu[Index];
    	if( !Menu.isShowed ){
    				document.getElementById( Menu.ImageName ).src = "Images/FButton.jpg";
    				if( bFader ) fctSetOpacity(Index, "+");
    				else document.getElementById( Menu.OptionName ).style.display = "";
    				for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
    					fctMove(Menu.Option[intCpt].Name, 0, intCpt);
    					To += 20;
    				}
    				for( intCpt = Menu.Index + 1; intCpt < arrListMenu.length; intCpt++ ){
    					fctMove(arrListMenu[intCpt].Name, To + arrListMenu[intCpt].PosY, Menu.Option.length + 1 );
    				}
    				Menu.isShowed = true;
    			}
    			else {
    				document.getElementById( Menu.ImageName ).src = "Images/OButton.jpg";
    				if( bFader ) fctSetOpacity(Index, "-");
    				for( intCpt = 0; intCpt < Menu.Option.length; intCpt++){
    					fctMove(Menu.Option[intCpt].Name,-30*(intCpt), intCpt + 1);
    					To += 20;
    					SumInt += Interval/2;
    				}
    				for( intCpt = Index + 1; intCpt < arrListMenu.length; intCpt++ ){
    					fctMove(arrListMenu[intCpt].Name, arrListMenu[intCpt].PosY - To, Menu.Option.length + 1 );
    					SumInt += Interval/2;
    				}
    				Menu.isShowed = false;
    				if( !bFader ) setTimeout("document.getElementById('" + Menu.OptionName + "').style.display = 'none'", SumInt);
    				SumInt = 0;
    			}
     
     
    }

  12. #12
    Membre à l'essai
    Inscrit en
    Février 2005
    Messages
    23
    Détails du profil
    Informations forums :
    Inscription : Février 2005
    Messages : 23
    Points : 11
    Points
    11
    Par défaut
    Tout simplement parfait, un grand merci matthieu !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Free Pascal] Intégrer des valeurs dans un menu dynamique
    Par boullery dans le forum Free Pascal
    Réponses: 16
    Dernier message: 30/03/2005, 17h04
  2. Créer un sous-menu dynamiquement
    Par PurL dans le forum C++Builder
    Réponses: 4
    Dernier message: 09/09/2004, 10h31
  3. [JSP]menu dynamique en jsp
    Par laouedjahmed dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 22/03/2004, 10h50
  4. Menu dynamique sous Flash MX
    Par dens63 dans le forum Flash
    Réponses: 7
    Dernier message: 29/10/2003, 15h46
  5. Comment créer un menu popup style XP ?
    Par chaours dans le forum Composants VCL
    Réponses: 4
    Dernier message: 29/09/2003, 09h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo