4 Reader.SubscriptionPanel = Ext.extend(Ext.Panel, {
5 constructor: function(application, config) {
6 this.application = application;
9 var listView = this.listView = new Ext.list.ListView({
10 emptyText: 'No Subscriptions',
11 store: this.application.subscription_store,
26 loadingText: 'Loading...',
29 Reader.SubscriptionPanel.superclass.constructor.call(this, Ext.applyIf(config||{}, {
30 title: 'Subscriptions',
37 iconCls: 'icon-add-feed',
39 Ext.MessageBox.prompt('Add Feed', 'Enter the URL to the feed:', function(button, text) {
42 url: '{% url reader_add_subscription %}',
45 'csrfmiddlewaretoken': '{% with csrf_token as csrf_token_clean %}{{ csrf_token_clean }}{% endwith %}',
48 self.application.subscription_store.reload();
51 alert('Unable to add feed.');
60 self.application.subscription_store.reload();
67 listView.on('selectionchange', function(listView, selections) {
68 if (selections.length > 0) {
69 self.application.selected_subscription(listView.getSelectedRecords()[0]['data']);
76 Reader.EntryPanel = Ext.extend(Ext.Panel, {
77 constructor: function(application, config) {
78 this.application = application;
81 var gridView = this.gridView = new Ext.grid.GridPanel({
82 store: this.application.entry_store,
96 sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
104 var entryDetailTpl = this.entryDetailTpl = new Ext.Template(
105 '<h1><a href="{link}" target="_blank">{title}</a></h1>',
106 '<p style="font-size: smaller;">{date}</p>',
110 var entryDetail = this.entryDetail = {
118 preventBodyReset: true,
119 html: 'Select an entry to view',
123 gridView.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {
124 var detailPanel = Ext.getCmp('entryDetail');
125 entryDetailTpl.overwrite(detailPanel.body, r.data);
128 url: '{% url reader_read_entry %}',
130 'entry_id': r.data['id'],
131 'csrfmiddlewaretoken': '{% with csrf_token as csrf_token_clean %}{{ csrf_token_clean }}{% endwith %}',
133 success: function() {
134 self.application.subscription_store.reload();
136 failure: function() {
137 console.log('Unable to set read entry');
142 Reader.EntryPanel.superclass.constructor.call(this, Ext.applyIf(config||{}, {
145 items: [ this.gridView, this.entryDetail ],
152 Reader.Application = Ext.extend(Ext.util.Observable, {
153 constructor: function(config) {
154 Ext.apply(this, config, {
155 renderTo: Ext.getBody(),
157 Reader.Application.superclass.constructor.call(this);
161 Ext.QuickTips.init();
163 var subscription_store = this.subscription_store = new Ext.data.JsonStore({
166 url: '{% url reader_get_subscriptions %}',
168 totalProperty: 'len',
176 var entry_store = this.entry_store = new Ext.data.JsonStore({
177 url: '{% url reader_get_entries %}',
179 'subscription_id': '-2',
180 'csrfmiddlewaretoken': '{% with csrf_token as csrf_token_clean %}{{ csrf_token_clean }}{% endwith %}',
183 totalProperty: 'len',
185 'id', 'title', 'date', 'content', 'link'
189 var subscription_panel = this.subscription_panel = new Reader.SubscriptionPanel(this, {
196 var entry_panel = this.entry_panel = new Reader.EntryPanel(this, {
200 var viewport = this.viewport = new Ext.Viewport({
202 renderTo: this.renderTo,
204 this.subscription_panel,
209 this.viewport.doLayout();
211 selected_subscription: function(subscription) {
212 this.entry_panel.setTitle(subscription['title']);
213 this.entry_store.reload({ params: {
214 'subscription_id': subscription['id'],