From 84c6d611563c19a8c19c2cbb2d0c5ce70f017502 Mon Sep 17 00:00:00 2001 From: Bastian Date: Thu, 16 Feb 2017 14:24:00 +0100 Subject: [PATCH] Added "webview-ready" Event This event is fired after the "did-finish-load" event of the webview of a tab was fired. --- README.md | 1 + index.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index b94619e..c935914 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ The following events are available: * `tabGroup.on("tab-added", (tab, tabGroup) => { ... });` * `tabGroup.on("tab-removed", (tab, tabGroup) => { ... });` * `tabGroup.on("tab-active", (tab, tabGroup) => { ... });` +* `tab.on("webview-ready", (title, tab) => { ... });` * `tab.on("title-changed", (title, tab) => { ... });` * `tab.on("icon-changed", (icon, tab) => { ... });` * `tab.on("active", (tab) => { ... });` diff --git a/index.js b/index.js index 5764a7d..2ffb243 100644 --- a/index.js +++ b/index.js @@ -294,6 +294,13 @@ const TabPrivate = { initWebview: function () { this.webview = document.createElement("webview"); + + const tabWebviewDidFinishLoadHandler = function (e) { + this.emit("webview-ready", this); + }; + + this.webview.addEventListener("did-finish-load", tabWebviewDidFinishLoadHandler.bind(this), false); + this.webview.classList.add(this.tabGroup.options.viewClass); if (this.webviewAttributes) { let attrs = this.webviewAttributes; @@ -301,6 +308,7 @@ const TabPrivate = { this.webview.setAttribute(key, attrs[key]); } } + this.tabGroup.viewContainer.appendChild(this.webview); } };