24 return([xOffset,yOffset]); |
24 return([xOffset,yOffset]); |
25 } |
25 } |
26 |
26 |
27 // Display the super-page with the given name and path. |
27 // Display the super-page with the given name and path. |
28 function showSuperPage(pageName, path) { |
28 function showSuperPage(pageName, path) { |
|
29 |
29 if (window.views.WebView[pageName] == undefined) { |
30 if (window.views.WebView[pageName] == undefined) { |
30 window.views.WebView.createSuperPage(pageName, true); |
31 window.views.WebView.createSuperPage(pageName, true); |
|
32 window.views.WebView[pageName].load(chrome.baseDirectory + path); |
31 } |
33 } |
32 window.views.WebView[pageName].load(chrome.baseDirectory + path); |
34 |
33 |
35 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) |
34 // Show it. |
36 window.views.WebView.zoomFactor = 1.0; |
35 window.views.WebView.zoomFactor = 1.0; |
37 //window.views.WebView.showSuperPage(pageName); |
36 window.views.WebView.showSuperPage(pageName); |
|
37 window.ViewStack.switchView(pageName, "WebView"); |
38 window.ViewStack.switchView(pageName, "WebView"); |
|
39 if (!window.views.WebView.bedrockTiledBackingStoreEnabled()) |
|
40 window.views.WebView.touchNav.doubleClickEnabled = false; |
38 } |
41 } |
39 |
42 |
40 function chrome_showBookmarksView() { |
43 function chrome_showBookmarksView() { |
41 app.debug("chrome_showBookmarksView"); |
|
42 showSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); |
44 showSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); |
43 } |
45 } |
44 |
46 |
45 function chrome_showHistoryView() { |
47 function chrome_showHistoryView() { |
46 app.debug("chrome_showHistoryView"); |
|
47 showSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); |
48 showSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); |
48 // showHistoryView(); |
|
49 } |
49 } |
50 |
50 |
51 function chrome_showWindowsView() { |
51 function chrome_showWindowsView() { |
52 app.debug("chrome_showWindowsView"); |
|
53 window.snippets.ZoomBarId.hide(); // hide Zoom Bar while showing windows view |
52 window.snippets.ZoomBarId.hide(); // hide Zoom Bar while showing windows view |
54 window.snippets.MostVisitedViewId.hide(); |
53 window.snippets.MostVisitedViewId.hide(); |
55 window.ViewStack.switchView("WindowView", "WebView"); |
54 window.ViewStack.switchView("WindowView", "WebView"); |
56 } |
55 } |
57 |
56 |
58 function chrome_showSettingsView() { |
57 function chrome_showSettingsView() { |
59 app.debug("chrome_showSettingsView"); |
|
60 showSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); |
58 showSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); |
61 } |
59 } |
62 |
60 |
63 function chrome_showBasicMenu() { |
61 function chrome_showBasicMenu() { |
64 if (!snippets.ContextMenuId.dontShow) { |
62 |
65 cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); |
63 cm_TheContextMenu.show(viewMenu_getWebViewContextMenuData()); |
66 } |
64 |
67 } |
65 } |
68 |
66 |
69 function chrome_addBookmark() { |
67 function chrome_addBookmark() { |
70 launchBookmarkDialog(window.pageController.currentDocTitle,window.pageController.currentDocUrl,0); |
68 launchBookmarkDialog(window.pageController.currentDocTitle,window.pageController.currentDocUrl,0); |
71 } |
69 } |
93 } |
91 } |
94 |
92 |
95 function onActivateBookmarkView() { |
93 function onActivateBookmarkView() { |
96 window.bookmarksManager.launchBookmarkEditDailog.connect(showBookmarkEditDialog); |
94 window.bookmarksManager.launchBookmarkEditDailog.connect(showBookmarkEditDialog); |
97 } |
95 } |
|
96 function preLoad() |
|
97 { |
|
98 preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); |
|
99 preloadSuperPage("SettingsView", "settingsview.superpage/SettingsView.html"); |
|
100 preLoadBookmarksDone=1; |
|
101 } |
|
102 function _updateHistory() |
|
103 { |
|
104 preloadSuperPage("BookmarkHistoryView", "historyview.superpage/historyView.html"); |
|
105 |
|
106 } |
|
107 |
|
108 function _updateBookmarks() |
|
109 { |
|
110 preloadSuperPage("BookmarkTreeView", "bookmarkview.superpage/BookmarkView.html"); |
|
111 } |
|
112 |
|
113 // chrome_popupShownCount keeps a count of how many popups are currently being shown so that |
|
114 // we can re-enable the appropriate UI elements only when the last one is hidden. |
|
115 var chrome_popupShownCount = 0; |
98 |
116 |
99 // Called when a PopupChromeItem is displayed. |
117 // Called when a PopupChromeItem is displayed. |
100 function onPopupShown(id) { |
118 function onPopupShown(id) { |
101 // Disable snippets etc. that should be greyed-out while the popup is shown. |
119 if(chrome_popupShownCount == 0) { |
102 snippets.UrlSearchChromeId.enabled = false; |
120 // Disable snippets etc. that should be greyed-out while the popup is shown. |
103 views.WebView.enabled = false; |
121 snippets.UrlSearchChromeId.enabled = false; |
104 views.WebView.freeze(); |
122 views.WebView.enabled = false; |
|
123 views.WebView.freeze(); |
|
124 |
|
125 // Note: this can be expanded as needed. We may want to disable all snippets except |
|
126 // for the status bar and the one who's id was passed in. |
|
127 } |
|
128 chrome_popupShownCount++; |
105 |
129 |
106 // Note: this can be expanded as needed. We may want to disable all snippets except |
130 if(preLoadBookmarksDone==0) |
107 // for the urlSearchBar and the one who's id was passed in. |
131 { |
|
132 preLoad(); |
|
133 } |
108 } |
134 } |
109 |
135 |
110 // Called when a PopupChromeItem is hidden. |
136 // Called when a PopupChromeItem is hidden. |
111 function onPopupHidden(id) { |
137 function onPopupHidden(id) { |
112 // Re-enable snippets etc. that were greyed-out while the popup is shown. |
138 chrome_popupShownCount--; |
113 snippets.UrlSearchChromeId.enabled = true; |
139 if(chrome_popupShownCount == 0) { |
114 views.WebView.enabled = true; |
140 // Re-enable snippets etc. that were greyed-out while popups were being shown. |
115 views.WebView.unfreeze(); |
141 snippets.UrlSearchChromeId.enabled = true; |
|
142 views.WebView.enabled = true; |
|
143 views.WebView.unfreeze(); |
|
144 } |
|
145 if(chrome_popupShownCount < 0) app.debug("onPopupHidden: error, chrome_popupShownCount invalid"); |
|
146 } |
|
147 |
|
148 function preloadSuperPage(pageName, path) { |
|
149 if (window.views.WebView[pageName] == undefined) { |
|
150 window.views.WebView.createSuperPage(pageName, true); |
|
151 } |
|
152 window.views.WebView[pageName].load(chrome.baseDirectory + path); |
116 } |
153 } |
117 |
154 |
118 function onChromeComplete(){ |
155 function onChromeComplete(){ |
119 if (app.ui() != "orbit_ui") { |
156 if (app.ui() == "orbit_ui") { |
120 snippets.StatusBarChromeId.show(); |
157 snippets.StatusBarChromeId.hide(); |
121 } |
158 } |
122 |
159 |
123 window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu); |
160 window.snippets.WebViewToolbarId.menuButtonSelected.connect(chrome_showBasicMenu); |
124 window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark); |
161 window.snippets.BookmarkViewToolbarId.addBookmarkSelected.connect(chrome_addBookmark); |
125 window.snippets.UrlSearchChromeId.anchorToView("top"); |
162 window.snippets.UrlSearchChromeId.anchorToView("top"); |
137 |
174 |
138 window.ViewStack.activateBookmark.connect(onActivateBookmarkView); |
175 window.ViewStack.activateBookmark.connect(onActivateBookmarkView); |
139 |
176 |
140 chrome.popupShown.connect(onPopupShown); |
177 chrome.popupShown.connect(onPopupShown); |
141 chrome.popupHidden.connect(onPopupHidden); |
178 chrome.popupHidden.connect(onPopupHidden); |
|
179 window.pageController.loadFinished.connect(_updateHistory); |
|
180 window.bookmarksManager.bookmarksCleared.connect(_updateBookmarks); |
|
181 window.bookmarksManager.historyCleared.connect(_updateHistory); |
142 } |
182 } |
143 |
183 |
144 // For debugging: prints all properties and functions attached to a given object. |
184 // For debugging: prints all properties and functions attached to a given object. |
145 function printProp(x) { |
185 function printProp(x) { |
146 var str = "-------------\n" + x + " properties:\n"; |
186 var str = "-------------\n" + x + " properties:\n"; |