AccordionWindow.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*!
  2. * Ext JS Library 4.0
  3. * Copyright(c) 2006-2011 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.define('MyDesktop.AccordionWindow', {
  8. extend: 'Ext.ux.desktop.Module',
  9. requires: [
  10. 'Ext.data.TreeStore',
  11. 'Ext.layout.container.Accordion',
  12. 'Ext.toolbar.Spacer',
  13. 'Ext.tree.Panel'
  14. ],
  15. id:'acc-win',
  16. init : function(){
  17. this.launcher = {
  18. text: 'Accordion Window',
  19. iconCls:'accordion'
  20. };
  21. },
  22. createTree : function(){
  23. var tree = Ext.create('Ext.tree.Panel', {
  24. id:'im-tree',
  25. title: 'Online Users',
  26. rootVisible:false,
  27. lines:false,
  28. autoScroll:true,
  29. tools:[{
  30. type: 'refresh',
  31. handler: function(c, t) {
  32. tree.setLoading(true, tree.body);
  33. var root = tree.getRootNode();
  34. root.collapseChildren(true, false);
  35. Ext.Function.defer(function() { // mimic a server call
  36. tree.setLoading(false);
  37. root.expand(true, true);
  38. }, 1000);
  39. }
  40. }],
  41. store: Ext.create('Ext.data.TreeStore', {
  42. root: {
  43. text:'Online',
  44. expanded: true,
  45. children:[{
  46. text:'Friends',
  47. expanded:true,
  48. children:[
  49. { text:'Brian', iconCls:'user', leaf:true },
  50. { text:'Kevin', iconCls:'user', leaf:true },
  51. { text:'Mark', iconCls:'user', leaf:true },
  52. { text:'Matt', iconCls:'user', leaf:true },
  53. { text:'Michael', iconCls:'user', leaf:true },
  54. { text:'Mike Jr', iconCls:'user', leaf:true },
  55. { text:'Mike Sr', iconCls:'user', leaf:true },
  56. { text:'JR', iconCls:'user', leaf:true },
  57. { text:'Rich', iconCls:'user', leaf:true },
  58. { text:'Nige', iconCls:'user', leaf:true },
  59. { text:'Zac', iconCls:'user', leaf:true }
  60. ]
  61. },{
  62. text:'Family',
  63. expanded:true,
  64. children:[
  65. { text:'Kiana', iconCls:'user-girl', leaf:true },
  66. { text:'Aubrey', iconCls:'user-girl', leaf:true },
  67. { text:'Cale', iconCls:'user-kid', leaf:true }
  68. ]
  69. }]
  70. }
  71. })
  72. });
  73. return tree;
  74. },
  75. createWindow : function(){
  76. var desktop = this.app.getDesktop();
  77. var win = desktop.getWindow('acc-win');
  78. if (!win) {
  79. win = desktop.createWindow({
  80. id: 'acc-win',
  81. title: 'Accordion Window',
  82. width: 250,
  83. height: 400,
  84. iconCls: 'accordion',
  85. animCollapse: false,
  86. constrainHeader: true,
  87. bodyBorder: true,
  88. tbar: {
  89. xtype: 'toolbar',
  90. ui: 'plain',
  91. items: [{
  92. tooltip:{title:'Rich Tooltips', text:'Let your users know what they can do!'},
  93. iconCls:'connect'
  94. },
  95. '-',
  96. {
  97. tooltip:'Add a new user',
  98. iconCls:'user-add'
  99. },
  100. ' ',
  101. {
  102. tooltip:'Remove the selected user',
  103. iconCls:'user-delete'
  104. }]
  105. },
  106. layout: 'accordion',
  107. border: false,
  108. items: [
  109. this.createTree(),
  110. {
  111. title: 'Settings',
  112. html:'<p>Something useful would be in here.</p>',
  113. autoScroll:true
  114. },
  115. {
  116. title: 'Even More Stuff',
  117. html : '<p>Something useful would be in here.</p>'
  118. },
  119. {
  120. title: 'My Stuff',
  121. html : '<p>Something useful would be in here.</p>'
  122. }
  123. ]
  124. });
  125. }
  126. return win;
  127. }
  128. });