25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

162 satır
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. hide_autosuggest();
  32. }
  33. tab.set_selected = function() {
  34. if(me.cur_tab) me.cur_tab.collapse();
  35. this.className = 'box_tab_selected';
  36. $op(this, 100);
  37. me.cur_tab = this;
  38. }
  39. tab.expand = function(arg) {
  40. this.set_selected();
  41. if(this.tab_body) $ds(this.tab_body);
  42. if(this.onshow)this.onshow(arg);
  43. }
  44. tab.onmouseover = function() {
  45. if(me.cur_tab!=this) this.className = 'box_tab_mouseover';
  46. }
  47. tab.onmouseout = function() {
  48. if(me.cur_tab!=this) this.className = ''
  49. }
  50. tab.hide = function() {
  51. this.collapse();
  52. $dh(this);
  53. }
  54. tab.show = function() {
  55. $ds(this);
  56. }
  57. tab.onclick = function() { this.expand(); }
  58. this.tabs[n] = tab;
  59. return tab;
  60. }
  61. // =================================================================================
  62. function TrayPage(parent, height, width, width_body) {
  63. var me = this;
  64. if(!width) width=(100/8)+'%';
  65. this.body_style = {margin: '4px 8px'}
  66. this.cur_item = null;
  67. this.items = {};
  68. this.tabs = this.items // for tabs
  69. this.tab = make_table($a(parent, 'div'), 1, 2, '100%', [width, width_body]);
  70. // tray style
  71. $y($td(this.tab, 0, 0),{
  72. backgroundColor: this.tray_bg
  73. //,borderRight:'1px solid ' + this.tray_fg
  74. ,width: width
  75. });
  76. // body style
  77. this.body = $a($td(this.tab, 0, 1), 'div');
  78. if(height) {
  79. $y(this.body, {height: height, overflow: 'auto'});
  80. }
  81. this.add_item = function(label, onclick, no_body, with_heading) {
  82. this.items[label] = new TrayItem(me, label, onclick, no_body, with_heading);
  83. return this.items[label];
  84. }
  85. }
  86. function TrayItem(tray, label, onclick, no_body, with_heading) {
  87. this.label = label;
  88. this.onclick = onclick;
  89. var me = this;
  90. this.ldiv = $a($td(tray.tab, 0, 0), 'div');
  91. $item_normal(this.ldiv);
  92. if(!no_body) {
  93. this.wrapper = $a(tray.body, 'div', '', tray.body_style);
  94. if(with_heading) {
  95. this.header = $a(this.wrapper, 'div', 'sectionHeading', {marginBottom:'16px', paddingBottom:'0px'});
  96. this.header.innerHTML = label;
  97. }
  98. this.body = $a(this.wrapper, 'div');
  99. this.tab_body = this.body; // for sync with tabs
  100. $dh(this.wrapper);
  101. }
  102. $(this.ldiv).html(label)
  103. .hover(
  104. function() { if(tray.cur_item.label != this.label) $item_active(this); },
  105. function() { if(tray.cur_item.label != this.label) $item_normal(this); }
  106. )
  107. .click(
  108. function() { me.expand(); }
  109. )
  110. this.ldiv.label = label;
  111. this.ldiv.setAttribute('title',label);
  112. this.ldiv.onmousedown = function() { $item_pressed(this); }
  113. this.ldiv.onmouseup = function() { $item_selected(this); }
  114. this.expand = function() {
  115. if(tray.cur_item) tray.cur_item.collapse();
  116. if(me.wrapper) $ds(me.wrapper);
  117. if(me.onclick) me.onclick(me.label);
  118. me.show_as_expanded();
  119. }
  120. this.show_as_expanded = function() {
  121. $item_selected(me.ldiv);
  122. tray.cur_item = me;
  123. }
  124. this.collapse = function() {
  125. if(me.wrapper)$dh(me.wrapper);
  126. $item_normal(me.ldiv);
  127. }
  128. this.hide = function() {
  129. me.collapse();
  130. $dh(me.ldiv);
  131. }
  132. this.show = function() {
  133. $ds(me.ldiv);
  134. }
  135. }