diff options
author | 2017-10-21 21:49:22 -0300 | |
---|---|---|
committer | 2017-10-21 21:49:22 -0300 | |
commit | 80f12d79251d28679becff126a4da095eb52f640 (patch) | |
tree | ca5acdd2a82fe12f034b3816db2d3d0eb1bb5afd /src/components/services/content/ServiceWebview.js | |
parent | Move linux distribution specific dependencies to /docs (diff) | |
download | ferdium-app-80f12d79251d28679becff126a4da095eb52f640.tar.gz ferdium-app-80f12d79251d28679becff126a4da095eb52f640.tar.zst ferdium-app-80f12d79251d28679becff126a4da095eb52f640.zip |
Show url when mouse enters a link
This resolves #47
Diffstat (limited to 'src/components/services/content/ServiceWebview.js')
-rw-r--r-- | src/components/services/content/ServiceWebview.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index 043ff42ea..7e33d694c 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js | |||
@@ -6,6 +6,7 @@ import Webview from 'react-electron-web-view'; | |||
6 | import classnames from 'classnames'; | 6 | import classnames from 'classnames'; |
7 | 7 | ||
8 | import ServiceModel from '../../../models/Service'; | 8 | import ServiceModel from '../../../models/Service'; |
9 | import StatusBarTargetUrl from '../../ui/StatusBarTargetUrl'; | ||
9 | 10 | ||
10 | @observer | 11 | @observer |
11 | export default class ServiceWebview extends Component { | 12 | export default class ServiceWebview extends Component { |
@@ -20,6 +21,8 @@ export default class ServiceWebview extends Component { | |||
20 | 21 | ||
21 | state = { | 22 | state = { |
22 | forceRepaint: false, | 23 | forceRepaint: false, |
24 | targetUrl: '', | ||
25 | statusBarVisible: false, | ||
23 | }; | 26 | }; |
24 | 27 | ||
25 | componentDidMount() { | 28 | componentDidMount() { |
@@ -33,6 +36,17 @@ export default class ServiceWebview extends Component { | |||
33 | }); | 36 | }); |
34 | } | 37 | } |
35 | 38 | ||
39 | updateTargetUrl = (event) => { | ||
40 | let visible = true; | ||
41 | if (event.url === '' || event.url === '#') { | ||
42 | visible = false; | ||
43 | } | ||
44 | this.setState({ | ||
45 | targetUrl: event.url, | ||
46 | statusBarVisible: visible, | ||
47 | }); | ||
48 | } | ||
49 | |||
36 | webview = null; | 50 | webview = null; |
37 | 51 | ||
38 | render() { | 52 | render() { |
@@ -47,6 +61,13 @@ export default class ServiceWebview extends Component { | |||
47 | 'services__webview--force-repaint': this.state.forceRepaint, | 61 | 'services__webview--force-repaint': this.state.forceRepaint, |
48 | }); | 62 | }); |
49 | 63 | ||
64 | let statusBar = null; | ||
65 | if (this.state.statusBarVisible) { | ||
66 | statusBar = ( | ||
67 | <StatusBarTargetUrl position="bottom" text={this.state.targetUrl} /> | ||
68 | ); | ||
69 | } | ||
70 | |||
50 | return ( | 71 | return ( |
51 | <div className={webviewClasses}> | 72 | <div className={webviewClasses}> |
52 | <Webview | 73 | <Webview |
@@ -62,11 +83,14 @@ export default class ServiceWebview extends Component { | |||
62 | webview: this.webview.view, | 83 | webview: this.webview.view, |
63 | })} | 84 | })} |
64 | 85 | ||
86 | onUpdateTargetUrl={this.updateTargetUrl} | ||
87 | |||
65 | useragent={service.userAgent} | 88 | useragent={service.userAgent} |
66 | 89 | ||
67 | disablewebsecurity | 90 | disablewebsecurity |
68 | allowpopups | 91 | allowpopups |
69 | /> | 92 | /> |
93 | {statusBar} | ||
70 | </div> | 94 | </div> |
71 | ); | 95 | ); |
72 | } | 96 | } |