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 : true,
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();    
166              var sum = Roo.select('.rss-list',true).first();
167              if (!sum) {
168                  return; // we are not on a show article page...
169              
170              }
171              sum.setVisibilityMode(Roo.Element.DISPLAY);
172              sum.hide()
173      
174              Roo.log('showArticle ' + pos);
175              
176              var art;
177              if (this.pos !== false) {
178                  
179                  // feed or list..
180                  
181                  art = this.articles.elements[this.pos];
182                  art.hide();
183                  //this.showArticle(pos);
184                  //this.showArticle.defer(500,this,[pos]);
185                  //return;
186              }
187              
188              
189              this.pos = pos;
190              var art = this.articles.elements[this.pos];
191              art.show(true);
192               var id = art.id.replace(/article\-/,'');
193              
194              // load the body!?
195              var abody  = art.select('.rss-body-preview',true).first();
196              Roo.select('.content').first().dom.scrollTop= 0;
197              if (typeof(art.rss_body) == 'undefined') {
198                  
199                  Roo.Ajax.request({
200                      method: 'GET',
201                      mask : 'Fetching Article',
202                      url : baseURL + '/FeedBody/' + id,
203                      success : function(res) {
204                          art.rss_body = res.responseText;
205                          Rss.showArticle(pos);
206                          
207                        
208                      },
209                      scope : this
210                  });
211                  return;
212                  
213              }
214          
215              abody.update(art.rss_body || "Body has not been loaded",false, function() {
216                  //Roo.log("body loaded");
217                  (function() { 
218                      var w = Roo.lib.Dom.getViewportWidth();
219          
220                      Roo.select('img', true).each(function(im) {
221                          if (im.getWidth() > w) {
222                              var sf = w/im.getWidth()  
223                              im.setSize(w, im.getHeight() * sf);
224                          }
225                          
226                              
227                      });
228                  }).defer(100);
229                      
230              });
231              // hide the summary...
232              
233              
234              
235              
236              
237              Roo.get(document.body).unmask();
238              
239              Roo.select('.rss-art-count').first().update((this.pos +1) +'/' + this.articles.elements.length);
240             
241              // flag it as read...
242              
243              Roo.Ajax.request({
244                  method: 'GET',
245                  url : baseURL + '/FeedBody/' + id,
246                  params : { flag_read : 1 }, 
247                  success : function(res) { },
248                  scope : this
249              });
250              
251              Roo.select('.rss-list-article-' +id +
252                         ' .count').first().dom.innerHTML =  'Read';
253      
254              Roo.select('.rss-list-article-' +id).addClass('rss-list-article-read-status-1');
255              
256              Roo.select('.rss-list-article-' +id +
257                         ' .count').show();
258              
259              Roo.select('.rss-list-article-' +id +
260                         ' .count').first().dom.innerHTML =  'Read';
261      
262              Roo.select('.rss-list-article-' +id +
263                         ' .chevron').first().hide();
264              
265             
266              //Roo.select('header h2').first().dom.innerHTML = this.feed_title + ' - ' +
267              //        art.select('.rss-title').first().dom.innerH
268      },
269      xns : Roo.bootstrap,
270      '|xns' : 'Roo.bootstrap',
271      xtype : 'Container'
272     }
273    ]
274   };  }
275 });