FeedDetail.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * @class FeedViewer.FeedDetail
  3. * @extends Ext.panel.Panel
  4. *
  5. * Shows the details of a particular feed
  6. *
  7. * @constructor
  8. * Create a new Feed Detail
  9. * @param {Object} config The config object
  10. */
  11. Ext.define('FeedViewer.FeedDetail', {
  12. extend: 'Ext.panel.Panel',
  13. alias: 'widget.feeddetail',
  14. border: false,
  15. initComponent: function(){
  16. this.display = Ext.create('widget.feedpost', {});
  17. Ext.apply(this, {
  18. layout: 'border',
  19. items: [this.createGrid(), this.createSouth(), this.createEast()]
  20. });
  21. this.relayEvents(this.display, ['opentab']);
  22. this.relayEvents(this.grid, ['rowdblclick']);
  23. this.callParent(arguments);
  24. },
  25. /**
  26. * Loads a feed.
  27. * @param {String} url
  28. */
  29. loadFeed: function(url){
  30. this.grid.loadFeed(url);
  31. },
  32. /**
  33. * Creates the feed grid
  34. * @private
  35. * @return {FeedViewer.FeedGrid} feedGrid
  36. */
  37. createGrid: function(){
  38. this.grid = Ext.create('widget.feedgrid', {
  39. region: 'center',
  40. dockedItems: [this.createTopToolbar()],
  41. flex: 2,
  42. minHeight: 200,
  43. minWidth: 150,
  44. listeners: {
  45. scope: this,
  46. select: this.onSelect
  47. }
  48. });
  49. this.loadFeed(this.url);
  50. return this.grid;
  51. },
  52. /**
  53. * Fires when a grid row is selected
  54. * @private
  55. * @param {FeedViewer.FeedGrid} grid
  56. * @param {Ext.data.Model} rec
  57. */
  58. onSelect: function(grid, rec) {
  59. this.display.setActive(rec);
  60. },
  61. /**
  62. * Creates top controller toolbar.
  63. * @private
  64. * @return {Ext.toolbar.Toolbar} toolbar
  65. */
  66. createTopToolbar: function(){
  67. this.toolbar = Ext.create('widget.toolbar', {
  68. cls: 'x-docked-noborder-top',
  69. items: [{
  70. iconCls: 'open-all',
  71. text: 'Open All',
  72. scope: this,
  73. handler: this.onOpenAllClick
  74. }, '-', {
  75. xtype: 'cycle',
  76. text: 'Reading Pane',
  77. prependText: 'Preview: ',
  78. showText: true,
  79. scope: this,
  80. changeHandler: this.readingPaneChange,
  81. menu: {
  82. id: 'reading-menu',
  83. items: [{
  84. text: 'Bottom',
  85. checked: true,
  86. iconCls:'preview-bottom'
  87. }, {
  88. text: 'Right',
  89. iconCls:'preview-right'
  90. }, {
  91. text: 'Hide',
  92. iconCls:'preview-hide'
  93. }]
  94. }
  95. }, {
  96. iconCls: 'summary',
  97. text: 'Summary',
  98. enableToggle: true,
  99. pressed: true,
  100. scope: this,
  101. toggleHandler: this.onSummaryToggle
  102. }]
  103. });
  104. return this.toolbar;
  105. },
  106. /**
  107. * Reacts to the open all being clicked
  108. * @private
  109. */
  110. onOpenAllClick: function(){
  111. this.fireEvent('openall', this);
  112. },
  113. /**
  114. * Gets a list of titles/urls for each feed.
  115. * @return {Array} The feed details
  116. */
  117. getFeedData: function(){
  118. return this.grid.store.getRange();
  119. },
  120. /**
  121. * @private
  122. * @param {Ext.button.Button} button The button
  123. * @param {Boolean} pressed Whether the button is pressed
  124. */
  125. onSummaryToggle: function(btn, pressed) {
  126. this.grid.getComponent('view').getPlugin('preview').toggleExpanded(pressed);
  127. },
  128. /**
  129. * Handle the checked item being changed
  130. * @private
  131. * @param {Ext.menu.CheckItem} item The checked item
  132. */
  133. readingPaneChange: function(cycle, activeItem){
  134. switch (activeItem.text) {
  135. case 'Bottom':
  136. this.east.hide();
  137. this.south.show();
  138. this.south.add(this.display);
  139. break;
  140. case 'Right':
  141. this.south.hide();
  142. this.east.show();
  143. this.east.add(this.display);
  144. break;
  145. default:
  146. this.south.hide();
  147. this.east.hide();
  148. break;
  149. }
  150. },
  151. /**
  152. * Create the south region container
  153. * @private
  154. * @return {Ext.panel.Panel} south
  155. */
  156. createSouth: function(){
  157. this.south = Ext.create('Ext.container.Container', {
  158. layout: 'fit',
  159. region: 'south',
  160. split: true,
  161. flex: 2,
  162. minHeight: 150,
  163. items: this.display
  164. });
  165. return this.south;
  166. },
  167. /**
  168. * Create the east region container
  169. * @private
  170. * @return {Ext.panel.Panel} east
  171. */
  172. createEast: function(){
  173. this.east = Ext.create('Ext.panel.Panel', {
  174. layout: 'fit',
  175. region: 'east',
  176. flex: 1,
  177. split: true,
  178. hidden: true,
  179. minWidth: 150,
  180. border: false
  181. });
  182. return this.east;
  183. }
  184. });