Skip to content

Add ForwardButton to Sidebar #1073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/renderer/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ webview.focus {
#loading-tooltip,
#dnd-tooltip,
#back-tooltip,
#forward-tooltip,
#reload-tooltip,
#setting-tooltip {
font-family: sans-serif;
Expand All @@ -362,6 +363,7 @@ webview.focus {
#loading-tooltip::after,
#dnd-tooltip::after,
#back-tooltip::after,
#forward-tooltip::after,
#reload-tooltip::after,
#setting-tooltip::after {
content: " ";
Expand Down
12 changes: 12 additions & 0 deletions app/renderer/js/components/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ export default class WebView extends BaseComponent {
}

this.canGoBackButton();
this.canGoForwardButton();
});

this.$el.addEventListener('did-navigate', () => {
this.canGoBackButton();
this.canGoForwardButton();
});

this.$el.addEventListener('page-favicon-updated', event => {
Expand Down Expand Up @@ -294,6 +296,16 @@ export default class WebView extends BaseComponent {
forward(): void {
if (this.$el.canGoForward()) {
this.$el.goForward();
this.focus();
}
}

canGoForwardButton(): void {
const $forwardButton = document.querySelector('#actions-container #forward-action');
if (this.$el.canGoForward()) {
$forwardButton.classList.remove('disable');
} else {
$forwardButton.classList.add('disable');
}
}

Expand Down
9 changes: 9 additions & 0 deletions app/renderer/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@ class ServerManagerView {
$settingsButton: HTMLButtonElement;
$webviewsContainer: Element;
$backButton: HTMLButtonElement;
$forwardButton: HTMLButtonElement;
$dndButton: HTMLButtonElement;
$addServerTooltip: HTMLElement;
$reloadTooltip: HTMLElement;
$loadingTooltip: HTMLElement;
$settingsTooltip: HTMLElement;
$serverIconTooltip: HTMLCollectionOf<HTMLElement>;
$backTooltip: HTMLElement;
$forwardTooltip: HTMLElement;
$dndTooltip: HTMLElement;
$sidebar: Element;
$fullscreenPopup: Element;
Expand All @@ -103,6 +105,7 @@ class ServerManagerView {
this.$settingsButton = $actionsContainer.querySelector('#settings-action');
this.$webviewsContainer = document.querySelector('#webviews-container');
this.$backButton = $actionsContainer.querySelector('#back-action');
this.$forwardButton = $actionsContainer.querySelector('#forward-action');
this.$dndButton = $actionsContainer.querySelector('#dnd-action');

this.$addServerTooltip = document.querySelector('#add-server-tooltip');
Expand All @@ -117,6 +120,7 @@ class ServerManagerView {
// eslint-disable-next-line unicorn/prefer-query-selector
this.$serverIconTooltip = document.getElementsByClassName('server-tooltip') as HTMLCollectionOf<HTMLElement>;
this.$backTooltip = $actionsContainer.querySelector('#back-tooltip');
this.$forwardTooltip = $actionsContainer.querySelector('#forward-tooltip');
this.$dndTooltip = $actionsContainer.querySelector('#dnd-tooltip');

this.$sidebar = document.querySelector('#sidebar');
Expand Down Expand Up @@ -423,6 +427,9 @@ class ServerManagerView {
this.$settingsButton.addEventListener('click', async () => {
await this.openSettings('General');
});
this.$forwardButton.addEventListener('click', () => {
this.tabs[this.activeTabIndex].webview.forward();
});
this.$backButton.addEventListener('click', () => {
this.tabs[this.activeTabIndex].webview.back();
});
Expand All @@ -431,6 +438,7 @@ class ServerManagerView {
this.sidebarHoverEvent(this.$loadingIndicator, this.$loadingTooltip);
this.sidebarHoverEvent(this.$settingsButton, this.$settingsTooltip);
this.sidebarHoverEvent(this.$reloadButton, this.$reloadTooltip);
this.sidebarHoverEvent(this.$forwardButton, this.$forwardTooltip);
this.sidebarHoverEvent(this.$backButton, this.$backTooltip);
this.sidebarHoverEvent(this.$dndButton, this.$dndTooltip);
}
Expand Down Expand Up @@ -628,6 +636,7 @@ class ServerManagerView {

try {
this.tabs[index].webview.canGoBackButton();
this.tabs[index].webview.canGoForwardButton();
} catch {}

this.activeTabIndex = index;
Expand Down
4 changes: 4 additions & 0 deletions app/renderer/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<i class="refresh material-icons md-48">loop</i>
<span id="loading-tooltip" style="display:none">Loading</span>
</div>
<div class="action-button disable" id="forward-action">
<i class="material-icons md-48">arrow_forward</i>
<span id="forward-tooltip" style="display:none">Go Forward</span>
</div>
<div class="action-button disable" id="back-action">
<i class="material-icons md-48">arrow_back</i>
<span id="back-tooltip" style="display:none">Go Back</span>
Expand Down