mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-23 12:03:54 +00:00
Added closing event
This commit is contained in:
parent
a2a5ae7f3c
commit
98bd8edd4d
|
@ -123,6 +123,10 @@ Toggle the "flash" class on the tab. `tab.unflash()` is an alias to `tab.flash(f
|
||||||
|
|
||||||
Close the tab (and activate another tab if relevant). When `force` is set to `true` the tab will be closed even if it is not `closable`.
|
Close the tab (and activate another tab if relevant). When `force` is set to `true` the tab will be closed even if it is not `closable`.
|
||||||
|
|
||||||
|
#### Prevent a tab from closing after it was created
|
||||||
|
|
||||||
|
Use the `closing` event and set the `closable` property to false
|
||||||
|
|
||||||
### Access webview element
|
### Access webview element
|
||||||
|
|
||||||
You can access the webview element and use its methods with through the `Tab.webview` attribute. See [webview documentation](http://electron.atom.io/docs/api/web-view-tag/#methods).
|
You can access the webview element and use its methods with through the `Tab.webview` attribute. See [webview documentation](http://electron.atom.io/docs/api/web-view-tag/#methods).
|
||||||
|
@ -148,6 +152,7 @@ The following events are available:
|
||||||
* `tab.on("flash", (tab) => { ... });`
|
* `tab.on("flash", (tab) => { ... });`
|
||||||
* `tab.on("unflash", (tab) => { ... });`
|
* `tab.on("unflash", (tab) => { ... });`
|
||||||
* `tab.on("close", (tab) => { ... });`
|
* `tab.on("close", (tab) => { ... });`
|
||||||
|
* `tab.on("closing", (tab) => { ... });`
|
||||||
|
|
||||||
## Drag and drop support
|
## Drag and drop support
|
||||||
|
|
||||||
|
|
2
index.js
2
index.js
|
@ -225,6 +225,8 @@ class Tab extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
close (force) {
|
close (force) {
|
||||||
|
this.emit("closing", this);
|
||||||
|
if (typeof force !== 'boolean') force = false;
|
||||||
if (this.isClosed || (!this.closable && !force)) return;
|
if (this.isClosed || (!this.closable && !force)) return;
|
||||||
this.isClosed = true;
|
this.isClosed = true;
|
||||||
let tabGroup = this.tabGroup;
|
let tabGroup = this.tabGroup;
|
||||||
|
|
Loading…
Reference in a new issue