From cc838640a5a9dd518917125e8b55056edc1c593f Mon Sep 17 00:00:00 2001 From: Robin Riclet Date: Tue, 4 Apr 2017 15:05:24 +0200 Subject: [PATCH 1/2] Added event closing --- README.md | 3 ++- index.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 24d3a35..3ef3e0d 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ The following events are available: * `tab.on("flash", (tab) => { ... });` * `tab.on("unflash", (tab) => { ... });` * `tab.on("close", (tab) => { ... });` +* `tab.on("closing", (tab) => { ... });` ## Drag and drop support @@ -182,4 +183,4 @@ var tabGroup = new TabGroup({ ## License -The MIT License (MIT) - Copyright (c) 2016 Thomas Brouard \ No newline at end of file +The MIT License (MIT) - Copyright (c) 2016 Thomas Brouard diff --git a/index.js b/index.js index 2ffb243..1d0dea8 100644 --- a/index.js +++ b/index.js @@ -225,6 +225,7 @@ class Tab extends EventEmitter { } close (force) { + this.emit("closing", this); if (this.isClosed || (!this.closable && !force)) return; this.isClosed = true; let tabGroup = this.tabGroup; @@ -294,13 +295,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; @@ -308,7 +309,7 @@ const TabPrivate = { this.webview.setAttribute(key, attrs[key]); } } - + this.tabGroup.viewContainer.appendChild(this.webview); } }; From 218449d56af92434fa5871506c00ab16c5af32c7 Mon Sep 17 00:00:00 2001 From: Robin Riclet Date: Tue, 4 Apr 2017 15:37:53 +0200 Subject: [PATCH 2/2] Restored whitespaces --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1d0dea8..77863f3 100644 --- a/index.js +++ b/index.js @@ -295,13 +295,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; @@ -309,9 +309,9 @@ const TabPrivate = { this.webview.setAttribute(key, attrs[key]); } } - + this.tabGroup.viewContainer.appendChild(this.webview); } }; -module.exports = TabGroup; \ No newline at end of file +module.exports = TabGroup;