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
| var actionMenuId = null;
var actionMenuClassDown = null;
var actionMenuClassUp = null;
document.oncontextmenu=catchEvent;
document.onclick=hideMenu;
function showActionMenu(menuId,classUp,classDown){
actionMenuId = menuId;
actionMenuClassDown = classDown;
actionMenuClassUp = classUp;
}
function catchEvent(e){
var actionMenu = document.getElementById(actionMenuId);
if(actionMenu){
cX = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.clientX;
xY = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.clientY;
var rightedge= document.body.clientWidth-cX;
var bottomedge= document.body.clientHeight-cY;
if (rightedge>actionMenu.offsetWidth) {
actionMenu.style.left=document.body.scrollLeft+cX;
}else {
actionMenu.style.left=document.body.scrollLeft+cX-actionMenu.offsetWidth;
}
if (document.body.scrollLeft>document.body.scrollLeft+cX-actionMenu.offsetWidth && rightedge<actionMenu.offsetWidth){
actionMenu.style.left=document.body.scrollLeft;
}
if (bottomedge>actionMenu.offsetHeight) {
actionMenu.style.top=document.body.scrollTop+cY;
}
else {
actionMenu.style.top=document.body.scrollTop+cY-actionMenu.offsetHeight;
}
if (document.body.scrollTop>document.body.scrollTop+cY-actionMenu.offsetHeight && bottomedge<actionMenu.offsetHeight){
actionMenu.style.top=document.body.scrollTop;
}
actionMenu.className=actionMenuClassUp;
}
return false;
}
function hideMenu(){
var actionMenu = document.getElementById(actionMenuId);
if(actionMenu!=null){
actionMenu.className=actionMenuClassDown;
}
actionMenuId = null;
actionMenuClassDown = null;
actionMenuClassUp = null;
}
if (navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEDOWN); |
Partager