No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 
 

163 líneas
4.0 KiB

  1. // Tabbed Page
  2. function TabbedPage(parent, only_labels) {
  3. this.tabs = {};
  4. this.items = this.tabs // bc
  5. this.cur_tab = null;
  6. this.label_wrapper = $a(parent, 'div','box_label_wrapper', {marginTop:'16px'}); // for border
  7. this.label_body = $a(this.label_wrapper, 'div', 'box_label_body'); // for height
  8. this.label_area = $a(this.label_body, 'ul', 'box_tabs');
  9. if(!only_labels)this.body_area = $a(parent, 'div', '', {backgroundColor:'#FFF'});
  10. else this.body_area = null;
  11. this.add_item = function(label, onclick, no_body, with_heading) {
  12. this.add_tab(label, onclick, no_body, with_heading);
  13. return this.items[label];
  14. }
  15. }
  16. TabbedPage.prototype.add_tab = function(n, onshow, no_body, with_heading) {
  17. var tab = $a(this.label_area, 'li');
  18. tab.label = $a(tab,'a');
  19. tab.label.innerHTML = n;
  20. if(this.body_area && !no_body){
  21. tab.tab_body = $a(this.body_area, 'div');
  22. $dh(tab.tab_body);
  23. tab.body = tab.tab_body; // bc
  24. } else {
  25. tab.tab_body = null;
  26. }
  27. tab.onshow = onshow;
  28. var me = this;
  29. tab.collapse = function() {
  30. if(this.tab_body)$dh(this.tab_body); this.className = '';
  31. if(hide_autosuggest)
  32. hide_autosuggest();
  33. }
  34. tab.set_selected = function() {
  35. if(me.cur_tab) me.cur_tab.collapse();
  36. this.className = 'box_tab_selected';
  37. $op(this, 100);
  38. me.cur_tab = this;
  39. }
  40. tab.expand = function(arg) {
  41. this.set_selected();
  42. if(this.tab_body) $ds(this.tab_body);
  43. if(this.onshow)this.onshow(arg);
  44. }
  45. tab.onmouseover = function() {
  46. if(me.cur_tab!=this) this.className = 'box_tab_mouseover';
  47. }
  48. tab.onmouseout = function() {
  49. if(me.cur_tab!=this) this.className = ''
  50. }
  51. tab.hide = function() {
  52. this.collapse();
  53. $dh(this);
  54. }
  55. tab.show = function() {
  56. $ds(this);
  57. }
  58. tab.onclick = function() { this.expand(); }
  59. this.tabs[n] = tab;
  60. return tab;
  61. }
  62. // =================================================================================
  63. function TrayPage(parent, height, width, width_body) {
  64. var me = this;
  65. if(!width) width=(100/8)+'%';
  66. this.body_style = {margin: '4px 8px'}
  67. this.cur_item = null;
  68. this.items = {};
  69. this.tabs = this.items // for tabs
  70. this.tab = make_table($a(parent, 'div'), 1, 2, '100%', [width, width_body]);
  71. // tray style
  72. $y($td(this.tab, 0, 0),{
  73. backgroundColor: this.tray_bg
  74. //,borderRight:'1px solid ' + this.tray_fg
  75. ,width: width
  76. });
  77. // body style
  78. this.body = $a($td(this.tab, 0, 1), 'div');
  79. if(height) {
  80. $y(this.body, {height: height, overflow: 'auto'});
  81. }
  82. this.add_item = function(label, onclick, no_body, with_heading) {
  83. this.items[label] = new TrayItem(me, label, onclick, no_body, with_heading);
  84. return this.items[label];
  85. }
  86. }
  87. function TrayItem(tray, label, onclick, no_body, with_heading) {
  88. this.label = label;
  89. this.onclick = onclick;
  90. var me = this;
  91. this.ldiv = $a($td(tray.tab, 0, 0), 'div');
  92. $item_normal(this.ldiv);
  93. if(!no_body) {
  94. this.wrapper = $a(tray.body, 'div', '', tray.body_style);
  95. if(with_heading) {
  96. this.header = $a(this.wrapper, 'div', 'sectionHeading', {marginBottom:'16px', paddingBottom:'0px'});
  97. this.header.innerHTML = label;
  98. }
  99. this.body = $a(this.wrapper, 'div');
  100. this.tab_body = this.body; // for sync with tabs
  101. $dh(this.wrapper);
  102. }
  103. $(this.ldiv).html(label)
  104. .hover(
  105. function() { if(tray.cur_item.label != this.label) $item_active(this); },
  106. function() { if(tray.cur_item.label != this.label) $item_normal(this); }
  107. )
  108. .click(
  109. function() { me.expand(); }
  110. )
  111. this.ldiv.label = label;
  112. this.ldiv.setAttribute('title',label);
  113. this.ldiv.onmousedown = function() { $item_pressed(this); }
  114. this.ldiv.onmouseup = function() { $item_selected(this); }
  115. this.expand = function() {
  116. if(tray.cur_item) tray.cur_item.collapse();
  117. if(me.wrapper) $ds(me.wrapper);
  118. if(me.onclick) me.onclick(me.label);
  119. me.show_as_expanded();
  120. }
  121. this.show_as_expanded = function() {
  122. $item_selected(me.ldiv);
  123. tray.cur_item = me;
  124. }
  125. this.collapse = function() {
  126. if(me.wrapper)$dh(me.wrapper);
  127. $item_normal(me.ldiv);
  128. }
  129. this.hide = function() {
  130. me.collapse();
  131. $dh(me.ldiv);
  132. }
  133. this.show = function() {
  134. $ds(me.ldiv);
  135. }
  136. }