|
1 function printProp(x) { |
|
2 window.app.debug(x + ":"); |
|
3 for (property in x) { |
|
4 window.chrome.alert(" " + property + ": " + x[property]); |
|
5 } |
|
6 } |
|
7 |
|
8 function historyViewContextEvent(e) { |
|
9 window.chrome.alert("history context: " + e + " " + e.itemIndex + |
|
10 " x=" + e.pos.x + " y=" + e.pos.y); |
|
11 printProp(e); |
|
12 } |
|
13 |
|
14 window.chrome.chromeComplete.connect(chromeLoadComplete); |
|
15 |
|
16 |
|
17 function chromeLoadComplete() { |
|
18 |
|
19 window.snippets.ContextMenuId.externalMouseEvent.connect( |
|
20 function(type, name, description) { |
|
21 |
|
22 if ((name == "QGraphicsSceneMouseReleaseEvent") || (name == "QGraphicsSceneResizeEvent")){ |
|
23 window.snippets.ContextMenuId.hide(); |
|
24 window.snippets.ContextMenuId.dontShow = true; |
|
25 setTimeout ( 'window.snippets.ContextMenuId.dontShow = false', 500 ); // reset the flag in 0.5 sec. |
|
26 } |
|
27 } |
|
28 ); |
|
29 } |
|
30 |
|
31 function ContextMenu() |
|
32 { |
|
33 // attach internal funcs |
|
34 this.write = writeContextMenu; |
|
35 |
|
36 // do setup |
|
37 this.write(); |
|
38 } |
|
39 //// |
|
40 |
|
41 function showBookmarkView() |
|
42 { |
|
43 if(window.views.WebView.BookmarkTreeView == undefined) { |
|
44 window.views.WebView.createSuperPage("BookmarkTreeView", true); |
|
45 } |
|
46 window.views.WebView.BookmarkTreeView.load(chrome.baseDirectory + "bookmarkview.superpage/BookmarkView.html"); |
|
47 |
|
48 // Show it. |
|
49 window.views.WebView.zoomFactor = 1.0; |
|
50 window.views.WebView.showSuperPage("BookmarkTreeView"); |
|
51 } |
|
52 |
|
53 function showSettingsView() |
|
54 { |
|
55 if(window.views.WebView.SettingsView == undefined) { |
|
56 window.views.WebView.createSuperPage("SettingsView", true); |
|
57 } |
|
58 window.views.WebView.SettingsView.load(chrome.baseDirectory + "settingsview.superpage/SettingsView.html"); |
|
59 |
|
60 // Show it. |
|
61 window.views.WebView.zoomFactor = 1.0; |
|
62 window.views.WebView.showSuperPage("SettingsView"); |
|
63 } |
|
64 |
|
65 function showHistoryView() |
|
66 { |
|
67 if(window.views.WebView.BookmarkHistoryView == undefined) { |
|
68 window.views.WebView.createSuperPage("BookmarkHistoryView", true); |
|
69 } |
|
70 window.views.WebView.BookmarkHistoryView.load(chrome.baseDirectory + "historyview.superpage/historyView.html"); |
|
71 |
|
72 // Show it. |
|
73 window.views.WebView.zoomFactor = 1.0; |
|
74 window.views.WebView.showSuperPage("BookmarkHistoryView"); |
|
75 } |
|
76 |
|
77 function goToRecentUrlView () { |
|
78 showHistoryView(); |
|
79 window.ViewStack.switchView("BookmarkHistoryView", "WebView"); |
|
80 } |
|
81 |
|
82 function goToBookmarkView () { |
|
83 showBookmarkView(); |
|
84 window.ViewStack.switchView("BookmarkTreeView", "WebView"); |
|
85 } |
|
86 |
|
87 function goToSettingsView () { |
|
88 showSettingsView(); |
|
89 window.ViewStack.switchView("SettingsView", "WebView"); |
|
90 //window.snippets.UrlSearchChromeId.hide(false); |
|
91 } |
|
92 |
|
93 // "Private" methods |
|
94 function writeContextMenu() { |
|
95 var html = |
|
96 '<div class="loadImagesTop">'+ |
|
97 '</div>'+ |
|
98 '<div class="loadImagesCenter">'+ |
|
99 '</div>'+ |
|
100 '<div class="loadImagesBottom">'+ |
|
101 '</div>'+ |
|
102 |
|
103 '<div class="menuItem menuTop">'+ |
|
104 '<div class="menuItemContents" onmouseup="goToBookmarkView(); window.snippets.ContextMenuId.hide()">'+ |
|
105 '<img STYLE="vertical-align: middle; padding-left: 20px; padding-right: 15px;" src="contextmenu.snippet/icons/menu_icon_bookmarks.png">'+ |
|
106 '<span class="menuItemLabel">'+ |
|
107 window.localeDelegate.translateText("content_view_menu_bookmarks")+ |
|
108 '</span>'+ |
|
109 '</div>'+ |
|
110 '</div>'+ |
|
111 |
|
112 '<div class="menuItem menuBot">'+ |
|
113 '<div class="menuItemContents" onmouseup="goToRecentUrlView();window.snippets.ContextMenuId.hide()">'+ |
|
114 '<img STYLE="vertical-align: middle; padding-left: 20px; padding-right: 15px;" src="contextmenu.snippet/icons/menu_icon_settings.png">'+ |
|
115 '<span class="menuItemLabel">'+ |
|
116 window.localeDelegate.translateText("content_view_menu_history")+ |
|
117 '</span>'+ |
|
118 '</div>'+ |
|
119 '</div>'; |
|
120 |
|
121 document.write(html); |
|
122 } |
|
123 |
|
124 |
|
125 |