mirror of
https://ark.sudovanilla.org/Korbs/electron-tabs.git
synced 2024-12-23 03:53:53 +00:00
Keep config in a separate object
This commit is contained in:
parent
14037c2e59
commit
9105285e2e
18
index.js
18
index.js
|
@ -27,12 +27,14 @@ if (!document) {
|
||||||
|
|
||||||
class TabGroup {
|
class TabGroup {
|
||||||
constructor (args) {
|
constructor (args) {
|
||||||
this.tabContainerSelector = args.tabContainerSelector || ".tabs-tabcontainer";
|
let options = this.options = {
|
||||||
this.tabContainer = document.querySelector(this.tabContainerSelector);
|
tabContainerSelector: args.tabContainerSelector || ".tabs-tabcontainer",
|
||||||
this.viewContainerSelector = args.viewContainerSelector || ".tabs-viewcontainer";
|
viewContainerSelector: args.viewContainerSelector || ".tabs-viewcontainer",
|
||||||
this.viewContainer = document.querySelector(this.viewContainerSelector);
|
tabClass: args.tabClass || "tabs-tab",
|
||||||
this.tabClass = args.tabClass || "tabs-tab";
|
viewClass: args.viewClass || "tabs-view"
|
||||||
this.viewClass = args.viewClass || "tabs-view";
|
};
|
||||||
|
this.tabContainer = document.querySelector(options.tabContainerSelector);
|
||||||
|
this.viewContainer = document.querySelector(options.viewContainerSelector);
|
||||||
this.tabs = [];
|
this.tabs = [];
|
||||||
this.newTabId = 0;
|
this.newTabId = 0;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +93,7 @@ class Tab {
|
||||||
initTab () {
|
initTab () {
|
||||||
this.tab = document.createElement("div");
|
this.tab = document.createElement("div");
|
||||||
this.setTitle(this.title);
|
this.setTitle(this.title);
|
||||||
this.tab.classList.add(this.tabGroup.tabClass);
|
this.tab.classList.add(this.tabGroup.options.tabClass);
|
||||||
this.tab.addEventListener("click", this.activate.bind(this), false);
|
this.tab.addEventListener("click", this.activate.bind(this), false);
|
||||||
this.tabGroup.tabContainer.appendChild(this.tab);
|
this.tabGroup.tabContainer.appendChild(this.tab);
|
||||||
// TODO: icon
|
// TODO: icon
|
||||||
|
@ -101,7 +103,7 @@ class Tab {
|
||||||
|
|
||||||
initWebview () {
|
initWebview () {
|
||||||
this.webview = document.createElement("webview");
|
this.webview = document.createElement("webview");
|
||||||
this.webview.classList.add(this.tabGroup.viewClass);
|
this.webview.classList.add(this.tabGroup.options.viewClass);
|
||||||
if (this.webviewAttributes) {
|
if (this.webviewAttributes) {
|
||||||
let attrs = this.webviewAttributes;
|
let attrs = this.webviewAttributes;
|
||||||
for (let key in attrs) {
|
for (let key in attrs) {
|
||||||
|
|
Loading…
Reference in a new issue