ContextMenu.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * DON'T REMOVE THE FOLLOWING LICENSE
  3. * INFORMATION!
  4. * ----------------------------------
  5. * Copyright by
  6. * Dennis Ritz
  7. * Author: Dennis Ritz
  8. * dennis.ritz@gmx.net
  9. * 2007-2008
  10. * ----------------------------------
  11. */
  12. isLeftClick = false;
  13. function ContextMenu() {
  14. this.leftClick = function() {
  15. isLeftClick = true;
  16. }
  17. this.show = function show(p_item,ev) {
  18. ContextContainer = Browser.getElementById("contextContainer");
  19. Browser.setDisplay(ContextContainer,true);
  20. ContextContainer.innerHTML = "";
  21. ContextContainer.appendChild(p_item.parentNode.nextSibling.nextSibling.cloneNode(true));
  22. var mouseCoords = Mouse.coords(ev);
  23. Browser.setTop(ContextContainer,mouseCoords.y);
  24. Browser.setLeft(ContextContainer,mouseCoords.x);
  25. return false;
  26. }
  27. this.hide = function hide(e) {
  28. ContextContainer = Browser.getElementById("contextContainer");
  29. if (!e)e = window.event;
  30. if ((e.button && e.button == 2) || (e.which && e.which == 3) || isLeftClick) {
  31. isLeftClick = false;
  32. }else{
  33. Browser.setDisplay(ContextContainer,false);
  34. }
  35. }
  36. }
  37. var ContextMenu = new ContextMenu();
  38. document.onclick = ContextMenu.hide;