Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

186 linhas
4.6 KiB

  1. /** Page Body
  2. + body
  3. + wntoolbar
  4. + banner_area
  5. + body
  6. + left_sidebar
  7. + center
  8. + right_sidebar
  9. + footer
  10. + dead session
  11. **/
  12. function Body() {
  13. this.left_sidebar = null;
  14. this.right_sidebar = null;
  15. this.status_area = null;
  16. var me = this;
  17. page_body = this;
  18. this.no_of_columns = function() {
  19. var n = 2;
  20. if(cint(me && me.cp && me.cp.right_sidebar_width))
  21. n = n + 1;
  22. return n;
  23. }
  24. this.setup_page_areas = function() {
  25. var n = this.no_of_columns();
  26. // has sidebars, make a table
  27. this.body_table = make_table(this.body, 1, n, '100%');
  28. $y(this.body_table, {tableLayout:'fixed'});
  29. var c = 0;
  30. // left sidebar
  31. this.left_sidebar = $td(this.body_table, 0, c);
  32. $y(this.left_sidebar, {width:cint(this.cp.left_sidebar_width) + 'px'});
  33. c++;
  34. // center
  35. this.center = $a($td(this.body_table, 0, c), 'div');
  36. c++;
  37. // right side bar
  38. if(cint(this.cp.right_sidebar_width)) {
  39. this.right_sidebar = $td(this.body_table, 0, c);
  40. $y(this.right_sidebar, {width:cint(this.cp.right_sidebar_width) + 'px'})
  41. c++;
  42. }
  43. this.center.header = $a(this.center, 'div');
  44. this.center.body = $a(this.center, 'div');
  45. this.center.loading = $a(this.center, 'div', '', {margin:'200px 0px', fontSize:'14px', color:'#999', textAlign:'center'});
  46. this.center.loading.innerHTML = 'Loading...'
  47. }
  48. this.setup_sidebar_menu = function() {
  49. if(this.left_sidebar && this.cp.show_sidebar_menu){
  50. sidebar_menu = new SidebarMenu();
  51. sidebar_menu.make_menu('');
  52. }
  53. }
  54. this.setup_header_footer = function() {
  55. // header
  56. if(cint(this.cp.header_height)) {
  57. var hh = this.cp.header_height ? (cint(this.cp.header_height) + 'px') : '0px';
  58. $y(this.header, {height:hh, borderBottom:'1px solid #CCC'});
  59. if(this.cp.client_name)this.banner_area.innerHTML = this.cp.client_name;
  60. }
  61. // footer
  62. var fh = this.cp.footer_height ? (cint(this.cp.footer_height) + 'px') : '0px';
  63. $y(this.footer, {height:fh});
  64. if(this.cp.footer_html)this.footer.innerHTML = this.cp.footer_html;
  65. }
  66. this.run_startup_code = function() {
  67. // startup style
  68. if(this.cp.startup_css)
  69. set_style(this.cp.startup_css);
  70. // startup code
  71. try{
  72. if(this.cp.startup_code)
  73. eval(this.cp.startup_code);
  74. if(this.cp.custom_startup_code)
  75. eval(this.cp.custom_startup_code);
  76. } catch(e) {
  77. errprint(e);
  78. }
  79. }
  80. this.setup = function() {
  81. this.cp = locals['Control Panel']['Control Panel'];
  82. this.wntoolbar_area = $a($i('body_div'),'div'); // $a(document.getElementsByTagName('body')[0], 'div');
  83. this.wrapper = $a($i('body_div'),'div');
  84. this.banner_area = $a(this.wrapper, 'div');;
  85. this.topmenu = $a(this.wrapper, 'div');
  86. this.breadcrumbs = $a(this.wrapper, 'div');
  87. this.body = $a(this.wrapper, 'div');
  88. this.footer = $a(this.wrapper, 'div');
  89. // sidebars
  90. if(user_defaults.hide_sidebars) {
  91. this.cp.left_sidebar_width = null;
  92. this.cp.right_sidebar_width = null;
  93. }
  94. this.setup_page_areas();
  95. // headers & footer
  96. this.setup_header_footer();
  97. // core areas;
  98. if(user=='Guest') user_defaults.hide_webnotes_toolbar = 1;
  99. if(!cint(user_defaults.hide_webnotes_toolbar) || user=='Administrator') {
  100. wn.require('lib/js/legacy/webpage/wntoolbar.js');
  101. this.wntoolbar = new WNToolbar(this.wntoolbar_area);
  102. $y(this.wrapper, {marginTop: this.wntoolbar.wrapper.offsetHeight + 'px'});
  103. }
  104. // page width
  105. if(this.cp.page_width) $y(this.wrapper,{width:cint(this.cp.page_width) + 'px'});
  106. }
  107. // Standard containers
  108. // - Forms
  109. // - Report Builder
  110. // - Item List
  111. // - [Pages by their names]
  112. this.pages = {};
  113. this.cur_page = null;
  114. this.add_page = function(label, onshow, onhide) {
  115. var c = $a(this.center.body, 'div');
  116. if(onshow)
  117. c.onshow = onshow;
  118. if(onhide)
  119. c.onhide = onhide;
  120. this.pages[label] = c;
  121. $dh(c);
  122. return c;
  123. }
  124. this.change_to = function(label) {
  125. // hide existing
  126. $dh(this.center.loading);
  127. if(me.cur_page && me.pages[label]!=me.cur_page) {
  128. if(me.cur_page.onhide)
  129. me.cur_page.onhide();
  130. $dh(me.cur_page);
  131. }
  132. // show
  133. me.cur_page = me.pages[label];
  134. me.cur_page_label = label;
  135. $(me.cur_page).fadeIn();
  136. // on show
  137. if(me.cur_page.onshow)
  138. me.cur_page.onshow(me.cur_page);
  139. }
  140. this.set_status = function(txt) {
  141. if(this.status_area)
  142. this.status_area.innerHTML = txt;
  143. }
  144. this.set_session_changed = function() {
  145. if(this.session_message_set) return;
  146. var div = $a($i('body_div').parentNode,'div','',{textAlign: 'center', fontSize:'14px', margin:'150px auto'});
  147. $dh('body_div');
  148. div.innerHTML = 'This session has been changed. Please <span class="link_type" onclick="window.location.reload()">refresh</span> to continue';
  149. this.session_message_set = 1;
  150. }
  151. this.setup();
  152. }