Screen.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. if (typeof window.RadControlsNamespace == "undefined")
  2. {
  3. window.RadControlsNamespace = {};
  4. }
  5. if (
  6. typeof(window.RadControlsNamespace.Screen) == "undefined" ||
  7. typeof(window.RadControlsNamespace.Screen.Version) == null ||
  8. window.RadControlsNamespace.Screen.Version < 1.1
  9. )
  10. {
  11. window.RadControlsNamespace.Screen =
  12. {
  13. Version : 1.1,
  14. GetViewPortSize : function()
  15. {
  16. var width = 0;
  17. var height = 0;
  18. var canvas = document.body;
  19. if (RadControlsNamespace.Browser.StandardsMode && !RadControlsNamespace.Browser.IsSafari)
  20. {
  21. canvas = document.documentElement;
  22. }
  23. if (RadControlsNamespace.Browser.IsMozilla && document.compatMode != "CSS1Compat")
  24. {
  25. canvas = document.body;
  26. }
  27. if (window.innerWidth)
  28. {
  29. width = window.innerWidth;
  30. height = window.innerHeight;
  31. }
  32. else
  33. {
  34. width = canvas.clientWidth;
  35. height = canvas.clientHeight;
  36. }
  37. width += canvas.scrollLeft;
  38. height += canvas.scrollTop;
  39. return { width : width - 6, height : height - 6 };
  40. },
  41. GetElementPosition : function (el)
  42. {
  43. var parent = null;
  44. var pos = {x: 0, y: 0};
  45. var box;
  46. if (el.getBoundingClientRect)
  47. {
  48. // IE
  49. box = el.getBoundingClientRect();
  50. var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  51. var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
  52. pos.x = box.left + scrollLeft - 2;
  53. pos.y = box.top + scrollTop - 2;
  54. return pos;
  55. }
  56. else if (document.getBoxObjectFor)
  57. {
  58. // gecko
  59. try
  60. {
  61. box = document.getBoxObjectFor(el);
  62. pos.x = box.x - 2;
  63. pos.y = box.y - 2;
  64. }catch(e){}
  65. }
  66. else
  67. {
  68. // safari/opera
  69. pos.x = el.offsetLeft;
  70. pos.y = el.offsetTop;
  71. parent = el.offsetParent;
  72. if (parent != el)
  73. {
  74. while (parent)
  75. {
  76. pos.x += parent.offsetLeft;
  77. pos.y += parent.offsetTop;
  78. parent = parent.offsetParent;
  79. }
  80. }
  81. }
  82. if (window.opera)
  83. {
  84. parent = el.offsetParent;
  85. while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html')
  86. {
  87. pos.x -= parent.scrollLeft;
  88. pos.y -= parent.scrollTop;
  89. parent = parent.offsetParent;
  90. }
  91. }
  92. else
  93. {
  94. parent = el.parentNode;
  95. while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html')
  96. {
  97. pos.x -= parent.scrollLeft;
  98. pos.y -= parent.scrollTop;
  99. parent = parent.parentNode;
  100. }
  101. }
  102. return pos;
  103. },
  104. ElementOverflowsTop : function (element)
  105. {
  106. return this.GetElementPosition(element).y < 0;
  107. },
  108. ElementOverflowsLeft : function (element)
  109. {
  110. return this.GetElementPosition(element).x < 0;
  111. },
  112. ElementOverflowsBottom : function (screenSize, element)
  113. {
  114. var bottomEdge = this.GetElementPosition(element).y + RadControlsNamespace.Box.GetOuterHeight(element);
  115. return bottomEdge > screenSize.height;
  116. },
  117. ElementOverflowsRight : function (screenSize, element)
  118. {
  119. var rightEdge = this.GetElementPosition(element).x + RadControlsNamespace.Box.GetOuterWidth(element);
  120. return rightEdge > screenSize.width;
  121. }
  122. }
  123. }
  124. //BEGIN_ATLAS_NOTIFY
  125. if (typeof(Sys) != "undefined")
  126. {
  127. if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
  128. {
  129. Sys.Application.notifyScriptLoaded();
  130. }
  131. }
  132. //END_ATLAS_NOTIFY