]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define("EnergyApp.view.Main", {\r |
2 | extend: "Ext.Panel",\r | |
3 | requires: ["EnergyApp.view.Navigation"],\r | |
4 | config: {\r | |
5 | id: "main",\r | |
6 | fullscreen: true,\r | |
7 | layout: 'fit',\r | |
8 | \r | |
9 | sheet: {\r | |
10 | hidden: true,\r | |
11 | enter: 'left',\r | |
12 | exit: 'left',\r | |
13 | hideOnMaskTap: true,\r | |
14 | zIndex: 400,\r | |
15 | layout: 'fit'\r | |
16 | },\r | |
17 | \r | |
18 | mainRegion: {\r | |
19 | layout: 'card'\r | |
20 | },\r | |
21 | \r | |
22 | launchScreen: {\r | |
23 | cls: 'launchscreen',\r | |
24 | scrollable: true,\r | |
25 | html: '<div>' +\r | |
26 | '<p><strong>This application visualizes US Energy data with charts from the Sencha Touch Charts package.</strong><br>' +\r | |
27 | 'Start by selecting consumption or production.</p>' +\r | |
28 | '</div>'\r | |
29 | },\r | |
30 | \r | |
31 | navigation: {\r | |
32 | width: 250,\r | |
33 | docked: 'left'\r | |
34 | },\r | |
35 | \r | |
36 | navigationButton: {\r | |
37 | id: "navigationButton",\r | |
38 | iconCls: 'x-fa fa-arrow-down',\r | |
39 | text: Ext.os.is.Phone ? "" : "Navigate",\r | |
40 | zIndex: 30\r | |
41 | },\r | |
42 | \r | |
43 | chartView: {\r | |
44 | xtype: 'chartview',\r | |
45 | id: 'chartView'\r | |
46 | },\r | |
47 | \r | |
48 | title: '',\r | |
49 | \r | |
50 | toolbar: {\r | |
51 | ui: 'dark',\r | |
52 | docked: 'top',\r | |
53 | items: [\r | |
54 | {\r | |
55 | iconCls: 'x-fa fa-arrow-left',\r | |
56 | id: 'prevButton',\r | |
57 | disabled: true,\r | |
58 | ui: 'back',\r | |
59 | align: 'left'\r | |
60 | },\r | |
61 | {\r | |
62 | iconCls: 'x-fa fa-arrow-right',\r | |
63 | id: 'nextButton',\r | |
64 | disabled: true,\r | |
65 | ui: 'forward',\r | |
66 | align: 'right'\r | |
67 | }\r | |
68 | ]\r | |
69 | },\r | |
70 | \r | |
71 | navigationDocked: true\r | |
72 | },\r | |
73 | \r | |
74 | updateNavigationDocked: function (docked) {\r | |
75 | var navigation = this.getNavigation(),\r | |
76 | navigationButton = this.getNavigationButton(),\r | |
77 | sheet = this.getSheet();\r | |
78 | \r | |
79 | if (docked) {\r | |
80 | sheet.hide(false);\r | |
81 | this.add(navigation);\r | |
82 | \r | |
83 | navigation.setConfig({\r | |
84 | docked: 'left',\r | |
85 | width: 250,\r | |
86 | height: null\r | |
87 | });\r | |
88 | } else {\r | |
89 | sheet.add(navigation);\r | |
90 | \r | |
91 | if (Ext.os.is.Phone) {\r | |
92 | sheet.setConfig({\r | |
93 | height: '80%'\r | |
94 | });\r | |
95 | }\r | |
96 | navigation.setConfig({\r | |
97 | width: Ext.os.is.Phone ? 220 : 250,\r | |
98 | height: Ext.os.is.Phone ? '100%' : 300\r | |
99 | });\r | |
100 | }\r | |
101 | \r | |
102 | navigation.show();\r | |
103 | \r | |
104 | if (navigationButton) {\r | |
105 | navigationButton.setHidden(docked);\r | |
106 | }\r | |
107 | },\r | |
108 | \r | |
109 | orientate: function (orientation) {\r | |
110 | var docked = Ext.os.deviceType !== 'Phone' && orientation === "landscape";\r | |
111 | this.setNavigationDocked(docked);\r | |
112 | },\r | |
113 | \r | |
114 | applyMainRegion: function (mainRegion, oldMainRegion) {\r | |
115 | return Ext.factory(mainRegion, "Ext.Panel", oldMainRegion);\r | |
116 | },\r | |
117 | \r | |
118 | updateMainRegion: function (mainRegion, oldMainRegion) {\r | |
119 | if (oldMainRegion) {\r | |
120 | this.remove(oldMainRegion);\r | |
121 | }\r | |
122 | if (mainRegion) {\r | |
123 | this.add(mainRegion);\r | |
124 | }\r | |
125 | },\r | |
126 | \r | |
127 | updateChartView: function (chartView, oldChartView) {\r | |
128 | if (oldChartView) {\r | |
129 | this.getMainRegion().add(oldChartView);\r | |
130 | }\r | |
131 | if (chartView) {\r | |
132 | this.getMainRegion().insert(1, chartView);\r | |
133 | }\r | |
134 | },\r | |
135 | \r | |
136 | applyLaunchScreen: function (launchScreen, oldLaunchScreen) {\r | |
137 | return Ext.factory(launchScreen, "Ext.Panel", oldLaunchScreen);\r | |
138 | },\r | |
139 | \r | |
140 | updateLaunchScreen: function (launchScreen, oldLaunchScreen) {\r | |
141 | if (oldLaunchScreen) {\r | |
142 | this.getMainRegion().remove(oldLaunchScreen);\r | |
143 | }\r | |
144 | if (launchScreen) {\r | |
145 | this.getMainRegion().add(launchScreen);\r | |
146 | }\r | |
147 | },\r | |
148 | \r | |
149 | applySheet: function (sheet, currentSheetInstance) {\r | |
150 | return Ext.factory(sheet, "Ext.Sheet", currentSheetInstance);\r | |
151 | },\r | |
152 | \r | |
153 | updateSheet: function (sheet, oldSheet) {\r | |
154 | if (oldSheet) {\r | |
155 | Ext.Viewport.remove(oldSheet);\r | |
156 | }\r | |
157 | if (sheet) {\r | |
158 | Ext.Viewport.add(sheet);\r | |
159 | }\r | |
160 | },\r | |
161 | \r | |
162 | applyNavigation: function (navigation, currentNavigationInstance) {\r | |
163 | return Ext.factory(navigation, "EnergyApp.view.Navigation", currentNavigationInstance);\r | |
164 | },\r | |
165 | \r | |
166 | updateNavigation: function (navigation, currentNavigationInstance) {\r | |
167 | if (currentNavigationInstance) {\r | |
168 | this.remove(currentNavigationInstance);\r | |
169 | }\r | |
170 | if (navigation) {\r | |
171 | this.add(navigation);\r | |
172 | }\r | |
173 | },\r | |
174 | \r | |
175 | applyNavigationButton: function (navigationButton, currentNavigationButtonInstance) {\r | |
176 | \r | |
177 | navigationButton = Ext.factory(navigationButton, "Ext.Button", currentNavigationButtonInstance);\r | |
178 | return navigationButton;\r | |
179 | },\r | |
180 | \r | |
181 | updateNavigationButton: function (navigationButton, currentNavigationButtonInstance) {\r | |
182 | if (currentNavigationButtonInstance) {\r | |
183 | this.getToolbar().remove(currentNavigationButtonInstance);\r | |
184 | }\r | |
185 | if (navigationButton) {\r | |
186 | this.getToolbar().add(navigationButton);\r | |
187 | }\r | |
188 | },\r | |
189 | \r | |
190 | updateTitle: function (title) {\r | |
191 | if (this.getToolbar()) {\r | |
192 | this.getToolbar().setTitle(title);\r | |
193 | }\r | |
194 | },\r | |
195 | \r | |
196 | applyToolbar: function (toolbar, currentToolbarInstance) {\r | |
197 | toolbar = Ext.factory(toolbar, "Ext.TitleBar", currentToolbarInstance);\r | |
198 | return toolbar;\r | |
199 | },\r | |
200 | \r | |
201 | updateToolbar: function (toolbar, oldToolbar) {\r | |
202 | if (oldToolbar) {\r | |
203 | this.getMainRegion().remove(oldToolbar);\r | |
204 | }\r | |
205 | if (toolbar) {\r | |
206 | this.getMainRegion().add(toolbar);\r | |
207 | }\r | |
208 | }\r | |
209 | });\r |