22 xCenterOffset; |
43 xCenterOffset; |
23 yOffset = -anchoredGeom.height - yBotGap; |
44 yOffset = -anchoredGeom.height - yBotGap; |
24 return([xOffset,yOffset]); |
45 return([xOffset,yOffset]); |
25 } |
46 } |
26 |
47 |
|
48 function hidePopups(){ |
|
49 |
|
50 if (window.snippets.MostVisitedViewId.isVisible()) |
|
51 window.snippets.MostVisitedViewId.hide(); |
|
52 |
|
53 if (window.snippets.SuggestsChromeId.isVisible()) { |
|
54 window.snippets.SuggestsChromeId.hide(false); |
|
55 views.WebView.enabled = true; |
|
56 views.WebView.unfreeze(); |
|
57 } |
|
58 |
|
59 if(app.ui() != "maemo5_ui") |
|
60 return; |
|
61 |
|
62 snippets.BookmarkDialogId.hide(); |
|
63 } |
|
64 |
27 // Display the super-page with the given name and path. |
65 // Display the super-page with the given name and path. |
28 function showSuperPage(pageName, path) { |
66 function showSuperPage(pageName, path) { |
29 |
67 |
30 if (window.views.WebView[pageName] == undefined) { |
68 if (window.views.WebView[pageName] == undefined) { |
31 window.views.WebView.createSuperPage(pageName, true); |
69 window.views.WebView.createSuperPage(pageName, true); |
32 window.views.WebView[pageName].load(chrome.baseDirectory + path); |
70 window.views.WebView[pageName].load(/*chrome.baseDirectory +*/ path); |
33 } |
71 } |
|
72 else { |
|
73 // FIXME: this is a workaround temporary solution |
|
74 // this is used to render CSS styles for super pages |
|
75 // instead of just popping them up from ViewStack which somehow prevent proper CSS styling on page display |
|
76 window.views.WebView[pageName].load(path); |
|
77 } |
|
78 |
34 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()){ |
79 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()){ |
35 window.views.WebView.setSavedZoomValueInView(window.views.WebView.zoomFactor); |
80 window.views.WebView.setSavedZoomValueInView(window.views.WebView.zoomFactor); |
36 window.views.WebView.zoomFactor = 1.0; |
81 window.views.WebView.zoomFactor = 1.0; |
37 } |
82 } |
38 //window.views.WebView.showSuperPage(pageName); |
83 //window.views.WebView.showSuperPage(pageName); |
39 window.ViewStack.switchView(pageName, "WebView"); |
84 window.ViewStack.switchView(pageName, "WebView"); |
|
85 |
40 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) |
86 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) |
41 window.views.WebView.touchNav.doubleClickEnabled = false; |
87 window.views.WebView.touchNav.doubleClickEnabled = false; |
|
88 |
|
89 hidePopups(); |
42 } |
90 } |
43 |
91 |
44 function chrome_showBookmarksView() { |
92 function chrome_showBookmarksView() { |
45 showSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); |
93 showSuperPage("BookmarkTreeView", BOOKMARKVIEW_PAGE); |
46 } |
94 } |
47 |
95 |
48 function chrome_showHistoryView() { |
96 function chrome_showHistoryView() { |
49 showSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); |
97 showSuperPage("BookmarkHistoryView", HISTORYVIEW_PAGE); |
50 } |
98 } |
51 |
99 |
52 function chrome_showWindowsView() { |
100 function chrome_showWindowsView() { |
53 window.snippets.ZoomBarId.hide(); // hide Zoom Bar while showing windows view |
101 if(app.ui() != "maemo5_ui") |
|
102 window.snippets.ZoomBarId.hide(); // hide Zoom Bar while showing windows view |
54 window.snippets.MostVisitedViewId.hide(); |
103 window.snippets.MostVisitedViewId.hide(); |
55 window.ViewStack.switchView("WindowView", "WebView"); |
104 window.ViewStack.switchView("WindowView", "WebView"); |
56 } |
105 } |
57 |
106 |
58 function chrome_showSettingsView() { |
107 function chrome_showSettingsView() { |
59 showSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); |
108 showSuperPage("SettingsView", SETTINGSVIEW_PAGE); |
60 } |
109 } |
61 |
110 |
62 function chrome_showBasicMenu() { |
111 function chrome_showBasicMenu() { |
63 |
112 |
64 cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); |
113 cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); |
158 |
211 |
159 function preloadSuperPage(pageName, path) { |
212 function preloadSuperPage(pageName, path) { |
160 if (window.views.WebView[pageName] == undefined) { |
213 if (window.views.WebView[pageName] == undefined) { |
161 window.views.WebView.createSuperPage(pageName, true); |
214 window.views.WebView.createSuperPage(pageName, true); |
162 } |
215 } |
163 window.views.WebView[pageName].load(chrome.baseDirectory + path); |
216 window.views.WebView[pageName].load(/*chrome.baseDirectory +*/ path); |
164 } |
217 } |
165 |
218 |
166 function onChromeComplete(){ |
219 //var chrome_blockPopupsAction; |
|
220 |
|
221 // Handle Block/Allow Popups action. |
|
222 function chrome_toggleBlockPopups() { |
|
223 hidePopups(); |
|
224 pageController.savePopupSettings(!pageController.getPopupSettings()); |
|
225 chrome_blockPopupsAction.text = chrome_getBlockPopupsActionText(); |
|
226 } |
|
227 |
|
228 // Returns the text for the Block/Allow Popups action based on the the current setting in the page controller. |
|
229 function chrome_getBlockPopupsActionText() { |
|
230 return window.localeDelegate.translateText(pageController.getPopupSettings() |
|
231 ? "txt_browser_content_view_menu_page_allow_popups" |
|
232 : "txt_browser_content_view_menu_page_block_popups"); |
|
233 } |
|
234 |
|
235 function chrome_setZoomButtonActions() { |
|
236 snippets.ZoomInButtonSnippet.connectAction("zoomIn", "WebView", true, true); |
|
237 snippets.ZoomOutButtonSnippet.connectAction("zoomOut", "WebView", true, true); |
|
238 } |
|
239 |
|
240 // Create an action and add it to the Maemo menu bar. |
|
241 function chrome_addMaemoMenuBarAction(text, callback) { |
|
242 var action = app.createAction(text); |
|
243 action.triggered.connect(callback); |
|
244 app.addMenuBarAction(action); |
|
245 return action; |
|
246 } |
|
247 function chrome_updateMaemoMenuBarItems() { |
|
248 app.setMenuBarEnabled(!views.WebView.currentPageIsSuperPage()); |
|
249 } |
|
250 |
|
251 // Create actions that appear in the Maemo system menu at the top of the screen. |
|
252 function chrome_createMaemoMenuBarItems() { |
|
253 // Global menu items. |
|
254 chrome_addMaemoMenuBarAction(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_bookmarks"), |
|
255 chrome_showBookmarksView); |
|
256 chrome_addMaemoMenuBarAction(window.localeDelegate.translateText("txt_browser_content_view_menu_page_add_bookmark"), |
|
257 function() { hidePopups(); launchBookmarkDialog(pageController.currentDocTitle, pageController.currentDocUrl,-1,0); } ); |
|
258 chrome_addMaemoMenuBarAction(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_history"), |
|
259 chrome_showHistoryView); |
|
260 chrome_blockPopupsAction = chrome_addMaemoMenuBarAction(chrome_getBlockPopupsActionText(), |
|
261 chrome_toggleBlockPopups); |
|
262 chrome_addMaemoMenuBarAction(window.localeDelegate.translateText("txt_browser_content_view_menu_page_share"), |
|
263 function() { hidePopups(); pageController.share(pageController.currentDocUrl); } ); |
|
264 chrome_addMaemoMenuBarAction(window.localeDelegate.translateText("txt_browser_content_view_menu_nav_settings"), |
|
265 chrome_showSettingsView); |
|
266 } |
|
267 function onChromeActivated() { |
|
268 |
|
269 snippets.SuggestsChromeId.hide(false); |
|
270 |
|
271 if(!views.WebView.currentPageIsSuperPage()) { |
|
272 views.WebView.enabled = true; |
|
273 views.WebView.unfreeze(); |
|
274 } |
|
275 snippets.MostVisitedViewId.hide(); |
|
276 |
|
277 if(app.ui() == "maemo5_ui") { |
|
278 snippets.UrlSearchChromeId.grabFocus(); |
|
279 } |
|
280 } |
|
281 |
|
282 function onChromeComplete() { |
|
283 |
167 if (app.ui() == "orbit_ui") { |
284 if (app.ui() == "orbit_ui") { |
168 snippets.StatusBarChromeId.hide(); |
285 snippets.StatusBarChromeId.hide(); |
169 } |
286 } |
170 if (app.layoutType() == "tenone") { |
287 if (app.layoutType() == "tenone") { |
171 window.snippets.TitleUrlId.anchorToView("top"); |
288 window.snippets.TitleUrlId.anchorToView("top"); |
172 |
289 |
|
290 // Disable content view while Most Visited view is shown. |
|
291 snippets.MostVisitedViewId.shown.connect( |
|
292 function() { |
|
293 views.WebView.enabled = false; |
|
294 views.WebView.unfreeze(); |
|
295 } |
|
296 ); |
|
297 |
|
298 // Enable content view when Most Visited view is hidden. |
|
299 snippets.MostVisitedViewId.hidden.connect( |
|
300 function() { |
|
301 views.WebView.enabled = true; |
|
302 } |
|
303 ); |
|
304 |
|
305 } |
|
306 else if(app.ui() == "maemo5_ui") { |
|
307 |
|
308 chrome_createMaemoMenuBarItems(); |
|
309 |
|
310 // Update the menu items when the page type changes. |
|
311 views.WebView.normalPageShown.connect(chrome_updateMaemoMenuBarItems); |
|
312 views.WebView.superPageShown.connect(chrome_updateMaemoMenuBarItems); |
|
313 window.snippets.UrlSearchChromeId.anchorToView("top"); |
|
314 chrome_setZoomButtonActions(); |
|
315 |
|
316 // Disable content view while Most Visited view is shown. |
|
317 snippets.MostVisitedViewId.shown.connect( |
|
318 function() { |
|
319 views.WebView.enabled = false; |
|
320 snippets.UrlSearchChromeId.enabled = false; |
|
321 } |
|
322 ); |
|
323 |
|
324 // Enable content view when Most Visited view is hidden. |
|
325 snippets.MostVisitedViewId.hidden.connect( |
|
326 function() { |
|
327 views.WebView.enabled = true; |
|
328 snippets.UrlSearchChromeId.enabled = true; |
|
329 } |
|
330 ); |
|
331 |
173 } |
332 } |
174 else { |
333 else { |
175 window.snippets.UrlSearchChromeId.anchorToView("top"); |
334 window.snippets.UrlSearchChromeId.anchorToView("top"); |
176 } |
335 } |
177 |
336 |
178 window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu); |
337 window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu); |
179 window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark); |
338 window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark); |
180 window.snippets.WebViewToolbarId.menuButtonCanceled.connect(chrome_cancelMenu); |
339 window.snippets.WebViewToolbarId.menuButtonCanceled.connect(chrome_cancelMenu); |
181 |
340 |
|
341 // Dismiss Most Visited view when it gets an external click event. |
|
342 snippets.MostVisitedViewId.externalMouseEvent.connect( |
|
343 function(type, name, description) { |
|
344 if(name == "MouseClick") { |
|
345 // Use timer here to hide the view even when the Most Visited page button is clicked, |
|
346 // otherwise the button re-displays the view. |
|
347 setTimeout('snippets.MostVisitedViewId.hide()', 100); |
|
348 } |
|
349 }); |
|
350 |
182 //window.snippets.ButtonContainer.setVisibilityAnimator("G_VISIBILITY_FADE_ANIMATOR"); |
351 //window.snippets.ButtonContainer.setVisibilityAnimator("G_VISIBILITY_FADE_ANIMATOR"); |
183 |
352 if(app.ui() != "maemo5_ui"){ |
184 result = new Array; |
353 result = new Array; |
185 result = calcToolbarPopAnchorOffset(window.snippets.ZoomBarId, |
354 result = calcToolbarPopAnchorOffset(window.snippets.ZoomBarId, |
186 window.snippets.ZoomButtonSnippet, |
355 window.snippets.ZoomButtonSnippet, |
187 0,10); |
356 0,10); |
188 window.snippets.ZoomBarId.anchorTo("ZoomButtonSnippet",result[0],result[1]); |
357 window.snippets.ZoomBarId.anchorTo("ZoomButtonSnippet",result[0],result[1]); |
189 |
358 } |
190 snippets.SuggestsChromeId.url = chrome.baseDirectory + "suggests.snippet/suggests.html"; |
359 |
|
360 snippets.SuggestsChromeId.url = /*chrome.baseDirectory +*/ SUGGESTS_PAGE; |
191 |
361 |
192 window.ViewStack.activateBookmark.connect(onActivateBookmarkView); |
362 window.ViewStack.activateBookmark.connect(onActivateBookmarkView); |
193 |
363 |
194 chrome.popupShown.connect(onPopupShown); |
364 chrome.popupShown.connect(onPopupShown); |
195 chrome.popupHidden.connect(onPopupHidden); |
365 chrome.popupHidden.connect(onPopupHidden); |
|
366 |
|
367 if(app.ui() == "maemo5_ui") |
|
368 chrome.chromeActivated.connect(onChromeActivated); |
|
369 |
196 window.pageController.loadFinished.connect(_updateHistory); |
370 window.pageController.loadFinished.connect(_updateHistory); |
197 window.pageController.loadFinishedForBackgroundWindow.connect(_updateHistory); |
371 window.pageController.loadFinishedForBackgroundWindow.connect(_updateHistory); |
198 window.bookmarksController.bookmarksCleared.connect(_updateBookmarks); |
372 window.bookmarksController.bookmarksCleared.connect(_updateBookmarks); |
199 window.historyManager.historyCleared.connect(_updateHistory); |
373 window.historyManager.historyCleared.connect(_updateHistory); |
|
374 |
200 } |
375 } |
201 |
376 |
202 // For debugging: prints all properties and functions attached to a given object. |
377 // For debugging: prints all properties and functions attached to a given object. |
203 function printProp(x) { |
378 function printProp(x) { |
204 var str = "-------------\n" + x + " properties:\n"; |
379 var str = "-------------\n" + x + " properties:\n"; |
205 for (property in x) { |
380 for (property in x) { |
206 str += ("\t" + property + ": " + x[property] + "\n"); |
381 str += ("\t" + property + ": " + x[property] + "\n"); |
207 } |
382 } |
208 app.debug(str); |
383 app.debug(str); |
209 } |
384 } |
|
385 |