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
| function BoiteGlobale(){
this.boite = document.body;
this.fenetreCourante = 0;
this.listeFenetre = [];
this.alt = false;
this.posXinit = 0;
this.posYinit = 0;
this.ZIndexMax = 0;
this.setComportement();
}
BoiteGlobale.prototype = {
toucheAlt: 18, // code touche Alt
toucheCombin: 76, // code touche l
setComportement: function() {
var courantSubstrat = this;
document.onkeydown = function(evt){
var touche = evt.keyCode;
if(touche == courantSubstrat.toucheAlt && !courantSubstrat.alt){
courantSubstrat.alt = true;
if(courantSubstrat.listeFenetre.length > 1) courantSubstrat.makeListe();
} else if(courantSubstrat.alt && touche != courantSubstrat.toucheAlt){
if(evt.keyCode == courantSubstrat.toucheCombin && courantSubstrat.listeFenetre.length > 1){
for(indexFenetre in courantSubstrat.listeFenetre){
if($(courantSubstrat.listeFenetre[indexFenetre]).style.zIndex == courantSubstrat.ZIndexMax){
var idFenetreActive = (1 + 1*indexFenetre < courantSubstrat.listeFenetre.length) ? 1 + 1*indexFenetre : 0;
courantSubstrat.setWindowFocus(courantSubstrat.listeFenetre[idFenetreActive]);
break;
};
};
courantSubstrat.makeListe();
};
};
};
document.onkeyup = function(evt){
var touche = evt.keyCode;
if(touche == courantSubstrat.toucheAlt){
courantSubstrat.alt = false;
if($('fenetresActives')) document.body.removeChild($('fenetresActives'));
};
};
},
makeListe: function(){
if($('fenetresActives')) document.body.removeChild($('fenetresActives'));
var cadreListeFenetre = document.createElement('div');
cadreListeFenetre.id = 'fenetresActives';
cadreListeFenetre.className = 'fenetresActives';
cadreListeFenetre.style.zIndex = 1+ 1*this.ZIndexMax;
var listeFen = document.createElement('ul');
for(indexFenetre in this.listeFenetre){
var fenTmp = document.createElement('li');
fenTmp.id = this.listeFenetre[indexFenetre];
fenTmp.innerHTML = $(this.listeFenetre[indexFenetre]).title;
fenTmp.className = ($(this.listeFenetre[indexFenetre]).style.zIndex == this.ZIndexMax) ? 'fenSelect' : 'fenDeSelect';
listeFen.appendChild(fenTmp);
};
listeFen.className = 'listeFenetre';
cadreListeFenetre.appendChild(listeFen);
cadreListeFenetre.onclick = function(){
document.body.removeChild(cadreListeFenetre);
};
document.body.appendChild(cadreListeFenetre);
},
}
BoiteGlobale.prototype.constructor = BoiteGlobale; |
Partager