Avoid multiple webviews show at the same time.

This commit is contained in:
Zhongyi Tong
2017-06-13 02:36:47 +08:00
parent 4c188bbdc8
commit 743d689281
2 changed files with 8 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ class WebView extends BaseComponent {
constructor(params) {
super();
const {$root, url, index, name, onTitleChange, nodeIntegration} = params;
const {$root, url, index, name, isActive, onTitleChange, nodeIntegration} = params;
this.$root = $root;
this.index = index;
this.name = name;
@@ -22,6 +22,7 @@ class WebView extends BaseComponent {
this.onTitleChange = onTitleChange;
this.zoomFactor = 1.0;
this.loading = false;
this.isActive = isActive;
this.domainUtil = new DomainUtil();
this.systemUtil = new SystemUtil();
this.badgeCount = 0;
@@ -93,6 +94,9 @@ class WebView extends BaseComponent {
}
show() {
// Do not show WebView if another tab was selected and this tab should be in background.
if (!this.isActive()) return;
this.$el.classList.remove('disabled');
this.focus()
this.loading = false;

View File

@@ -58,6 +58,7 @@ class ServerManagerView {
index: index,
url: server.url,
name: server.alias,
isActive: () => {return index == this.activeTabIndex},
onTitleChange: this.updateBadge.bind(this),
nodeIntegration: false
}));
@@ -93,6 +94,7 @@ class ServerManagerView {
index: this.settingsTabIndex,
url: url,
name: "Settings",
isActive: () => {return this.settingsTabIndex == this.activeTabIndex},
onTitleChange: this.updateBadge.bind(this),
nodeIntegration: true
}));
@@ -116,8 +118,8 @@ class ServerManagerView {
this.tabs[index].activate();
this.webviews[index].load();
this.activeTabIndex = index;
this.webviews[index].load();
}
updateBadge() {