cd999f5f025334d438573f18336141cba182e4e5
[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           return String.format(
169                    '<h3>{0}</h3><small>{1}</small><i class="rss-list-body">{2}</i>' + 
170                        '{3}<i class="fa fa-chevron-right"></i>',
171                r.data.article_id_headline,
172                r.data.article_id_published_dt,
173                r.data.article_id_body_txt,
174                r.data.has_read * 1 ? '<span class="badge">Read</span>' : ''
175            );
176                    
177         
178         },
179        xns : Roo.grid,
180        '|xns' : 'Roo.grid',
181        xtype : 'ColumnModel'
182       }
183      ]
184     },
185     {
186      hidden : false,
187      id : 'articleCtr',
188      load : function(pos) { 
189          
190      
191          if (pos < 0) {
192              Roo.MessageBox.alert("error", "show article got < 0");
193          }
194              
195          //    Roo.select('.hover-nav').show();
196          _this.table.hide(); // hopefully...
197          this.show();
198          
199          var rec = _this.table.store.getAt(pos);
200          if (typeof(rec.data.rss_body) == 'undefined') {
201      
202                  
203              new Pman.Request({
204                  method: 'GET',
205                  mask : 'Fetching Article',
206                  params : {as_json : 1} ,
207                  url : baseURL + '/FeedBody/' + rec.data.id,
208                  success : function(res) {
209                      Roo.log(res);
210                      rec.data.rss_body = res.data;
211                      _this.articleCtr.load(pos);
212                      
213                    
214                  }
215              });
216              return;
217              
218          }
219          
220          _this.articleDate.el.update(rec.data.article_id_published_dt.split(' ')[0]);
221      
222          _this.articleURL.el.update(String.format('<a href="{0}">{1}</a>',
223                  rec.data.article_id_real_url,
224                  rec.data.article_id_real_url.split('/')[2] // hopefull will not break.!
225           ));
226           _this.articleTitle.el.update(String.format('{0}', rec.data.article_id_headline));
227          
228          _this.articleBody.el.update(rec.data.rss_body || "Body has not been loaded",false, function() {
229              //Roo.log("body loaded");
230              (function() { 
231                  var w = Roo.lib.Dom.getViewportWidth();
232      
233                  // resize the images... 
234                  _this.articleBody.el.select('img', true).each(function(im) {
235                      if (im.getWidth() > w) {
236                          var sf = w/im.getWidth()  
237                          im.setSize(w, im.getHeight() * sf);
238                      }
239                      
240                          
241                  });
242              }).defer(100);
243                  
244          });
245          // hide the summary...
246          
247          
248          
249          
250          
251          //Roo.get(document.body).unmask();
252          
253          //Roo.select('.rss-art-count').first().update((this.pos +1) +'/' + this.articles.elements.length);
254         
255          // flag it as read...
256          
257          new Pman.Request({
258              method: 'GET',
259              url : baseURL + '/FeedBody/' + rec.data.id,
260              params : { flag_read : 1 }, 
261              success : function(res) { }
262          });
263          rec.set('has_read', 1);
264              
265          //Roo.select('.rss-list-article-' +id +
266          //           ' .count').show();
267          
268          //Roo.select('.rss-list-article-' +id +
269          //           ' .count').first().dom.innerHTML =  'Read';
270      
271          //Roo.select('.rss-list-article-' +id +
272          //           ' .chevron').first().hide();
273          
274         
275              //Roo.select('header h2').first().dom.innerHTML = this.feed_title + ' - ' +
276              //        art.select('.rss-title').first().dom.innerH
277      },
278      xns : Roo.bootstrap,
279      '|xns' : 'Roo.bootstrap',
280      xtype : 'Element',
281      listeners : {
282       render : function (_self)
283        {
284          _this.articleCtr = this;
285        }
286      },
287      items  : [
288       {
289        cls : 'breadcrumb',
290        style : 'margin-top:50px;',
291        tag : 'ol',
292        xns : Roo.bootstrap,
293        '|xns' : 'Roo.bootstrap',
294        xtype : 'Element',
295        items  : [
296         {
297          html : _this._strings['44749712dbec183e983dcd78a7736c41'] /* Date */,
298          tag : 'li',
299          xns : Roo.bootstrap,
300          '|xns' : 'Roo.bootstrap',
301          xtype : 'Element',
302          listeners : {
303           render : function (_self)
304            {
305              _this.articleDate  = this;
306            }
307          }
308         },
309         {
310          html : _this._strings['40c829f4b6cdd8753135704af571192f'] /* articleURL */,
311          tag : 'li',
312          xns : Roo.bootstrap,
313          '|xns' : 'Roo.bootstrap',
314          xtype : 'Element',
315          listeners : {
316           render : function (_self)
317            {
318              _this.articleURL  = this;
319            }
320          }
321         },
322         {
323          cls : 'active',
324          html : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
325          tag : 'li',
326          xns : Roo.bootstrap,
327          '|xns' : 'Roo.bootstrap',
328          xtype : 'Element',
329          listeners : {
330           render : function (_self)
331            {
332            _this.articleTitle = this;
333            }
334          }
335         }
336        ]
337       },
338       {
339        xns : Roo.bootstrap,
340        '|xns' : 'Roo.bootstrap',
341        xtype : 'Container',
342        listeners : {
343         render : function (_self)
344          {
345            _this.articleBody = this;
346          }
347        }
348       }
349      ]
350     }
351    ]
352   };  }
353 });