diff options
author | Juan Mora <raicerk@gmail.com> | 2020-09-08 10:44:22 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 14:44:22 +0100 |
commit | d3e1715a4f37dbbce0a4447cccc5f93694e989c4 (patch) | |
tree | f9e83c779f9fc753cfbf0c343a20ed2638a484fb | |
parent | Bump marked from 0.6.1 to 0.7.0 (#944) (diff) | |
download | ferdium-app-d3e1715a4f37dbbce0a4447cccc5f93694e989c4.tar.gz ferdium-app-d3e1715a4f37dbbce0a4447cccc5f93694e989c4.tar.zst ferdium-app-d3e1715a4f37dbbce0a4447cccc5f93694e989c4.zip |
Add "Go to Home Page" in services context menu (#900)
Co-authored-by: Juan Mora <juanvalentin.mora@globant.com>
-rw-r--r-- | src/webview/contextMenuBuilder.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js index ee27877b9..8adc3b432 100644 --- a/src/webview/contextMenuBuilder.js +++ b/src/webview/contextMenuBuilder.js | |||
@@ -10,6 +10,8 @@ const { | |||
10 | clipboard, nativeImage, remote, shell, | 10 | clipboard, nativeImage, remote, shell, |
11 | } = require('electron'); | 11 | } = require('electron'); |
12 | 12 | ||
13 | const { URL } = require('url'); | ||
14 | |||
13 | const { Menu, MenuItem } = remote; | 15 | const { Menu, MenuItem } = remote; |
14 | 16 | ||
15 | function matchesWord(string) { | 17 | function matchesWord(string) { |
@@ -31,6 +33,7 @@ const contextMenuStringTable = { | |||
31 | copy: () => 'Copy', | 33 | copy: () => 'Copy', |
32 | paste: () => 'Paste', | 34 | paste: () => 'Paste', |
33 | inspectElement: () => 'Inspect Element', | 35 | inspectElement: () => 'Inspect Element', |
36 | goToHomePage: () => 'Go to Home Page', | ||
34 | }; | 37 | }; |
35 | 38 | ||
36 | /** | 39 | /** |
@@ -128,6 +131,8 @@ module.exports = class ContextMenuBuilder { | |||
128 | this.addInspectElement(menu, menuInfo); | 131 | this.addInspectElement(menu, menuInfo); |
129 | this.processMenu(menu, menuInfo); | 132 | this.processMenu(menu, menuInfo); |
130 | 133 | ||
134 | this.goToHomePage(menu, menuInfo); | ||
135 | |||
131 | return menu; | 136 | return menu; |
132 | } | 137 | } |
133 | 138 | ||
@@ -175,6 +180,8 @@ module.exports = class ContextMenuBuilder { | |||
175 | this.addInspectElement(menu, menuInfo); | 180 | this.addInspectElement(menu, menuInfo); |
176 | this.processMenu(menu, menuInfo); | 181 | this.processMenu(menu, menuInfo); |
177 | 182 | ||
183 | this.goToHomePage(menu, menuInfo); | ||
184 | |||
178 | return menu; | 185 | return menu; |
179 | } | 186 | } |
180 | 187 | ||
@@ -191,6 +198,8 @@ module.exports = class ContextMenuBuilder { | |||
191 | this.addInspectElement(menu, menuInfo); | 198 | this.addInspectElement(menu, menuInfo); |
192 | this.processMenu(menu, menuInfo); | 199 | this.processMenu(menu, menuInfo); |
193 | 200 | ||
201 | this.goToHomePage(menu, menuInfo); | ||
202 | |||
194 | return menu; | 203 | return menu; |
195 | } | 204 | } |
196 | 205 | ||
@@ -416,4 +425,22 @@ module.exports = class ContextMenuBuilder { | |||
416 | 425 | ||
417 | img.src = url; | 426 | img.src = url; |
418 | } | 427 | } |
428 | |||
429 | /** | ||
430 | * Adds the go to home menu item. | ||
431 | */ | ||
432 | goToHomePage(menu, menuInfo) { | ||
433 | const baseURL = new URL(menuInfo.pageURL); | ||
434 | menu.append(new MenuItem({ | ||
435 | label: this.stringTable.goToHomePage(), | ||
436 | accelerator: 'CommandOrControl+Home', | ||
437 | enabled: true, | ||
438 | click: () => { | ||
439 | // target.loadURL(baseURL.origin); | ||
440 | window.location.href = baseURL.origin; | ||
441 | }, | ||
442 | })); | ||
443 | |||
444 | return menu; | ||
445 | } | ||
419 | }; | 446 | }; |