You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

150 lines
3.4 KiB

  1. /** Page Body
  2. + body
  3. + body
  4. + left_sidebar
  5. + center
  6. + right_sidebar
  7. + dead session
  8. **/
  9. function Body() {
  10. this.left_sidebar = null;
  11. this.right_sidebar = null;
  12. this.status_area = null;
  13. var me = this;
  14. page_body = this;
  15. this.no_of_columns = function() {
  16. var n = 2;
  17. if(cint(me && me.cp && me.cp.right_sidebar_width))
  18. n = n + 1;
  19. return n;
  20. }
  21. this.ready = function() {
  22. $dh('startup_div');
  23. $ds('body_div');
  24. }
  25. this.setup_page_areas = function() {
  26. var n = this.no_of_columns();
  27. // has sidebars, make a table
  28. this.body_table = make_table(this.body, 1, n, '100%');
  29. $y(this.body_table, {tableLayout:'fixed'});
  30. var c = 0;
  31. // left sidebar
  32. this.left_sidebar = $td(this.body_table, 0, c);
  33. $y(this.left_sidebar, {width:cint(this.cp.left_sidebar_width) + 'px'});
  34. c++;
  35. // center
  36. this.center = $a($td(this.body_table, 0, c), 'div');
  37. c++;
  38. // right side bar
  39. if(cint(this.cp.right_sidebar_width)) {
  40. this.right_sidebar = $td(this.body_table, 0, c);
  41. $y(this.right_sidebar, {width:cint(this.cp.right_sidebar_width) + 'px'})
  42. c++;
  43. }
  44. this.center.header = $a(this.center, 'div');
  45. this.center.body = $a(this.center, 'div');
  46. this.center.loading = $a(this.center, 'div', '', {margin:'200px 0px', fontSize:'14px', color:'#999', textAlign:'center'});
  47. this.center.loading.innerHTML = 'Loading...'
  48. }
  49. this.setup_sidebar_menu = function() {
  50. if(this.left_sidebar && this.cp.show_sidebar_menu){
  51. sidebar_menu = new SidebarMenu();
  52. sidebar_menu.make_menu('');
  53. }
  54. }
  55. this.run_startup_code = function() {
  56. $(document).trigger('startup');
  57. // startup code
  58. try{
  59. if(this.cp.custom_startup_code)
  60. eval(this.cp.custom_startup_code);
  61. } catch(e) {
  62. errprint(e);
  63. }
  64. }
  65. this.setup = function() {
  66. this.cp = wn.control_panel;
  67. this.wrapper = $a($i('body_div'),'div');
  68. this.body = $a(this.wrapper, 'div');
  69. this.setup_page_areas();
  70. // core areas;
  71. if(user=='Guest') user_defaults.hide_webnotes_toolbar = 1;
  72. if(!cint(user_defaults.hide_webnotes_toolbar) || user=='Administrator') {
  73. this.wntoolbar = new wn.ui.toolbar.Toolbar();
  74. }
  75. // page width
  76. if(this.cp.page_width) $y(this.wrapper,{width:cint(this.cp.page_width) + 'px'});
  77. }
  78. // Standard containers
  79. // - Forms
  80. // - Report Builder
  81. // - Item List
  82. // - [Pages by their names]
  83. this.pages = {};
  84. this.cur_page = null;
  85. this.add_page = function(label, onshow, onhide) {
  86. var c = $a(this.center.body, 'div');
  87. if(onshow)
  88. c.onshow = onshow;
  89. if(onhide)
  90. c.onhide = onhide;
  91. this.pages[label] = c;
  92. $dh(c);
  93. return c;
  94. }
  95. this.change_to = function(label) {
  96. // hide existing
  97. $dh(this.center.loading);
  98. if(me.cur_page && me.pages[label]!=me.cur_page) {
  99. if(me.cur_page.onhide)
  100. me.cur_page.onhide();
  101. $dh(me.cur_page);
  102. }
  103. // show
  104. me.cur_page = me.pages[label];
  105. me.cur_page_label = label;
  106. $(me.cur_page).fadeIn();
  107. // on show
  108. if(me.cur_page.onshow)
  109. me.cur_page.onshow(me.cur_page);
  110. }
  111. this.set_status = function(txt) {
  112. if(this.status_area)
  113. this.status_area.innerHTML = txt;
  114. }
  115. this.set_session_changed = function() {
  116. if(this.session_message_set) return;
  117. var div = $a($i('body_div').parentNode,'div','',{textAlign: 'center', fontSize:'14px', margin:'150px auto'});
  118. $dh('body_div');
  119. div.innerHTML = 'This session has been changed. Please <span class="link_type" onclick="window.location.reload()">refresh</span> to continue';
  120. this.session_message_set = 1;
  121. }
  122. this.setup();
  123. }