Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

184 рядки
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. new_widget('SidebarMenu', function(m) { sidebar_menu = m; m.make_menu(''); });
  51. }
  52. }
  53. this.setup_header_footer = function() {
  54. // header
  55. if(cint(this.cp.header_height)) {
  56. var hh = this.cp.header_height ? (cint(this.cp.header_height) + 'px') : '0px';
  57. $y(this.header, {height:hh, borderBottom:'1px solid #CCC'});
  58. if(this.cp.client_name)this.banner_area.innerHTML = this.cp.client_name;
  59. }
  60. // footer
  61. var fh = this.cp.footer_height ? (cint(this.cp.footer_height) + 'px') : '0px';
  62. $y(this.footer, {height:fh});
  63. if(this.cp.footer_html)this.footer.innerHTML = this.cp.footer_html;
  64. }
  65. this.run_startup_code = function() {
  66. // startup style
  67. if(this.cp.startup_css)
  68. set_style(this.cp.startup_css);
  69. // startup code
  70. try{
  71. if(this.cp.startup_code)
  72. eval(this.cp.startup_code);
  73. if(this.cp.custom_startup_code)
  74. eval(this.cp.custom_startup_code);
  75. } catch(e) {
  76. errprint(e);
  77. }
  78. }
  79. this.setup = function() {
  80. this.cp = locals['Control Panel']['Control Panel'];
  81. this.wntoolbar_area = $a($i('body_div'),'div'); // $a(document.getElementsByTagName('body')[0], 'div');
  82. this.wrapper = $a($i('body_div'),'div');
  83. this.banner_area = $a(this.wrapper, 'div');;
  84. this.topmenu = $a(this.wrapper, 'div');
  85. this.breadcrumbs = $a(this.wrapper, 'div');
  86. this.body = $a(this.wrapper, 'div');
  87. this.footer = $a(this.wrapper, 'div');
  88. // sidebars
  89. if(user_defaults.hide_sidebars) {
  90. this.cp.left_sidebar_width = null;
  91. this.cp.right_sidebar_width = null;
  92. }
  93. this.setup_page_areas();
  94. // headers & footer
  95. this.setup_header_footer();
  96. // core areas;
  97. if(user=='Guest') user_defaults.hide_webnotes_toolbar = 1;
  98. if(!cint(user_defaults.hide_webnotes_toolbar) || user=='Administrator') {
  99. this.wntoolbar = new WNToolbar(this.wntoolbar_area);
  100. $y(this.wrapper, {marginTop: this.wntoolbar.wrapper.offsetHeight + 'px'});
  101. }
  102. // page width
  103. if(this.cp.page_width) $y(this.wrapper,{width:cint(this.cp.page_width) + 'px'});
  104. }
  105. // Standard containers
  106. // - Forms
  107. // - Report Builder
  108. // - Item List
  109. // - [Pages by their names]
  110. this.pages = {};
  111. this.cur_page = null;
  112. this.add_page = function(label, onshow, onhide) {
  113. var c = $a(this.center.body, 'div');
  114. if(onshow)
  115. c.onshow = onshow;
  116. if(onhide)
  117. c.onhide = onhide;
  118. this.pages[label] = c;
  119. $dh(c);
  120. return c;
  121. }
  122. this.change_to = function(label) {
  123. // hide existing
  124. $dh(this.center.loading);
  125. if(me.cur_page && me.pages[label]!=me.cur_page) {
  126. if(me.cur_page.onhide)
  127. me.cur_page.onhide();
  128. $dh(me.cur_page);
  129. }
  130. // show
  131. me.cur_page = me.pages[label];
  132. me.cur_page_label = label;
  133. $(me.cur_page).fadeIn();
  134. // on show
  135. if(me.cur_page.onshow)
  136. me.cur_page.onshow(me.cur_page);
  137. }
  138. this.set_status = function(txt) {
  139. if(this.status_area)
  140. this.status_area.innerHTML = txt;
  141. }
  142. this.set_session_changed = function() {
  143. if(this.session_message_set) return;
  144. var div = $a($i('body_div').parentNode,'div','',{textAlign: 'center', fontSize:'14px', margin:'150px auto'});
  145. $dh('body_div');
  146. div.innerHTML = 'This session has been changed. Please <span class="link_type" onclick="window.location.reload()">refresh</span> to continue';
  147. this.session_message_set = 1;
  148. }
  149. this.setup();
  150. }