132 }, false); |
132 }, false); |
133 window.addEventListener("scroll", function(){ |
133 window.addEventListener("scroll", function(){ |
134 self.updateScrollbar(); |
134 self.updateScrollbar(); |
135 }, false); |
135 }, false); |
136 } |
136 } |
137 } |
137 }; |
138 |
138 |
139 // Returns the current view. |
139 // Returns the current view. |
140 UIManager.prototype.getView = function() { |
140 UIManager.prototype.getView = function() { |
141 return this.currentView; |
141 return this.currentView; |
142 } |
142 }; |
143 |
143 |
144 // Switches to the specified view. |
144 // Switches to the specified view. |
145 UIManager.prototype.setView = function(view) { |
145 UIManager.prototype.setView = function(view) { |
146 uiLogger.debug("View set to " + view.id); |
146 uiLogger.debug("View set to " + view.id); |
147 |
147 |
166 } |
166 } |
167 |
167 |
168 // focus the first focusable control |
168 // focus the first focusable control |
169 // a timer is used to prevent unwanted focus shift |
169 // a timer is used to prevent unwanted focus shift |
170 setTimeout(function() { view.focusFirstControl(); }, 1); |
170 setTimeout(function() { view.focusFirstControl(); }, 1); |
171 } |
171 }; |
172 |
172 |
173 // Updates the scrollbar. |
173 // Updates the scrollbar. |
174 UIManager.prototype.updateScrollbar = function() { |
174 UIManager.prototype.updateScrollbar = function() { |
175 if (this.enableScrollBar) { |
175 if (this.enableScrollBar) { |
176 // get current viewport and document position and dimensions |
176 // get current viewport and document position and dimensions |
190 // update the scrollbar |
190 // update the scrollbar |
191 this.scrollbar.update(scrollY, viewportHeight, documentHeight); |
191 this.scrollbar.update(scrollY, viewportHeight, documentHeight); |
192 uiLogger.debug("Scrollbar updated"); |
192 uiLogger.debug("Scrollbar updated"); |
193 } |
193 } |
194 } |
194 } |
195 } |
195 }; |
196 |
196 |
197 // Starts the view manager timer. |
197 // Starts the view manager timer. |
198 UIManager.prototype.startTimer = function() { |
198 UIManager.prototype.startTimer = function() { |
199 if (this.timerId == null) { |
199 if (this.timerId == null) { |
200 uiLogger.debug("UIManager timer started"); |
200 uiLogger.debug("UIManager timer started"); |
202 // setup the timer |
202 // setup the timer |
203 this.timerId = setInterval(function() { self.onTimer(); }, this.TIMER_INTERVAL); |
203 this.timerId = setInterval(function() { self.onTimer(); }, this.TIMER_INTERVAL); |
204 } else { |
204 } else { |
205 uiLogger.warn("UIManager timer already running"); |
205 uiLogger.warn("UIManager timer already running"); |
206 } |
206 } |
207 } |
207 }; |
208 |
208 |
209 // Stops the view manager timer. |
209 // Stops the view manager timer. |
210 UIManager.prototype.stopTimer = function() { |
210 UIManager.prototype.stopTimer = function() { |
211 if (this.timerId != null) { |
211 if (this.timerId != null) { |
212 // stop the timer |
212 // stop the timer |
213 clearTimeout(this.timerId); |
213 clearTimeout(this.timerId); |
214 this.timerId = null; |
214 this.timerId = null; |
215 } else { |
215 } else { |
216 uiLogger.warn("UIManager timer already stopped"); |
216 uiLogger.warn("UIManager timer already stopped"); |
217 } |
217 } |
218 } |
218 }; |
219 |
219 |
220 // Timer callback function. |
220 // Timer callback function. |
221 UIManager.prototype.onTimer = function() { |
221 UIManager.prototype.onTimer = function() { |
222 if (this.enableScrollBar) { |
222 if (this.enableScrollBar) { |
223 // make sure the scrollbar is up to date |
223 // make sure the scrollbar is up to date |
224 this.updateScrollbar(); |
224 this.updateScrollbar(); |
225 } |
225 } |
226 } |
226 }; |
227 |
227 |
228 // Displays a notification. |
228 // Displays a notification. |
229 UIManager.prototype.showNotification = function(displayTime, type, text, progress) { |
229 UIManager.prototype.showNotification = function(displayTime, type, text, progress) { |
230 uiLogger.debug("UIManager.showNotification(" + displayTime + ", " + type + ", " + text + ", " + progress + ")"); |
230 uiLogger.debug("UIManager.showNotification(" + displayTime + ", " + type + ", " + text + ", " + progress + ")"); |
231 // use the notification popup to show the notification |
231 // use the notification popup to show the notification |
232 this.notificationPopup.showNotification(displayTime, type, text, progress); |
232 this.notificationPopup.showNotification(displayTime, type, text, progress); |
233 } |
233 }; |
234 |
234 |
235 // Hides the currently displayed notification. |
235 // Hides the currently displayed notification. |
236 UIManager.prototype.hideNotification = function() { |
236 UIManager.prototype.hideNotification = function() { |
237 uiLogger.debug("UIManager.hideNotification()"); |
237 uiLogger.debug("UIManager.hideNotification()"); |
238 // hide the notification popup |
238 // hide the notification popup |
239 this.notificationPopup.hideNotification(); |
239 this.notificationPopup.hideNotification(); |
240 } |
240 }; |