PromptPage.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* Copyright (c) Business Objects 2006. All rights reserved. */
  2. if (typeof(bobj.crv.PromptPage) == 'undefined') {
  3. bobj.crv.PromptPage = {};
  4. }
  5. /**
  6. * PromptPage constructor
  7. *
  8. * @param kwArgs.id [String] DOM node id
  9. * @param kwArgs.contentId [String] DOM node id of report page content container
  10. * @param kwArgs.bgColor [String] Background color of the page
  11. * @param kwArgs.width [Int] Page content's width in pixels
  12. * @param kwArgs.height [Int] Page content's height in pixels
  13. * @param kwArgs.topMargin [Int] Top margin of report page in pixels
  14. * @param kwArgs.rightMargin [Int] Right margin of report page in pixels
  15. * @param kwArgs.bottomMargin [Int] Bottom margin of report page in pixels
  16. * @param kwArgs.leftMargin [Int] Left margin of report page in pixels
  17. */
  18. bobj.crv.newPromptPage = function(kwArgs) {
  19. kwArgs = MochiKit.Base.update({
  20. id: bobj.uniqueId(),
  21. layoutType: 'fixed',
  22. width: 800,
  23. height: 600,
  24. padding: 5,
  25. top: 0,
  26. left: 0
  27. }, kwArgs);
  28. var o = newWidget(kwArgs.id);
  29. o.widgetType = 'PromptPage';
  30. o._reportProcessing = null;
  31. // Update instance with constructor arguments
  32. bobj.fillIn(o, kwArgs);
  33. // Update instance with member functions
  34. o.initOld = o.init;
  35. MochiKit.Base.update(o, bobj.crv.PromptPage);
  36. return o;
  37. };
  38. /**
  39. * Overrides parent. Sets the content of the report page.
  40. *
  41. * @param content [String|DOM Node] Html or Node to use as report page content
  42. */
  43. bobj.crv.PromptPage.setHTML = function (content) {
  44. var pageNode = this._pageNode;
  45. if (bobj.isString(content)) {
  46. pageNode.innerHTML = content;
  47. }
  48. else if (bobj.isObject(content)) {
  49. pageNode.innerHTML = '';
  50. pageNode.appendChild(content);
  51. var contentStyle = content.style;
  52. contentStyle.display = 'block';
  53. contentStyle.visibility = 'visible';
  54. }
  55. };
  56. bobj.crv.PromptPage.getHTML = function () {
  57. var h = bobj.html;
  58. var isBorderBoxModel = bobj.isBorderBoxModel();
  59. var pageOuterHeight = this.height + this.topMargin + this.bottomMargin;
  60. var pageOuterWidth = this.width + this.leftMargin + this.rightMargin;
  61. var contentHeight = isBorderBoxModel ? pageOuterHeight : this.height;
  62. var contentWidth = isBorderBoxModel ? pageOuterWidth : this.width;
  63. var layerStyle = {
  64. position: 'relative',
  65. width: contentWidth + 'px',
  66. height: contentHeight + 'px',
  67. top: this.top + "px",
  68. left: this.left + "px",
  69. border: 'none',
  70. 'z-index': 1,
  71. 'background-color': this.bgColor
  72. };
  73. // To support the width and height
  74. if (this.layoutType == 'fixed') {
  75. layerStyle.overflow = 'auto';
  76. }
  77. var pageStyle = {
  78. 'padding': this.padding + 'px'
  79. };
  80. var html = h.DIV({id: this.id, style:layerStyle},
  81. h.DIV({id:this.id + '_page', style:pageStyle}) );
  82. return html + bobj.crv.getInitHTML(this.widx);
  83. };
  84. bobj.crv.PromptPage.init = function () {
  85. this._pageNode = document.getElementById(this.id + '_page');
  86. this.initOld();
  87. if (this.contentId) {
  88. var content = document.getElementById(this.contentId);
  89. if (content) {
  90. this.setHTML(content);
  91. }
  92. }
  93. var connect = MochiKit.Signal.connect;
  94. if (this.layoutType.toLowerCase() == 'client') {
  95. connect(window, 'onresize', this, '_doLayout');
  96. }
  97. this._doLayout();
  98. };
  99. //TODO: fix the layout (fitreport) to behave like XIR2
  100. bobj.crv.PromptPage._doLayout = function() {
  101. var layout = this.layoutType.toLowerCase();
  102. if ('client' == layout) {
  103. this.css.width = '100%';
  104. this.css.height = '100%';
  105. }
  106. else if ('fitreport' == layout) {
  107. this.css.width = '100%';
  108. this.css.height = '100%';
  109. }
  110. else { // fixed layout
  111. this.css.width = this.width + 'px';
  112. this.css.height = this.height + 'px';
  113. }
  114. var rptProcessing = this._reportProcessing;
  115. if (rptProcessing && rptProcessing.layer) {
  116. rptProcessing.center();
  117. }
  118. };
  119. bobj.crv.PromptPage.addChild = function(widget) {
  120. if (widget.widgetType == 'ReportProcessingUI') {
  121. this._reportProcessing = widget;
  122. }
  123. };
  124. if (typeof(bobj.crv.FlexPromptPage) == 'undefined') {
  125. bobj.crv.FlexPromptPage = {};
  126. }
  127. /**
  128. * FlexPromptPage constructor
  129. *
  130. * @param kwArgs.id [String] DOM node id
  131. * @param kwArgs.contentId [String] DOM node id of report page content container
  132. * @param kwArgs.bgColor [String] Background color of the page
  133. * @param kwArgs.width [Int] Page content's width in pixels
  134. * @param kwArgs.height [Int] Page content's height in pixels
  135. * @param kwArgs.topMargin [Int] Top margin of report page in pixels
  136. * @param kwArgs.rightMargin [Int] Right margin of report page in pixels
  137. * @param kwArgs.bottomMargin [Int] Bottom margin of report page in pixels
  138. * @param kwArgs.leftMargin [Int] Left margin of report page in pixels
  139. */
  140. bobj.crv.newFlexPromptPage = function(kwArgs) {
  141. kwArgs = MochiKit.Base.update({
  142. id: bobj.uniqueId(),
  143. layoutType: 'fixed',
  144. width: 800,
  145. height: 600,
  146. padding: 5,
  147. top: 0,
  148. left: 0
  149. }, kwArgs);
  150. var o = newWidget(kwArgs.id);
  151. o.widgetType = 'FlexPromptPage';
  152. o._reportProcessing = null;
  153. // Update instance with constructor arguments
  154. bobj.fillIn(o, kwArgs);
  155. // Update instance with member functions
  156. o.initOld = o.init;
  157. MochiKit.Base.update(o, bobj.crv.FlexPromptPage);
  158. return o;
  159. };
  160. /**
  161. * Overrides parent. Does nothing because the swf content will replace the DIV later
  162. *
  163. * @param content [String|DOM Node] Html or Node to use as report page content
  164. */
  165. bobj.crv.FlexPromptPage.setHTML = function (content) {
  166. };
  167. bobj.crv.FlexPromptPage.getHTML = function () {
  168. var isBorderBoxModel = bobj.isBorderBoxModel();
  169. var pageOuterHeight = this.height + this.topMargin + this.bottomMargin;
  170. var pageOuterWidth = this.width + this.leftMargin + this.rightMargin;
  171. var contentHeight = isBorderBoxModel ? pageOuterHeight : this.height;
  172. var contentWidth = isBorderBoxModel ? pageOuterWidth : this.width;
  173. var useSize = this.layoutType.toLowerCase() == bobj.crv.Viewer.LayoutTypes.FIXED;
  174. var layerStyle = {
  175. position: 'relative',
  176. width: useSize ? contentWidth + 'px' : '100%',
  177. height: useSize ? contentHeight + 'px' : '100%',
  178. top: this.top + "px",
  179. left: this.left + "px",
  180. border: 'none',
  181. 'z-index': 1,
  182. 'background-color': this.bgColor
  183. };
  184. var pageStyle = {
  185. 'padding': this.padding + 'px',
  186. position: 'absolute' // Must be absolute to avoid double initialization in firefox ADAPT01260507
  187. };
  188. bobj.crv.params.FlexParameterUI.setViewerLayoutType(this.id, this.layoutType);
  189. var h = bobj.html;
  190. return h.DIV({id: this.id, style:layerStyle},
  191. h.DIV({id:this.id + '_page', style:pageStyle},
  192. h.DIV({id:this.contentId})) );
  193. };
  194. bobj.crv.FlexPromptPage.init = function () {
  195. var connect = MochiKit.Signal.connect;
  196. if (this.layoutType.toLowerCase() == 'client') {
  197. connect(window, 'onresize', this, '_doLayout');
  198. }
  199. this._doLayout();
  200. };
  201. bobj.crv.FlexPromptPage._doLayout = function() {
  202. var rptProcessing = this._reportProcessing;
  203. if (rptProcessing && rptProcessing.layer) {
  204. rptProcessing.center();
  205. }
  206. };
  207. bobj.crv.FlexPromptPage.addChild = function(widget) {
  208. if (widget.widgetType == 'ReportProcessingUI') {
  209. this._reportProcessing = widget;
  210. }
  211. };