mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-23 03:53:53 +00:00
Chainable methods
This commit is contained in:
parent
9fd514637c
commit
e98e4141c5
12
index.js
12
index.js
|
@ -76,12 +76,14 @@ class TabGroup extends EventEmitter {
|
||||||
if (triggerEvent) {
|
if (triggerEvent) {
|
||||||
this.emit("tab-removed", tab, this);
|
this.emit("tab-removed", tab, this);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveTab (tab) {
|
setActiveTab (tab) {
|
||||||
this.removeTab(tab);
|
this.removeTab(tab);
|
||||||
this.tabs.unshift(tab);
|
this.tabs.unshift(tab);
|
||||||
this.emit("tab-active", tab, this);
|
this.emit("tab-active", tab, this);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getActiveTab () {
|
getActiveTab () {
|
||||||
|
@ -90,9 +92,11 @@ class TabGroup extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
activateRecentTab (tab) {
|
activateRecentTab (tab) {
|
||||||
if (this.tabs.length === 0) return null;
|
if (this.tabs.length > 0) {
|
||||||
this.tabs[0].activate();
|
this.tabs[0].activate();
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tab extends EventEmitter {
|
class Tab extends EventEmitter {
|
||||||
|
@ -148,6 +152,7 @@ class Tab extends EventEmitter {
|
||||||
span.innerHTML = title;
|
span.innerHTML = title;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.emit("title-changed", title, this);
|
this.emit("title-changed", title, this);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTitle () {
|
getTitle () {
|
||||||
|
@ -163,6 +168,7 @@ class Tab extends EventEmitter {
|
||||||
span.innerHTML = `<img src="${iconURL}" />`;
|
span.innerHTML = `<img src="${iconURL}" />`;
|
||||||
}
|
}
|
||||||
this.emit("icon-changed", iconURL, this);
|
this.emit("icon-changed", iconURL, this);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getIcon () {
|
getIcon () {
|
||||||
|
@ -201,16 +207,19 @@ class Tab extends EventEmitter {
|
||||||
this.tab.classList.add("active");
|
this.tab.classList.add("active");
|
||||||
this.webview.classList.add("visible");
|
this.webview.classList.add("visible");
|
||||||
this.emit("active", this);
|
this.emit("active", this);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
show () {
|
show () {
|
||||||
if (this.isClosed) return;
|
if (this.isClosed) return;
|
||||||
this.tab.classList.add("visible");
|
this.tab.classList.add("visible");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
hide () {
|
hide () {
|
||||||
if (this.isClosed) return;
|
if (this.isClosed) return;
|
||||||
this.tab.classList.remove("visible");
|
this.tab.classList.remove("visible");
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
flash (flag) {
|
flash (flag) {
|
||||||
|
@ -222,6 +231,7 @@ class Tab extends EventEmitter {
|
||||||
this.tab.classList.remove("flash");
|
this.tab.classList.remove("flash");
|
||||||
this.emit("flash-end", this);
|
this.emit("flash-end", this);
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
move (index) {
|
move (index) {
|
||||||
|
|
Loading…
Reference in a new issue