Project

General

Profile

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

git_sitools_idoc / flarecast / workspace / client-user-3.0 / app / controller / footer / FooterController.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 it under the
7
 * terms of the GNU General Public License as published by the Free Software
8
 * Foundation, either version 3 of the License, or (at your option) any later
9
 * version.
10
 * 
11
 * SITools2 is distributed in the hope that it will be useful, but WITHOUT ANY
12
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14
 * 
15
 * You should have received a copy of the GNU General Public License along with
16
 * SITools2. If not, see <http://www.gnu.org/licenses/>.
17
 ******************************************************************************/
18

    
19
/**
20
 * Populate the div x-headers of the sitools Desktop.
21
 * 
22
 * @cfg {String} htmlContent html content of the headers,
23
 * @cfg {Array} modules the modules list
24
 * @class sitools.user.component.entete.Entete
25
 * @extends Ext.Panel
26
 */
27
Ext.define("sitools.user.controller.footer.FooterController", {
28

    
29
    extend : 'Ext.app.Controller',
30

    
31
    views : ['footer.FooterView'],
32
    
33
    config : {
34
            FooterView : null
35
    },
36

    
37
    heightNormalMode : 0,
38
    heightMaximizeDesktopMode : 0,
39
    
40
    statics : {
41
        showFooterLink : function (url, linkName) {
42
//            var windowConfig = {
43
//                title : i18n.get(linkName),
44
//                id : linkName,
45
//                iconCls : "version"
46
//            };
47
//
48
//            var jsObj = Ext.ux.ManagedIFrame.Panel;
49
//            var componentCfg = {
50
//                defaults : {
51
//                    padding : 10
52
//                },
53
//                layout : 'fit',
54
//                region : 'center',
55
//                defaultSrc : url
56
//            };
57
//
58
//            SitoolsDesk.addDesktopWindow(windowConfig, componentCfg, jsObj);
59
            
60
            alert("todo open window with link " + url + " with name : " + linkName);
61
        }
62
    },
63

    
64
    init : function () {
65
        
66
        this.getApplication().on('headerLoaded', this.onProjectLoaded, this);
67

    
68
        Ext.create('Ext.data.Store', {
69
            fields : [ 'name', 'url' ],
70
            storeId : 'linkStore'
71
        });
72
        
73
        this.control({
74
            'container#leftPanel' : {
75
                afterrender : function (panel) {
76
                    Ext.get("sitools_logo").on('load', function () {
77
                        Ext.get("sitools_logo").alignTo(panel.getEl(), "c-c", [ -60, 2 ]);
78
                    }, this);
79
                }
80
            },
81
            'panel#footer' : {
82
                afterrender : function (me) {
83
                    if (!me.defaultBottom) {
84
                        me.setHeight(0);
85
                    } else {
86
                        Ext.Ajax.request({
87
                            url : this.versionUrl,
88
                            method : 'GET',
89
                            scope : this,
90
                            success : function (ret) {
91
                                var json = Ext.decode(ret.responseText);
92
                                if (!json.success) {
93
                                    Ext.Msg.alert(i18n.get('label.warning'), json.message);
94
                                    return false;
95
                                }
96
                                var info = json.info;
97

    
98
                                var copyright = info.copyright;
99

    
100
                                me.down('label#credits').setText(Ext.String.format(i18n.get("label.build_by_sitools2"), copyright), false);
101

    
102
                                var bottomEl = Ext.get(me.renderTo);
103
                                me.setHeight(bottomEl.getHeight());
104
                                me.heightNormalMode = bottomEl.getHeight();
105
                                
106

    
107
                            }
108
                        });
109
                    }
110

    
111
                },
112
                resize : function (me) {
113
                    if (!me.defaultBottom) {
114
                        me.setHeight(0);
115
                    } else {
116
                        me.setSize(Ext.get(me.renderTo).getSize());
117
                        Ext.get("sitools_logo").alignTo(me.down('container#leftPanel').getEl(), "c-c");
118
                        me.down("panel#sitools_build_by").alignTo(me.down('panel#middlePanel').getEl(), "c-c");
119

    
120
                        var fr = Ext.get("sitools_footer_right");
121
                        if (Ext.isDefined(fr) && !Ext.isEmpty(fr)) {
122
                            fr.alignTo(me.down('panel#rightPanel').getEl(), "c-c");
123
                        }
124
                    }
125
                },
126
                maximizeDesktop : this.onMaximizeDesktop,
127
                minimizeDesktop : this.onMinimizeDesktop
128
            }
129
        });
130
        
131
        this.callParent(arguments);
132
    },
133
    
134
    onProjectLoaded : function () {
135
        this.fillLinks();
136
        this.versionUrl = loadUrl.get('APP_URL') + '/version';
137

    
138
        if (Desktop.getBottomEl().getHeight() != 0) {
139
            this.FooterView = Ext.create('sitools.user.view.footer.FooterView', {});
140
        }
141

    
142
        this.getApplication().fireEvent('footerLoaded');
143
    },
144
    
145
    onMaximizeDesktop : function () {
146
            var footerView = this.getFooterView();
147

    
148
        if (Ext.isEmpty(footerView)) {
149
            return;
150
        }
151

    
152
        this.getFooterView().container.setHeight(0);
153
        this.getFooterView().hide();
154
    },
155
    
156
    onMinimizeDesktop : function () {
157
            var footerView = this.getFooterView();
158

    
159
        if (Ext.isEmpty(footerView)) {
160
            return;
161
        }
162

    
163
            footerView.container.dom.style.height = "";
164
            footerView.setSize(Desktop.getBottomEl().getSize());
165
            footerView.show();
166
    },
167
    
168
    fillLinks : function () {
169
        var project = Ext.getStore('ProjectStore').getAt(0);
170
        var projectLinks = project.links();
171
        var linkStore = Ext.getStore('linkStore');
172
        projectLinks.each(function (link) {
173
            linkStore.add(link);
174
        }, this);
175
    }
176
});