1e854c9deed4f5de645c234a2ab8cb27a1926025
[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   '2efe14eb257ad32579ef6080d295c3af' :"<i class=\"fa fa-chevron-left\"></i> Name of feed",
9   '40c829f4b6cdd8753135704af571192f' :"articleURL",
10   '8287b137f969bcae66ca51f7abf14308' :"Show Previously Read ",
11   'd9cd9f7b44e0493c9604e9f8fb7a6c07' :"Mark All Read",
12   'b78a3223503896721cca1303f776159b' :"Title",
13   'b7436cc90ecf26f15baeead978f09040' :"name of feed",
14   '83ca9a18d9507324a9453c92a7420dd2' :"Report Issue",
15   '44749712dbec183e983dcd78a7736c41' :"Date"
16  },
17
18   part     :  ["Reader", "Feed" ],
19   order    : '-Feed',
20   region   : 'center',
21   parent   : false,
22   name     : "unnamed module",
23   disabled : false, 
24   permname : '', 
25   _tree : function()
26   {
27    var _this = this;
28    var MODULE = this;
29    return {
30    xns : Roo.bootstrap,
31    '|xns' : 'Roo.bootstrap',
32    xtype : 'Body',
33    items  : [
34     {
35      html : _this._strings['b7436cc90ecf26f15baeead978f09040'] /* name of feed */,
36      style : 'font-weight: bold;\nfont-size: 22px;\n \nposition: static;\nleft: 100px;\ntop: 10px;\nz-Index: 2000;\ncolor: white;',
37      tag : 'div',
38      xns : Roo.bootstrap,
39      '|xns' : 'Roo.bootstrap',
40      xtype : 'Element',
41      listeners : {
42       click : function (_self, e)
43        {
44          if (this.state == 'READING') { 
45            // flip to index...
46            }
47        }
48      }
49     },
50     {
51      inverse : true,
52      position : 'fixed-top',
53      xns : Roo.bootstrap,
54      '|xns' : 'Roo.bootstrap',
55      xtype : 'NavHeaderbar',
56      items  : [
57       {
58        align : 'right',
59        xns : Roo.bootstrap,
60        '|xns' : 'Roo.bootstrap',
61        xtype : 'NavGroup',
62        items  : [
63         {
64          html : _this._strings['d9cd9f7b44e0493c9604e9f8fb7a6c07'] /* Mark All Read */,
65          xns : Roo.bootstrap,
66          '|xns' : 'Roo.bootstrap',
67          xtype : 'NavItem'
68         },
69         {
70          html : _this._strings['8287b137f969bcae66ca51f7abf14308'] /* Show Previously Read  */,
71          xns : Roo.bootstrap,
72          '|xns' : 'Roo.bootstrap',
73          xtype : 'NavItem'
74         },
75         {
76          html : _this._strings['83ca9a18d9507324a9453c92a7420dd2'] /* Report Issue */,
77          xns : Roo.bootstrap,
78          '|xns' : 'Roo.bootstrap',
79          xtype : 'NavItem'
80         }
81        ]
82       },
83       {
84        href : '#',
85        html : _this._strings['2efe14eb257ad32579ef6080d295c3af'] /* <i class="fa fa-chevron-left"></i> Name of feed */,
86        xns : Roo.bootstrap,
87        '|xns' : 'Roo.bootstrap',
88        xtype : 'Link'
89       }
90      ]
91     },
92     {
93      hover : true,
94      responsive : true,
95      RowSelection : true,
96      striped : true,
97      style : 'margin-top:50px',
98      thead : false,
99      xns : Roo.bootstrap,
100      '|xns' : 'Roo.bootstrap',
101      xtype : 'Table',
102      listeners : {
103       render : function (_self)
104        {
105            _this.table = this;
106            this.store.load({});
107        },
108       rowclick : function (_self, el, rowIndex, e)
109        {
110            //var rec = this.store.getAt(rowIndex);
111           
112            _this.articleCtr.load(rowIndex);
113        }
114      },
115      store : {
116       remoteSort : true,
117       xns : Roo.data,
118       '|xns' : 'Roo.data',
119       xtype : 'Store',
120       listeners : {
121        beforeload : function (_self, o)
122         {
123             o.params = o.params || {};
124             o.params.feed = 83;
125         }
126       },
127       proxy : {
128        method : 'GET',
129        url : baseURL + '/Api/Reader_read',
130        xns : Roo.data,
131        '|xns' : 'Roo.data',
132        xtype : 'HttpProxy'
133       },
134       reader : {
135        fields : [
136                "id",
137                    "article_id",
138                    "has_read",
139                    "article_id_id" ,
140                    "article_id_published_dt" ,
141                    "article_id_headline" ,
142                    "article_id_body" ,
143                    "article_id_real_url" ,
144                    'article_id_body_txt'
145                ],
146        xns : Roo.data,
147        '|xns' : 'Roo.data',
148        xtype : 'JsonReader'
149       }
150      },
151      cm : [
152       {
153        dataIndex : 'article_id_headline',
154        renderer : function(v,x,r) {
155           
156           return String.format(
157                    '<h3>{0}</h3><small>{1}</small><i class="rss-list-body">{2}</i>' + 
158                        '{3}<i class="fa fa-chevron-right"></i>',
159                r.data.article_id_headline,
160                r.data.article_id_published_dt,
161                r.data.article_id_body_txt,
162                r.data.has_read * 1 ? '<span class="badge">Read</span>' : ''
163            );
164                    
165         
166         },
167        xns : Roo.grid,
168        '|xns' : 'Roo.grid',
169        xtype : 'ColumnModel'
170       }
171      ]
172     },
173     {
174      hidden : false,
175      id : '',
176      load : function(pos) { 
177          
178      
179          if (pos < 0) {
180              Roo.MessageBox.alert("error", "show article got < 0");
181          }
182              
183          //    Roo.select('.hover-nav').show();
184          _this.table.hide(); // hopefully...
185          this.show();
186          
187          var rec = _this.table.store.getAt(pos);
188          if (typeof(rec.data.rss_body) == 'undefined') {
189      
190                  
191              new Pman.Request({
192                  method: 'GET',
193                  mask : 'Fetching Article',
194                  params : {as_json : 1} ,
195                  url : baseURL + '/FeedBody/' + rec.data.id,
196                  success : function(res) {
197                      Roo.log(res);
198                      rec.data.rss_body = res.data;
199                      _this.articleCtr.load(pos);
200                      
201                    
202                  }
203              });
204              return;
205              
206          }
207          
208          _this.articleDate.el.update(rec.data.article_id_published_dt.split(' ')[0]);
209      
210          _this.articleURL.el.update(String.format('<a href="{0}">{1}</a>',
211                  rec.data.article_id_real_url,
212                  rec.data.article_id_real_url.split('/')[2] // hopefull will not break.!
213           ));
214           _this.articleTitle.el.update(String.format('{0}', rec.data.article_id_headline));
215          
216          _this.articleBody.el.update(rec.data.rss_body || "Body has not been loaded",false, function() {
217              //Roo.log("body loaded");
218              (function() { 
219                  var w = Roo.lib.Dom.getViewportWidth();
220      
221                  // resize the images... 
222                  _this.articleBody.el.select('img', true).each(function(im) {
223                      if (im.getWidth() > w) {
224                          var sf = w/im.getWidth()  
225                          im.setSize(w, im.getHeight() * sf);
226                      }
227                      
228                          
229                  });
230              }).defer(100);
231                  
232          });
233          // hide the summary...
234          
235          
236          
237          
238          
239          //Roo.get(document.body).unmask();
240          
241          //Roo.select('.rss-art-count').first().update((this.pos +1) +'/' + this.articles.elements.length);
242         
243          // flag it as read...
244          
245          new Pman.Request({
246              method: 'GET',
247              url : baseURL + '/FeedBody/' + rec.data.id,
248              params : { flag_read : 1 }, 
249              success : function(res) { }
250          });
251          rec.set('has_read', 1);
252              
253          //Roo.select('.rss-list-article-' +id +
254          //           ' .count').show();
255          
256          //Roo.select('.rss-list-article-' +id +
257          //           ' .count').first().dom.innerHTML =  'Read';
258      
259          //Roo.select('.rss-list-article-' +id +
260          //           ' .chevron').first().hide();
261          
262         
263              //Roo.select('header h2').first().dom.innerHTML = this.feed_title + ' - ' +
264              //        art.select('.rss-title').first().dom.innerH
265      },
266      xns : Roo.bootstrap,
267      '|xns' : 'Roo.bootstrap',
268      xtype : 'Element',
269      listeners : {
270       render : function (_self)
271        {
272          _this.articleCtr = this;
273        }
274      },
275      items  : [
276       {
277        cls : 'breadcrumb',
278        style : 'margin-top:50px;',
279        tag : 'ol',
280        xns : Roo.bootstrap,
281        '|xns' : 'Roo.bootstrap',
282        xtype : 'Element',
283        items  : [
284         {
285          html : _this._strings['44749712dbec183e983dcd78a7736c41'] /* Date */,
286          tag : 'li',
287          xns : Roo.bootstrap,
288          '|xns' : 'Roo.bootstrap',
289          xtype : 'Element',
290          listeners : {
291           render : function (_self)
292            {
293              _this.articleDate  = this;
294            }
295          }
296         },
297         {
298          html : _this._strings['40c829f4b6cdd8753135704af571192f'] /* articleURL */,
299          tag : 'li',
300          xns : Roo.bootstrap,
301          '|xns' : 'Roo.bootstrap',
302          xtype : 'Element',
303          listeners : {
304           render : function (_self)
305            {
306              _this.articleURL  = this;
307            }
308          }
309         },
310         {
311          cls : 'active',
312          html : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
313          tag : 'li',
314          xns : Roo.bootstrap,
315          '|xns' : 'Roo.bootstrap',
316          xtype : 'Element',
317          listeners : {
318           render : function (_self)
319            {
320            _this.articleTitle = this;
321            }
322          }
323         }
324        ]
325       },
326       {
327        xns : Roo.bootstrap,
328        '|xns' : 'Roo.bootstrap',
329        xtype : 'Container',
330        listeners : {
331         render : function (_self)
332          {
333            _this.articleBody = this;
334          }
335        }
336       }
337      ]
338     }
339    ]
340   };  }
341 });