a46fb6f52500792aed39c61748923d797e652a66
2 * © 2007 Benoît PIN – Centre de recherche en informatique – École des mines de Paris
3 * Licence Creative Commons http://creativecommons.org/licenses/by/2.0/
4 * $Id: retractable_menu.js 507 2008-05-16 16:43:58Z pin $
5 * $URL: http://svn.luxia.fr/svn/labo/projects/zope/Portfolio/trunk/skins/retractable_menu.js $
7 * element : element représentant le menu
8 * visibleAtStartup : menu visible au début
9 * charList : Liste des caractères à intercépter pour ce menu
10 * step : pas (en pixels) appliqué pour les reductions/affichages du menu
11 * direction : direction de réduction/affichage du menu = up,down,right ou left
12 * timeStep : intervalle utilisé pour la réduction/affichage du menu
15 function Menu(element
, visibleAtStartup
, charList
, step
, direction
, timeStep
)
17 this.element
= element
;
18 this.charList
= charList
;
20 this.direction
= direction
;
21 this.timeStep
= timeStep
;
23 this.style
= this.element
.style
;
24 if (visibleAtStartup
) {
25 this.style
.visibility
= 'visible'
29 this.style
.visibility
= 'hidden'
33 this.initialWidth
= parseInt(this.style
.width
);
34 this.initialHeight
= parseInt(this.style
.height
);
36 if(direction
== "up" || direction
== "down")
38 this.toModify
= "height";
39 this.toCheck
= "initialHeight";
43 this.toModify
= "width";
44 this.toCheck
= "initialWidth";
48 addListener(document
, 'keypress', function(evt
){thisMenu
.handleKeyPress(evt
);});
53 Menu
.prototype.handleKeyPress = function(evt
)
55 evt
= getEventObject(evt
);
56 var charPress
= String
.fromCharCode((evt
.keyCode
) ? evt
.keyCode
: evt
.which
);
58 if(this.charList
.indexOf(charPress
) != -1)
63 this.idAffiche
= setInterval(function(){thisMenu
.afficheMenu();}, this.timeStep
);
67 this.initialHeight
= parseInt(this.style
.height
);
68 this.initialWidth
= parseInt(this.style
.width
);
69 this.idReduc
= setInterval(function(){thisMenu
.reducMenu();}, this.timeStep
);
78 Menu
.prototype.reducMenu = function ()
80 var thickness
= parseInt(this.style
[this.toModify
]);
82 thickness
= (thickness
-this.step
);
87 this.style
.visibility
= "hidden";
88 clearInterval(this.idReduc
);
90 this.style
[this.toModify
] = thickness
+"px";
95 Menu
.prototype.afficheMenu = function()
97 this.style
.visibility
="visible";
99 var thickness
= parseInt(this.style
[this.toModify
]);
101 thickness
= (thickness
+this.step
);
103 if(thickness
>this[this.toCheck
])
105 thickness
= this[this.toCheck
];
106 clearInterval(this.idAffiche
);
109 this.style
[this.toModify
] = thickness
+"px";