Box.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. if (typeof window.RadControlsNamespace == "undefined")
  2. {
  3. window.RadControlsNamespace = {};
  4. }
  5. if (
  6. typeof(window.RadControlsNamespace.Box) == "undefined" ||
  7. typeof(window.RadControlsNamespace.Box.Version) == null ||
  8. window.RadControlsNamespace.Box.Version < 2
  9. )
  10. {
  11. window.RadControlsNamespace.Box =
  12. {
  13. Version : 2, /// Change the version when make changes. Change the value in the IF also
  14. GetOuterWidth : function (element)
  15. {
  16. return element.offsetWidth;
  17. },
  18. GetOuterHeight : function (element)
  19. {
  20. return element.offsetHeight;
  21. },
  22. SetOuterHeight : function (element, height)
  23. {
  24. if (height <= 0 || height == "")
  25. {
  26. element.style.height = "";
  27. }
  28. else
  29. {
  30. element.style.height = height + "px";
  31. var diff = element.offsetHeight - height;
  32. var newHeight = height - diff;
  33. if (newHeight > 0) {
  34. element.style.height = newHeight + "px";
  35. } else {
  36. element.style.height = "";
  37. }
  38. }
  39. },
  40. SetOuterWidth : function (element, width)
  41. {
  42. if (width <= 0 || width == "")
  43. {
  44. element.style.width = "";
  45. }
  46. else
  47. {
  48. element.style.width = width + "px";
  49. var diff = element.offsetWidth - width;
  50. var newWidth = width - diff;
  51. if (newWidth > 0) {
  52. element.style.width = newWidth + "px";
  53. } else {
  54. element.style.width = "";
  55. }
  56. return newWidth;
  57. }
  58. },
  59. GetPropertyValue : function(element, styleProperty)
  60. {
  61. var computedStyle = this.GetStyle(element);
  62. return this.GetStyleValues(computedStyle, styleProperty);
  63. },
  64. GetStyle : function (element)
  65. {
  66. if (document.defaultView && document.defaultView.getComputedStyle)
  67. {
  68. return document.defaultView.getComputedStyle(element, null);
  69. }
  70. else if (element.currentStyle)
  71. {
  72. return element.currentStyle;
  73. }
  74. else
  75. {
  76. return element.style;
  77. }
  78. }
  79. }
  80. }
  81. //BEGIN_ATLAS_NOTIFY
  82. if (typeof(Sys) != "undefined")
  83. {
  84. if (Sys.Application != null && Sys.Application.notifyScriptLoaded != null)
  85. {
  86. Sys.Application.notifyScriptLoaded();
  87. }
  88. }
  89. //END_ATLAS_NOTIFY