您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

156 行
3.6 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. // sidebars
  70. if(user_defaults.hide_sidebars) {
  71. this.cp.left_sidebar_width = null;
  72. this.cp.right_sidebar_width = null;
  73. }
  74. this.setup_page_areas();
  75. // core areas;
  76. if(user=='Guest') user_defaults.hide_webnotes_toolbar = 1;
  77. if(!cint(user_defaults.hide_webnotes_toolbar) || user=='Administrator') {
  78. this.wntoolbar = new wn.ui.toolbar.Toolbar();
  79. }
  80. // page width
  81. if(this.cp.page_width) $y(this.wrapper,{width:cint(this.cp.page_width) + 'px'});
  82. }
  83. // Standard containers
  84. // - Forms
  85. // - Report Builder
  86. // - Item List
  87. // - [Pages by their names]
  88. this.pages = {};
  89. this.cur_page = null;
  90. this.add_page = function(label, onshow, onhide) {
  91. var c = $a(this.center.body, 'div');
  92. if(onshow)
  93. c.onshow = onshow;
  94. if(onhide)
  95. c.onhide = onhide;
  96. this.pages[label] = c;
  97. $dh(c);
  98. return c;
  99. }
  100. this.change_to = function(label) {
  101. // hide existing
  102. $dh(this.center.loading);
  103. if(me.cur_page && me.pages[label]!=me.cur_page) {
  104. if(me.cur_page.onhide)
  105. me.cur_page.onhide();
  106. $dh(me.cur_page);
  107. }
  108. // show
  109. me.cur_page = me.pages[label];
  110. me.cur_page_label = label;
  111. $(me.cur_page).fadeIn();
  112. // on show
  113. if(me.cur_page.onshow)
  114. me.cur_page.onshow(me.cur_page);
  115. }
  116. this.set_status = function(txt) {
  117. if(this.status_area)
  118. this.status_area.innerHTML = txt;
  119. }
  120. this.set_session_changed = function() {
  121. if(this.session_message_set) return;
  122. var div = $a($i('body_div').parentNode,'div','',{textAlign: 'center', fontSize:'14px', margin:'150px auto'});
  123. $dh('body_div');
  124. div.innerHTML = 'This session has been changed. Please <span class="link_type" onclick="window.location.reload()">refresh</span> to continue';
  125. this.session_message_set = 1;
  126. }
  127. this.setup();
  128. }