952d1aaa0a64e9f6239fe3af95269c1b99362b68.svn-base 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Ext JS Library 2.0 Copyright(c) 2006-2007, Ext JS, LLC. licensing@extjs.com
  3. *
  4. * http://extjs.com/license
  5. */
  6. Ext.layout.Accordion = Ext.extend(Ext.layout.FitLayout, {
  7. fill : true,
  8. autoWidth : true,
  9. titleCollapse : true,
  10. hideCollapseTool : false,
  11. collapseFirst : false,
  12. animate : false,
  13. sequence : false,
  14. activeOnTop : false,
  15. renderItem : function(A) {
  16. if (this.animate === false) {
  17. A.animCollapse = false
  18. }
  19. A.collapsible = true;
  20. if (this.autoWidth) {
  21. A.autoWidth = true
  22. }
  23. if (this.titleCollapse) {
  24. A.titleCollapse = true
  25. }
  26. if (this.hideCollapseTool) {
  27. A.hideCollapseTool = true
  28. }
  29. if (this.collapseFirst !== undefined) {
  30. A.collapseFirst = this.collapseFirst
  31. }
  32. if (!this.activeItem && !A.collapsed) {
  33. this.activeItem = A
  34. } else {
  35. if (this.activeItem) {
  36. A.collapsed = true
  37. }
  38. }
  39. Ext.layout.Accordion.superclass.renderItem.apply(this,
  40. arguments);
  41. A.header.addClass("x-accordion-hd");
  42. A.on("beforeexpand", this.beforeExpand, this)
  43. },
  44. beforeExpand : function(C, B) {
  45. var A = this.activeItem;
  46. if (A) {
  47. if (this.sequence) {
  48. delete this.activeItem;
  49. A.collapse({
  50. callback : function() {
  51. C.expand(B || true)
  52. },
  53. scope : this
  54. });
  55. return false
  56. } else {
  57. A.collapse(this.animate)
  58. }
  59. }
  60. this.activeItem = C;
  61. if (this.activeOnTop) {
  62. C.el.dom.parentNode.insertBefore(C.el.dom,
  63. C.el.dom.parentNode.firstChild)
  64. }
  65. this.layout()
  66. },
  67. setItemSize : function(F, E) {
  68. if (this.fill && F) {
  69. var B = this.container.items.items;
  70. var D = 0;
  71. for (var C = 0, A = B.length; C < A; C++) {
  72. var G = B[C];
  73. if (G != F) {
  74. D += (G.getSize().height - G.bwrap.getHeight())
  75. }
  76. }
  77. E.height -= D;
  78. F.setSize(E)
  79. }
  80. }
  81. });
  82. Ext.Container.LAYOUTS["accordion"] = Ext.layout.Accordion;