Project

General

Profile

Download (4.42 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / flarecast / workspace / client-public-3.0 / js / feedsReader / FeedGridFlux.js @ master

1
/***************************************
2
* Copyright 2010-2014 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
3
* 
4
* This file is part of SITools2.
5
* 
6
* SITools2 is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
* 
11
* SITools2 is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with SITools2.  If not, see <http://www.gnu.org/licenses/>.
18
***************************************/
19
/*global Ext, sitools, i18n,document, window, SitoolsDesk*/
20
Ext.namespace('sitools.public.feedsReader');
21

    
22
/**
23
 * @cfg {string} urlFeed The feed URL
24
 * @cfg {string} feedType the type of the feed ("atom_1.0" or "rss_2")
25
 * @cfg {string} feedSource the source of the feed (OPENSEARCH or CLASSIC)
26
 * @requires sitools.user.component.openSearchResultFeed
27
 */
28
Ext.define('sitools.public.feedsReader.FeedGridFlux', {
29
    extend : 'Ext.panel.Panel',
30
    alias : 'widget.appfeedgridflux',
31
    componentType : "feeds",
32
    border : false,
33
    bodyBorder : false,
34
    
35
    requires : ['sitools.public.feedsReader.AtomFeedReader',
36
                'sitools.public.feedsReader.RssFeedReader',
37
                'sitools.public.feedsReader.FeedItemDetails',
38
                ],
39
    
40
    initComponent : function () {
41

    
42
        this.layout = "fit";
43
        
44
        var gridPanel;
45
        if (this.feedSource !== undefined && this.feedSource === "OPENSEARCH") {
46
            gridPanel = Ext.create('sitools.user.view.component.datasets.opensearch.OpensearchResultFeedView', this);
47
        } else {
48
            
49
            if (this.feedType !== undefined && this.feedType === "atom_1.0") {
50
                gridPanel = Ext.create('sitools.public.feedsReader.AtomFeedReader', {
51
                    feedGrid : this
52
                });
53
            } else {
54
                gridPanel = Ext.create('sitools.public.feedsReader.RssFeedReader', {
55
                    feedGrid : this
56
                });
57
            }
58
        }
59

    
60
        this.btnSubscribeRss = Ext.create('Ext.button.Button', {
61
            text : i18n.get('label.subscribeRss'),
62
//            cls : 'services-toolbar-btn',
63
            cls : 'x-custom-button-color',
64
            icon : loadUrl.get('APP_URL') + '/client-public/common/res/images/icons/rss.png',
65
            handler : this.subscribeRss
66
         });
67
         
68
         this.bbar = {
69
             xtype : 'toolbar',
70
             cls : "services-toolbar", 
71
             defaults : {
72
                 scope : this
73
             },
74
             items : [ this.btnSubscribeRss ]
75
         };
76
        
77
        this.items = [ gridPanel ];
78

    
79
        this.callParent(arguments);
80
    },
81
    
82
    clickOnRow : function (self, rowIndex, e) {
83
        e.stopEvent();
84
        var rec = self.store.getAt(rowIndex);
85
        if (Ext.isEmpty(rec)) {
86
            return;
87
        }
88
        // si on est pas sur le bureau
89
        if (Ext.isEmpty(window) || Ext.isEmpty(window.SitoolsDesk)) {
90
            
91
            var component = Ext.create('sitools.public.feedsReader.FeedItemDetails', {
92
                record : rec
93
            });
94
            
95
            var win = Ext.create('Ext.window.Window', {
96
                stateful : false,
97
                title : i18n.get('label.viewFeedDetail'),
98
                width : 400,
99
                height : 600,
100
                shim : false,
101
                animCollapse : false,
102
                constrainHeader : true,
103
                layout : 'fit',
104
                modal : true
105
            });
106
            win.add(component);
107
            win.show();
108
        } else {
109
            var componentCfg = {
110
                record : rec
111
            };
112
            var jsObj = sitools.public.feedsReader.FeedItemDetails;
113

    
114
            var windowConfig = {
115
                id : "viewFeedDetail",
116
                title : i18n.get('label.viewFeedDetail'),
117
                saveToolbar : false
118
            };
119
            SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj, true);
120
        }
121
    },
122
    
123
    _getSettings : function () {
124
        return {
125
            objectName : "feedsReader"
126
        };
127
    },
128
    
129
    subscribeRss : function () {
130
        window.open(this.urlFeed, '_blank');
131
    }
132
});
133