Added support for icon libraries (e.g. Font Awesome)
This commit is contained in:
parent
43b1fb7ae0
commit
06375a7973
2 changed files with 18 additions and 10 deletions
17
index.js
17
index.js
|
@ -124,6 +124,7 @@ class Tab extends EventEmitter {
|
|||
this.id = id;
|
||||
this.title = args.title;
|
||||
this.iconURL = args.iconURL;
|
||||
this.icon = args.icon;
|
||||
this.closable = args.closable === false ? false : true;
|
||||
this.webviewAttributes = args.webviewAttributes || {};
|
||||
this.webviewAttributes.src = args.src;
|
||||
|
@ -155,20 +156,26 @@ class Tab extends EventEmitter {
|
|||
return this.title;
|
||||
}
|
||||
|
||||
setIcon (iconURL) {
|
||||
setIcon (iconURL, icon) {
|
||||
if (this.isClosed) return;
|
||||
this.iconURL = iconURL;
|
||||
this.icon = icon;
|
||||
let span = this.tabElements.icon;
|
||||
if (iconURL) {
|
||||
span.innerHTML = `<img src="${iconURL}" />`;
|
||||
this.emit("icon-changed", iconURL, this);
|
||||
} else if (icon) {
|
||||
span.innerHTML = `<i class="${icon}"></i>`;
|
||||
this.emit("icon-changed", icon, this);
|
||||
}
|
||||
this.emit("icon-changed", iconURL, this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
getIcon () {
|
||||
if (this.isClosed) return;
|
||||
return this.iconURL;
|
||||
if (this.iconURL) return this.iconURL;
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
activate () {
|
||||
|
@ -247,7 +254,7 @@ const TabPrivate = {
|
|||
}
|
||||
|
||||
this.setTitle(this.title);
|
||||
this.setIcon(this.iconURL);
|
||||
this.setIcon(this.iconURL, this.icon);
|
||||
TabPrivate.initTabButtons.bind(this)();
|
||||
TabPrivate.initTabClickHandler.bind(this)();
|
||||
|
||||
|
@ -298,4 +305,4 @@ const TabPrivate = {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = TabGroup;
|
||||
module.exports = TabGroup;
|
Loading…
Add table
Add a link
Reference in a new issue