Reader/Feed.bjs
[web.Reader] / Reader / Feed.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Feed = new Roo.XComponent({
6
7  _strings : {
8   '8287b137f969bcae66ca51f7abf14308' :"Show Previously Read ",
9   'd9cd9f7b44e0493c9604e9f8fb7a6c07' :"Mark All Read",
10   'b7436cc90ecf26f15baeead978f09040' :"name of feed",
11   '83ca9a18d9507324a9453c92a7420dd2' :"Report Issue"
12  },
13
14   part     :  ["Reader", "Feed" ],
15   order    : '-Feed',
16   region   : 'center',
17   parent   : false,
18   name     : "unnamed module",
19   disabled : false, 
20   permname : '', 
21   _tree : function()
22   {
23    var _this = this;
24    var MODULE = this;
25    return {
26    xns : Roo.bootstrap,
27    '|xns' : 'Roo.bootstrap',
28    xtype : 'Body',
29    items  : [
30     {
31      html : _this._strings['b7436cc90ecf26f15baeead978f09040'] /* name of feed */,
32      style : 'font-weight: bold;\nfont-size: 22px;\n \nposition: absolute;\nleft: 100px;\ntop: 10px;\nz-Index: 1000;\ncolor: white;',
33      tag : 'div',
34      xns : Roo.bootstrap,
35      '|xns' : 'Roo.bootstrap',
36      xtype : 'Element'
37     },
38     {
39      brand : '<i class=\"fa fa-chevron-left\"></i> Feeds',
40      brand_href : baseURL + '/Feeds',
41      inverse : true,
42      position : 'fixed-top',
43      xns : Roo.bootstrap,
44      '|xns' : 'Roo.bootstrap',
45      xtype : 'NavHeaderbar',
46      items  : [
47       {
48        align : 'right',
49        xns : Roo.bootstrap,
50        '|xns' : 'Roo.bootstrap',
51        xtype : 'NavGroup',
52        items  : [
53         {
54          html : _this._strings['d9cd9f7b44e0493c9604e9f8fb7a6c07'] /* Mark All Read */,
55          xns : Roo.bootstrap,
56          '|xns' : 'Roo.bootstrap',
57          xtype : 'NavItem'
58         },
59         {
60          html : _this._strings['8287b137f969bcae66ca51f7abf14308'] /* Show Previously Read  */,
61          xns : Roo.bootstrap,
62          '|xns' : 'Roo.bootstrap',
63          xtype : 'NavItem'
64         },
65         {
66          html : _this._strings['83ca9a18d9507324a9453c92a7420dd2'] /* Report Issue */,
67          xns : Roo.bootstrap,
68          '|xns' : 'Roo.bootstrap',
69          xtype : 'NavItem'
70         }
71        ]
72       }
73      ]
74     },
75     {
76      hover : true,
77      responsive : true,
78      RowSelection : true,
79      striped : true,
80      style : 'margin-top:50px',
81      thead : false,
82      xns : Roo.bootstrap,
83      '|xns' : 'Roo.bootstrap',
84      xtype : 'Table',
85      listeners : {
86       render : function (_self)
87        {
88            _this.table = this;
89            this.store.load({});
90        },
91       rowclick : function (_self, el, rowIndex, e)
92        {
93            var rec = this.store.getAt(rowIndex);
94            Roo.log(rec);
95        }
96      },
97      store : {
98       remoteSort : true,
99       xns : Roo.data,
100       '|xns' : 'Roo.data',
101       xtype : 'Store',
102       listeners : {
103        beforeload : function (_self, o)
104         {
105             o.params = o.params || {};
106             o.params.feed = 83;
107         }
108       },
109       proxy : {
110        method : 'GET',
111        url : baseURL + '/Api/Reader_read',
112        xns : Roo.data,
113        '|xns' : 'Roo.data',
114        xtype : 'HttpProxy'
115       },
116       reader : {
117        fields : [
118                "id",
119                    "article_id",
120                    "has_read",
121                    "article_id_id" ,
122                    "article_id_published_dt" ,
123                    "article_id_headline" ,
124                    "article_id_body" ,
125                    "article_id_real_url" ,
126                    'article_id_body_txt'
127                ],
128        xns : Roo.data,
129        '|xns' : 'Roo.data',
130        xtype : 'JsonReader'
131       }
132      },
133      cm : [
134       {
135        dataIndex : 'article_id_headline',
136        renderer : function(v,x,r) {
137           
138           return String.format(
139                    '<h3>{0}</h3><small>{1}</small><i class="rss-list-body">{2}</i>' + 
140                        '{3}<i class="fa fa-chevron-right"></i>',
141                r.data.article_id_headline,
142                r.data.article_id_published_dt,
143                r.data.article_id_body_txt,
144                r.data.has_read * 1 ? '<span class="badge">Read</span>' : ''
145            );
146                    
147         
148         },
149        xns : Roo.grid,
150        '|xns' : 'Roo.grid',
151        xtype : 'ColumnModel'
152       }
153      ]
154     },
155     {
156      hidden : false,
157      loadArticle : function(pos) { 
158          
159      
160          if (pos < 0) {
161              Roo.MessageBox.alert("error", "show article got < 0");
162          }
163              
164          //    Roo.select('.hover-nav').show();
165          _this.table.hide(); // hopefully...
166          this.show();
167          
168          var rec = _this.store.getAt(pos);
169          if (typeof(rec.data.rss_body) == 'undefined') {
170      
171                  
172              new Pman.Request({
173                  method: 'GET',
174                  mask : 'Fetching Article',
175                  url : baseURL + '/FeedBody/' + id,
176                  success : function(res) {
177                      rec.data.rss_body = res.responseText;
178                      _this.article_ctr.showArticle(pos);
179                      
180                    
181                  }
182              });
183              return;
184              
185          }
186      
187          abody.update(rec.data.rss_body || "Body has not been loaded",false, function() {
188              //Roo.log("body loaded");
189              (function() { 
190                  var w = Roo.lib.Dom.getViewportWidth();
191      
192                  // resize the images... 
193                  Roo.select('img', true).each(function(im) {
194                      if (im.getWidth() > w) {
195                          var sf = w/im.getWidth()  
196                          im.setSize(w, im.getHeight() * sf);
197                      }
198                      
199                          
200                  });
201              }).defer(100);
202                  
203          });
204          // hide the summary...
205          
206          
207          
208          
209          
210          Roo.get(document.body).unmask();
211          
212          Roo.select('.rss-art-count').first().update((this.pos +1) +'/' + this.articles.elements.length);
213         
214          // flag it as read...
215          
216          Roo.Ajax.request({
217              method: 'GET',
218              url : baseURL + '/FeedBody/' + id,
219              params : { flag_read : 1 }, 
220              success : function(res) { },
221              scope : this
222          });
223          
224          Roo.select('.rss-list-article-' +id +
225                     ' .count').first().dom.innerHTML =  'Read';
226      
227          Roo.select('.rss-list-article-' +id).addClass('rss-list-article-read-status-1');
228          
229          Roo.select('.rss-list-article-' +id +
230                     ' .count').show();
231          
232          Roo.select('.rss-list-article-' +id +
233                     ' .count').first().dom.innerHTML =  'Read';
234      
235          Roo.select('.rss-list-article-' +id +
236                     ' .chevron').first().hide();
237          
238         
239              //Roo.select('header h2').first().dom.innerHTML = this.feed_title + ' - ' +
240              //        art.select('.rss-title').first().dom.innerH
241      },
242      xns : Roo.bootstrap,
243      '|xns' : 'Roo.bootstrap',
244      xtype : 'Element',
245      items  : [
246       {
247        cls : 'breadcrumb',
248        tag : 'ol',
249        xns : Roo.bootstrap,
250        '|xns' : 'Roo.bootstrap',
251        xtype : 'Element',
252        items  : [
253         {
254          cls : 'breadcrumb',
255          tag : 'li',
256          xns : Roo.bootstrap,
257          '|xns' : 'Roo.bootstrap',
258          xtype : 'Element'
259         }
260        ]
261       }
262      ]
263     }
264    ]
265   };  }
266 });