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