XHtml.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /**
  2. * XHtmlHtml
  3. */
  4. XHtmlHtml.prototype = new XFormsElement;
  5. function XHtmlHtml (strParentId, strId, strTag)
  6. {
  7. if (!strId)
  8. {
  9. return;
  10. }
  11. XFormsElement.call(this, strParentId, strId, strTag);
  12. };
  13. /**
  14. * XHtmlHead
  15. */
  16. XHtmlHead.prototype = new XFormsElement;
  17. function XHtmlHead (strParentId, strId, strTag)
  18. {
  19. if (!strId)
  20. {
  21. return;
  22. }
  23. XFormsElement.call(this, strParentId, strId, strTag);
  24. };
  25. /**
  26. * XHtmlBody
  27. */
  28. XHtmlBody.prototype = new XFormsGroup;
  29. function XHtmlBody (strParentId, strAlert, strHelp, strHint, strAccesskey, bAutoRefresh, strClass, bDisabled, strId, nNavindex,
  30. strOverflow, strPrintBottomMargin, strPrintLeftMargin, strPrintRightMargin, strPrintTopMargin, strScroll, strStyle, strTag, strVisibility)
  31. {
  32. if (!strId)
  33. {
  34. return;
  35. }
  36. XFormsGroup.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, ""/*strBind*/, strClass, bDisabled, strId, nNavindex,
  37. strOverflow, ""/*bPopup*/, ""/*strRef*/, strScroll, ""/*strShowEffect*/, strStyle, strTag, strVisibility);
  38. this.m_bShowPopupMenu = true;
  39. this.m_bSetPopupMenu = false;
  40. /**
  41. * Property
  42. */
  43. // Attribute
  44. this.attribute["autorefresh"] = bAutoRefresh;
  45. this.attribute["print-bottommargin"] = strPrintBottomMargin;
  46. this.attribute["print-leftmargin"] = strPrintLeftMargin;
  47. this.attribute["print-rightmargin"] = strPrintRightMargin;
  48. this.attribute["print-topmargin"] = strPrintTopMargin;
  49. };
  50. XHtmlBody.prototype.refresh = function ()
  51. {
  52. var arKeyset = this.children.keys();
  53. for (var i=0; i<arKeyset.length; i++)
  54. {
  55. var strId = arKeyset[i];
  56. var objChild = this.children.item(strId);
  57. if (null != objChild && objChild instanceof XFormsElement && objChild.refresh)
  58. {
  59. objChild.refresh();
  60. }
  61. }
  62. };
  63. XHtmlBody.prototype.init = function ()
  64. {
  65. XFormsGroup.prototype.init.call(this);
  66. body.attribute["width"] = document.body.clientWidth;
  67. body.attribute["height"] = document.body.clientHeight;
  68. this.m_heControl.borderWidth = "0px";
  69. this.m_heControl.style.position = "absolute";
  70. };
  71. XHtmlBody.prototype.onMouseDown = function (event)
  72. {
  73. XFormsGroup.prototype.onMouseDown.call(this, event);
  74. var objWindow = window;
  75. var nPositionX = 0;
  76. var nPositionY = 0;
  77. while (window.top != objWindow && null != objWindow)
  78. {
  79. var heOffsetParent = objWindow.frameElement;
  80. while (null != heOffsetParent)
  81. {
  82. nPositionX += heOffsetParent.offsetLeft;
  83. nPositionY += heOffsetParent.offsetTop;
  84. if (heOffsetParent != objWindow.frameElement && heOffsetParent != objWindow.document.body)
  85. {
  86. nPositionX += heOffsetParent.clientLeft;
  87. nPositionY += heOffsetParent.clientTop;
  88. }
  89. nPositionX -= (is_android ? 0 : heOffsetParent.scrollLeft);
  90. nPositionY -= (is_android ? 0 : heOffsetParent.scrollTop);
  91. heOffsetParent = heOffsetParent.offsetParent;
  92. }
  93. objWindow = objWindow.parent;
  94. }
  95. nPositionX = nPositionX + event.x + window.top.document.body.scrollLeft;
  96. nPositionY = nPositionY + event.y + window.top.document.body.scrollTop;
  97. var bTargetContext = false;
  98. if (window.top.document.getElementById("HE___TF_ContextMenu"))
  99. {
  100. var xnContextMenu = window.top.document.getElementById("HE___TF_ContextMenu");
  101. var nContextLeft = xnContextMenu.offsetLeft - window.top.document.body.scrollLeft;
  102. var nContextTop = xnContextMenu.offsetTop - window.top.document.body.scrollTop;
  103. var nContextRight = nContextLeft + xnContextMenu.offsetWidth;
  104. var nContextBottom = nContextTop + xnContextMenu.offsetHeight;
  105. if (nPositionX < nContextLeft || nPositionX > nContextRight || nPositionY < nContextTop || nPositionY > nContextBottom)
  106. {
  107. window.top.document.body.removeChild(xnContextMenu);
  108. }
  109. else
  110. {
  111. bTargetContext = true;
  112. }
  113. }
  114. if (event.button == 3)
  115. {
  116. if (this.m_bShowPopupMenu && !this.m_bSetPopupMenu && !bTargetContext)
  117. {
  118. window.top.document.oncontextmenu = null;
  119. if (window != window.top) document.oncontextmenu = null;
  120. }
  121. else
  122. {
  123. window.top.document.oncontextmenu = new Function("return false");
  124. if (window != window.top) document.oncontextmenu = new Function("return false");
  125. }
  126. if (this.m_bShowPopupMenu && this.m_bSetPopupMenu && !bTargetContext) document.allElement.item("__TF_ContextMenu").createContextMenu(nPositionX, nPositionY);
  127. }
  128. };