diff --git a/demo/electron-tabs.html b/demo/electron-tabs.html index 0049eef..2850c97 100644 --- a/demo/electron-tabs.html +++ b/demo/electron-tabs.html @@ -11,22 +11,27 @@ diff --git a/dist/electron-tabs.js b/dist/electron-tabs.js index 39601a8..4304237 100644 --- a/dist/electron-tabs.js +++ b/dist/electron-tabs.js @@ -1,4 +1,4 @@ -var $5580883c37846f86$export$2e2bcd8739ae039 = ".etabs-tabgroup {\n width: 100%;\n height: 32px;\n background-color: #ccc;\n cursor: default;\n font: caption;\n font-size: 14px;\n -webkit-user-select: none;\n user-select: none;\n display: none;\n}\n\n.etabs-tabgroup.visible {\n\tdisplay: block;\n}\n\n.etabs-tabs {\n}\n\n.etabs-tab {\n display: none;\n position: relative;\n color: #333;\n height: 22px;\n padding: 6px 8px 4px;\n border: 1px solid #aaa;\n border-bottom: none;\n border-left: none;\n background: linear-gradient(to bottom, rgba(234,234,234,1) 0%,rgba(204,204,204,1) 100%);\n font: caption;\n font-size: 14px;\n background-color: #ccc;\n cursor: default;\n}\n\n/* Dragula */\n.etabs-tab.gu-mirror {\n padding-bottom: 0;\n}\n\n.etabs-tab:first-child {\n border-left: none;\n}\n\n.etabs-tab.visible {\n display: inline-block;\n float: left;\n}\n\n.etabs-tab.active {\n background: #fff;\n}\n\n.etabs-tab.flash {\n background: linear-gradient(to bottom, rgba(255,243,170,1) 0%,rgba(255,227,37,1) 100%);\n}\n\n.etabs-buttons {\n float: left;\n}\n\n.etabs-buttons button {\n float: left;\n color: #333;\n background: none;\n border: none;\n font-size: 12px;\n margin-top: 6px;\n border-radius: 2px;\n margin-left: 4px;\n width: 20px;\n text-align: center;\n padding: 4px 0;\n}\n\n.etabs-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-tab-badge {\n position: absolute;\n right: 0;\n top: -7px;\n background: red;\n border-radius: 100%;\n text-align: center;\n font-size: 10px;\n padding: 0 5px;\n}\n\n.etabs-tab-badge.hidden {\n display: none;\n}\n\n.etabs-tab-icon {\n display: inline-block;\n height: 16px;\n}\n\n.etabs-tab-icon img {\n max-width: 16px;\n max-height: 16px;\n}\n\n.etabs-tab-title {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons button {\n display: inline-block;\n color: #333;\n background: none;\n border: none;\n width: 20px;\n text-align: center;\n border-radius: 2px;\n}\n\n.etabs-tab-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-views {\n position: relative;\n border-top: 1px solid #aaa;\n height: calc(100vh - 33px);\n}\n\n.etab-view {\n position: relative;\n}\n\nwebview {\n position: absolute;\n visibility: hidden;\n width: 100%;\n height: 100%;\n}\nwebview.visible {\n visibility: visible;\n}\n"; +var $5580883c37846f86$export$2e2bcd8739ae039 = ".etabs-tabgroup {\n width: 100%;\n height: 32px;\n background-color: #ccc;\n cursor: default;\n font: caption;\n font-size: 14px;\n -webkit-user-select: none;\n user-select: none;\n display: none;\n}\n\n.etabs-tabgroup.visible {\n\tdisplay: block;\n}\n\n.etabs-tab {\n display: none;\n position: relative;\n color: #333;\n height: 22px;\n padding: 6px 8px 4px;\n border: 1px solid #aaa;\n border-bottom: none;\n border-left: none;\n background: linear-gradient(to bottom, rgba(234,234,234,1) 0%,rgba(204,204,204,1) 100%);\n font: caption;\n font-size: 14px;\n background-color: #ccc;\n cursor: default;\n}\n\n/* Dragula */\n.etabs-tab.gu-mirror {\n padding-bottom: 0;\n}\n\n.etabs-tab:first-child {\n border-left: none;\n}\n\n.etabs-tab.visible {\n display: inline-block;\n}\n\n.etabs-tab.active {\n background: #fff;\n}\n\n.etabs-tab.flash {\n background: linear-gradient(to bottom, rgba(255,243,170,1) 0%,rgba(255,227,37,1) 100%);\n}\n\n.etabs-buttons {\n float: left;\n}\n\n.etabs-buttons button {\n float: left;\n color: #333;\n background: none;\n border: none;\n font-size: 12px;\n margin-top: 6px;\n border-radius: 2px;\n margin-left: 4px;\n width: 20px;\n text-align: center;\n padding: 4px 0;\n}\n\n.etabs-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-tab-badge {\n position: absolute;\n right: 0;\n top: -7px;\n background: red;\n border-radius: 100%;\n text-align: center;\n font-size: 10px;\n padding: 0 5px;\n}\n\n.etabs-tab-badge.hidden {\n display: none;\n}\n\n.etabs-tab-icon {\n display: inline-block;\n height: 16px;\n}\n\n.etabs-tab-icon img {\n max-width: 16px;\n max-height: 16px;\n}\n\n.etabs-tab-title {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons button {\n display: inline-block;\n color: #333;\n background: none;\n border: none;\n width: 20px;\n text-align: center;\n border-radius: 2px;\n}\n\n.etabs-tab-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-views {\n position: relative;\n border-top: 1px solid #aaa;\n height: calc(100vh - 33px);\n}\n\n.etab-view {\n position: relative;\n}\n\nwebview {\n position: absolute;\n visibility: hidden;\n width: 100%;\n height: 100%;\n}\n\nwebview.visible {\n visibility: visible;\n}\n"; if (!document) throw Error("electron-tabs module must be called in renderer process"); @@ -44,6 +44,9 @@ class $4fa36e821943b400$var$TabGroup extends HTMLElement { $4fa36e821943b400$var$TabGroupPrivate.initVisibility.bind(this)(); if (typeof this.options.ready === "function") this.options.ready(this); } + setNewTab(newTab) { + this.options.newTab = newTab; + } addTab(args = this.options.newTab) { if (typeof args === "function") args = args(this); let id = this.newTabId; @@ -166,8 +169,8 @@ class $4fa36e821943b400$var$Tab extends EventTarget { this.badge = badge; if (badge) { span.innerHTML = badge; - span.classList.remove('hidden'); - } else span.classList.add('hidden'); + span.classList.remove("hidden"); + } else span.classList.add("hidden"); this.emit("badge-changed", badge, this); } getBadge() { diff --git a/dist/electron-tabs.js.map b/dist/electron-tabs.js.map index 1846e7d..6d4ccdd 100644 --- a/dist/electron-tabs.js.map +++ b/dist/electron-tabs.js.map @@ -1 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AG,CAAC,SAAS,EAAE,uCAAiB,CAAC,CAAC;AAEhD,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,8BAAQ,CAAC,CAAC","sources":["src/index.js","src/style.inline.css"],"sourcesContent":["import styles from \"./style.inline.css\";\n\nif (!document) {\n throw Error(\"electron-tabs module must be called in renderer process\");\n}\n\nclass TabGroup extends HTMLElement {\n constructor () {\n super();\n\n // Options\n this.options = {\n closeButtonText: this.getAttribute(\"close-button-text\") || \"×\",\n newTabButtonText: this.getAttribute(\"new-tab-button-text\") || \"+\",\n visibilityThreshold: this.getAttribute(\"visibility-threshold\") || 0,\n tabClass: this.getAttribute(\"tab-class\") || \"etabs-tab\",\n viewClass: this.getAttribute(\"view-class\") || \"etabs-view\"\n // TODO: replace this callback\n // ready: args.ready\n };\n\n // Create custom element\n const shadow = this.attachShadow({mode: \"open\"});\n\n const wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"class\", \"etabs\");\n\n const tabgroup = document.createElement(\"div\");\n tabgroup.setAttribute(\"class\", \"etabs-tabgroup\");\n wrapper.appendChild(tabgroup);\n\n const tabContainer = document.createElement(\"div\");\n tabContainer.setAttribute(\"class\", \"etabs-tabs\");\n tabgroup.appendChild(tabContainer);\n this.tabContainer = tabContainer;\n\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.setAttribute(\"class\", \"etabs-buttons\");\n tabgroup.appendChild(buttonContainer);\n this.buttonContainer = buttonContainer;\n\n const viewContainer = document.createElement(\"div\");\n viewContainer.setAttribute(\"class\", \"etabs-views\");\n wrapper.appendChild(viewContainer);\n this.viewContainer = viewContainer;\n\n const style = document.createElement(\"style\");\n style.textContent = styles;\n\n shadow.appendChild(style);\n shadow.appendChild(wrapper);\n\n this.tabs = [];\n this.newTabId = 0;\n TabGroupPrivate.initNewTabButton.bind(this)();\n TabGroupPrivate.initVisibility.bind(this)();\n if (typeof this.options.ready === \"function\") {\n this.options.ready(this);\n }\n }\n\n addTab (args = this.options.newTab) {\n if (typeof args === \"function\") {\n args = args(this);\n }\n let id = this.newTabId;\n this.newTabId++;\n let tab = new Tab(this, id, args);\n this.tabs.push(tab);\n // Don't call tab.activate() before a tab is referenced in this.tabs\n if (args.active === true) {\n tab.activate();\n }\n this.emit(\"tab-added\", tab, this);\n return tab;\n }\n\n getTab (id) {\n for (let i in this.tabs) {\n if (this.tabs[i].id === id) {\n return this.tabs[i];\n }\n }\n return null;\n }\n\n getTabByPosition (position) {\n let fromRight = position < 0;\n for (let i in this.tabs) {\n if (this.tabs[i].getPosition(fromRight) === position) {\n return this.tabs[i];\n }\n }\n return null;\n }\n\n getTabByRelPosition (position) {\n position = this.getActiveTab().getPosition() + position;\n if (position <= 0) {\n return null;\n }\n return this.getTabByPosition(position);\n }\n\n getNextTab () {\n return this.getTabByRelPosition(1);\n }\n\n getPreviousTab () {\n return this.getTabByRelPosition(-1);\n }\n\n getTabs () {\n return this.tabs.slice();\n }\n\n eachTab (fn) {\n this.getTabs().forEach(fn);\n return this;\n }\n\n getActiveTab () {\n if (this.tabs.length === 0) return null;\n return this.tabs[0];\n }\n}\n\nconst TabGroupPrivate = {\n initNewTabButton: function () {\n if (!this.options.newTab) return;\n let button = this.buttonContainer.appendChild(document.createElement(\"button\"));\n button.classList.add(`${this.options.tabClass}-button-new`);\n button.innerHTML = this.options.newTabButtonText;\n button.addEventListener(\"click\", this.addTab.bind(this, undefined), false);\n },\n\n initVisibility: function () {\n function toggleTabsVisibility(tab, tabGroup) {\n var visibilityThreshold = this.options.visibilityThreshold;\n var el = tabGroup.tabContainer.parentNode;\n if (this.tabs.length >= visibilityThreshold) {\n el.classList.add(\"visible\");\n } else {\n el.classList.remove(\"visible\");\n }\n }\n\n this.on(\"tab-added\", toggleTabsVisibility);\n this.on(\"tab-removed\", toggleTabsVisibility);\n },\n\n removeTab: function (tab, triggerEvent) {\n let id = tab.id;\n for (let i in this.tabs) {\n if (this.tabs[i].id === id) {\n this.tabs.splice(i, 1);\n break;\n }\n }\n if (triggerEvent) {\n this.emit(\"tab-removed\", tab, this);\n }\n return this;\n },\n\n setActiveTab: function (tab) {\n TabGroupPrivate.removeTab.bind(this)(tab);\n this.tabs.unshift(tab);\n this.emit(\"tab-active\", tab, this);\n return this;\n },\n\n activateRecentTab: function (tab) {\n if (this.tabs.length > 0) {\n this.tabs[0].activate();\n }\n return this;\n }\n};\n\nclass Tab extends EventTarget {\n constructor (tabGroup, id, args) {\n super();\n this.tabGroup = tabGroup;\n this.id = id;\n this.title = args.title;\n this.badge = args.badge;\n this.iconURL = args.iconURL;\n this.icon = args.icon;\n this.closable = args.closable === false ? false : true;\n this.webviewAttributes = args.webviewAttributes || {};\n this.webviewAttributes.src = args.src;\n this.tabElements = {};\n TabPrivate.initTab.bind(this)();\n TabPrivate.initWebview.bind(this)();\n if (args.visible !== false) {\n this.show();\n }\n if (typeof args.ready === \"function\") {\n args.ready(this);\n }\n }\n\n setTitle (title) {\n if (this.isClosed) return;\n let span = this.tabElements.title;\n span.innerHTML = title;\n span.title = title;\n this.title = title;\n this.emit(\"title-changed\", title, this);\n return this;\n }\n\n getTitle () {\n if (this.isClosed) return;\n return this.title;\n }\n\n setBadge (badge) {\n if (this.isClosed) return;\n let span = this.tabElements.badge;\n this.badge = badge;\n\n if (badge) {\n span.innerHTML = badge;\n span.classList.remove('hidden');\n } else {\n span.classList.add('hidden');\n }\n\n this.emit(\"badge-changed\", badge, this);\n }\n\n getBadge () {\n if (this.isClosed) return;\n return this.badge;\n }\n\n setIcon (iconURL, icon) {\n if (this.isClosed) return;\n this.iconURL = iconURL;\n this.icon = icon;\n let span = this.tabElements.icon;\n if (iconURL) {\n span.innerHTML = ``;\n this.emit(\"icon-changed\", iconURL, this);\n } else if (icon) {\n span.innerHTML = ``;\n this.emit(\"icon-changed\", icon, this);\n }\n\n return this;\n }\n\n getIcon () {\n if (this.isClosed) return;\n if (this.iconURL) return this.iconURL;\n return this.icon;\n }\n\n setPosition (newPosition) {\n let tabContainer = this.tabGroup.tabContainer;\n let tabs = tabContainer.children;\n let oldPosition = this.getPosition() - 1;\n\n if (newPosition < 0) {\n newPosition += tabContainer.childElementCount;\n\n if (newPosition < 0) {\n newPosition = 0;\n }\n } else {\n if (newPosition > tabContainer.childElementCount) {\n newPosition = tabContainer.childElementCount;\n }\n\n // Make 1 be leftmost position\n newPosition--;\n }\n\n if (newPosition > oldPosition) {\n newPosition++;\n }\n\n tabContainer.insertBefore(tabs[oldPosition], tabs[newPosition]);\n\n return this;\n }\n\n getPosition (fromRight) {\n let position = 0;\n let tab = this.tab;\n while ((tab = tab.previousSibling) != null) position++;\n\n if (fromRight === true) {\n position -= this.tabGroup.tabContainer.childElementCount;\n }\n\n if (position >= 0) {\n position++;\n }\n\n return position;\n }\n\n activate () {\n if (this.isClosed) return;\n let activeTab = this.tabGroup.getActiveTab();\n if (activeTab) {\n activeTab.tab.classList.remove(\"active\");\n activeTab.webview.classList.remove(\"visible\");\n activeTab.emit(\"inactive\", activeTab);\n }\n TabGroupPrivate.setActiveTab.bind(this.tabGroup)(this);\n this.tab.classList.add(\"active\");\n this.webview.classList.add(\"visible\");\n this.webview.focus();\n this.emit(\"active\", this);\n return this;\n }\n\n show (flag) {\n if (this.isClosed) return;\n if (flag !== false) {\n this.tab.classList.add(\"visible\");\n this.emit(\"visible\", this);\n } else {\n this.tab.classList.remove(\"visible\");\n this.emit(\"hidden\", this);\n }\n return this;\n }\n\n hide () {\n return this.show(false);\n }\n\n flash (flag) {\n if (this.isClosed) return;\n if (flag !== false) {\n this.tab.classList.add(\"flash\");\n this.emit(\"flash\", this);\n } else {\n this.tab.classList.remove(\"flash\");\n this.emit(\"unflash\", this);\n }\n return this;\n }\n\n unflash () {\n return this.flash(false);\n }\n\n hasClass (classname) {\n return this.tab.classList.contains(classname);\n }\n\n close (force) {\n const abortController = new AbortController();\n const abort = () => abortController.abort();\n this.emit(\"closing\", this, abort);\n\n const abortSignal = abortController.signal;\n if (this.isClosed || (!this.closable && !force) || abortSignal.aborted) return;\n\n this.isClosed = true;\n let tabGroup = this.tabGroup;\n tabGroup.tabContainer.removeChild(this.tab);\n tabGroup.viewContainer.removeChild(this.webview);\n let activeTab = this.tabGroup.getActiveTab();\n TabGroupPrivate.removeTab.bind(tabGroup)(this, true);\n\n this.emit(\"close\", this);\n\n if (activeTab.id === this.id) {\n TabGroupPrivate.activateRecentTab.bind(tabGroup)();\n }\n }\n}\n\nconst TabPrivate = {\n initTab: function () {\n let tabClass = this.tabGroup.options.tabClass;\n\n // Create tab element\n let tab = this.tab = document.createElement(\"div\");\n tab.classList.add(tabClass);\n for (let el of [\"icon\", \"title\", \"buttons\", \"badge\"]) {\n let span = tab.appendChild(document.createElement(\"span\"));\n span.classList.add(`${tabClass}-${el}`);\n this.tabElements[el] = span;\n }\n\n this.setTitle(this.title);\n this.setBadge(this.badge);\n this.setIcon(this.iconURL, this.icon);\n TabPrivate.initTabButtons.bind(this)();\n TabPrivate.initTabClickHandler.bind(this)();\n\n this.tabGroup.tabContainer.appendChild(this.tab);\n },\n\n initTabButtons: function () {\n let container = this.tabElements.buttons;\n let tabClass = this.tabGroup.options.tabClass;\n if (this.closable) {\n let button = container.appendChild(document.createElement(\"button\"));\n button.classList.add(`${tabClass}-button-close`);\n button.innerHTML = this.tabGroup.options.closeButtonText;\n button.addEventListener(\"click\", this.close.bind(this, false), false);\n }\n },\n\n initTabClickHandler: function () {\n // Mouse up\n const tabClickHandler = function (e) {\n if (this.isClosed) return;\n if (e.which === 2) {\n this.close();\n }\n };\n this.tab.addEventListener(\"mouseup\", tabClickHandler.bind(this), false);\n // Mouse down\n const tabMouseDownHandler = function (e) {\n if (this.isClosed) return;\n if (e.which === 1) {\n if (e.target.matches(\"button\")) return;\n this.activate();\n }\n };\n this.tab.addEventListener(\"mousedown\", tabMouseDownHandler.bind(this), false);\n },\n\n initWebview: function () {\n const webview = this.webview = document.createElement(\"webview\");\n\n const tabWebviewDidFinishLoadHandler = function (e) {\n this.emit(\"webview-ready\", this);\n };\n\n this.webview.addEventListener(\"did-finish-load\", tabWebviewDidFinishLoadHandler.bind(this), false);\n\n const tabWebviewDomReadyHandler = function (e) {\n // Remove this once https://github.com/electron/electron/issues/14474 is fixed\n webview.blur();\n webview.focus();\n this.emit(\"webview-dom-ready\", this);\n };\n\n this.webview.addEventListener(\"dom-ready\", tabWebviewDomReadyHandler.bind(this), false);\n\n this.webview.classList.add(this.tabGroup.options.viewClass);\n if (this.webviewAttributes) {\n let attrs = this.webviewAttributes;\n for (let key in attrs) {\n const attr = attrs[key];\n if (attr === false) continue;\n this.webview.setAttribute(key, attr);\n }\n }\n\n this.tabGroup.viewContainer.appendChild(this.webview);\n }\n};\n\n/**\n * This makes the browser EventTarget API work similar to EventEmitter\n */\n const eventEmitterMixin = {\n emit (type, ...args) {\n this.dispatchEvent(new CustomEvent(type, { detail: args }));\n },\n\n on (type, fn) {\n this.addEventListener(type, ({ detail }) => fn.apply(this, detail));\n },\n\n once (type, fn) {\n this.addEventListener(type, ({ detail }) => fn.apply(this, detail), { once: true });\n }\n};\n\nObject.assign(TabGroup.prototype, eventEmitterMixin);\nObject.assign(Tab.prototype, eventEmitterMixin);\n\ncustomElements.define(\"tab-group\", TabGroup);\n",".etabs-tabgroup {\n width: 100%;\n height: 32px;\n background-color: #ccc;\n cursor: default;\n font: caption;\n font-size: 14px;\n -webkit-user-select: none;\n user-select: none;\n display: none;\n}\n\n.etabs-tabgroup.visible {\n\tdisplay: block;\n}\n\n.etabs-tabs {\n}\n\n.etabs-tab {\n display: none;\n position: relative;\n color: #333;\n height: 22px;\n padding: 6px 8px 4px;\n border: 1px solid #aaa;\n border-bottom: none;\n border-left: none;\n background: linear-gradient(to bottom, rgba(234,234,234,1) 0%,rgba(204,204,204,1) 100%);\n font: caption;\n font-size: 14px;\n background-color: #ccc;\n cursor: default;\n}\n\n/* Dragula */\n.etabs-tab.gu-mirror {\n padding-bottom: 0;\n}\n\n.etabs-tab:first-child {\n border-left: none;\n}\n\n.etabs-tab.visible {\n display: inline-block;\n float: left;\n}\n\n.etabs-tab.active {\n background: #fff;\n}\n\n.etabs-tab.flash {\n background: linear-gradient(to bottom, rgba(255,243,170,1) 0%,rgba(255,227,37,1) 100%);\n}\n\n.etabs-buttons {\n float: left;\n}\n\n.etabs-buttons button {\n float: left;\n color: #333;\n background: none;\n border: none;\n font-size: 12px;\n margin-top: 6px;\n border-radius: 2px;\n margin-left: 4px;\n width: 20px;\n text-align: center;\n padding: 4px 0;\n}\n\n.etabs-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-tab-badge {\n position: absolute;\n right: 0;\n top: -7px;\n background: red;\n border-radius: 100%;\n text-align: center;\n font-size: 10px;\n padding: 0 5px;\n}\n\n.etabs-tab-badge.hidden {\n display: none;\n}\n\n.etabs-tab-icon {\n display: inline-block;\n height: 16px;\n}\n\n.etabs-tab-icon img {\n max-width: 16px;\n max-height: 16px;\n}\n\n.etabs-tab-title {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons button {\n display: inline-block;\n color: #333;\n background: none;\n border: none;\n width: 20px;\n text-align: center;\n border-radius: 2px;\n}\n\n.etabs-tab-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-views {\n position: relative;\n border-top: 1px solid #aaa;\n height: calc(100vh - 33px);\n}\n\n.etab-view {\n position: relative;\n}\n\nwebview {\n position: absolute;\n visibility: hidden;\n width: 100%;\n height: 100%;\n}\nwebview.visible {\n visibility: visible;\n}\n"],"names":[],"version":3,"file":"electron-tabs.js.map"} \ No newline at end of file +{"mappings":"ACAA,IAAA,wCAAs2E,GAAv1E,u1EAAu1E;;ADAt2E;AAEA,IAAI,CAAC,QAAQ,EACX,MAAM,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAGzE,MAAM,8BAAQ,SAAS,WAAW;IAChC,aAAe;QACb,KAAK,EAAE,CAAC;QAER,UAAU;QACV,IAAI,CAAC,OAAO,GAAG;YACb,eAAe,E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document) {\n throw Error(\"electron-tabs module must be called in renderer process\");\n}\n\nclass TabGroup extends HTMLElement {\n constructor () {\n super();\n\n // Options\n this.options = {\n closeButtonText: this.getAttribute(\"close-button-text\") || \"×\",\n newTabButtonText: this.getAttribute(\"new-tab-button-text\") || \"+\",\n visibilityThreshold: this.getAttribute(\"visibility-threshold\") || 0,\n tabClass: this.getAttribute(\"tab-class\") || \"etabs-tab\",\n viewClass: this.getAttribute(\"view-class\") || \"etabs-view\"\n // TODO: replace this callback\n // ready: args.ready\n };\n\n // Create custom element\n const shadow = this.attachShadow({mode: \"open\"});\n\n const wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"class\", \"etabs\");\n\n const tabgroup = document.createElement(\"div\");\n tabgroup.setAttribute(\"class\", \"etabs-tabgroup\");\n wrapper.appendChild(tabgroup);\n\n const tabContainer = document.createElement(\"div\");\n tabContainer.setAttribute(\"class\", \"etabs-tabs\");\n tabgroup.appendChild(tabContainer);\n this.tabContainer = tabContainer;\n\n const buttonContainer = document.createElement(\"div\");\n buttonContainer.setAttribute(\"class\", \"etabs-buttons\");\n tabgroup.appendChild(buttonContainer);\n this.buttonContainer = buttonContainer;\n\n const viewContainer = document.createElement(\"div\");\n viewContainer.setAttribute(\"class\", \"etabs-views\");\n wrapper.appendChild(viewContainer);\n this.viewContainer = viewContainer;\n\n const style = document.createElement(\"style\");\n style.textContent = styles;\n\n shadow.appendChild(style);\n shadow.appendChild(wrapper);\n\n this.tabs = [];\n this.newTabId = 0;\n TabGroupPrivate.initNewTabButton.bind(this)();\n TabGroupPrivate.initVisibility.bind(this)();\n if (typeof this.options.ready === \"function\") {\n this.options.ready(this);\n }\n }\n\n setNewTab (newTab) {\n this.options.newTab = newTab;\n }\n\n addTab (args = this.options.newTab) {\n if (typeof args === \"function\") {\n args = args(this);\n }\n let id = this.newTabId;\n this.newTabId++;\n let tab = new Tab(this, id, args);\n this.tabs.push(tab);\n // Don't call tab.activate() before a tab is referenced in this.tabs\n if (args.active === true) {\n tab.activate();\n }\n this.emit(\"tab-added\", tab, this);\n return tab;\n }\n\n getTab (id) {\n for (let i in this.tabs) {\n if (this.tabs[i].id === id) {\n return this.tabs[i];\n }\n }\n return null;\n }\n\n getTabByPosition (position) {\n let fromRight = position < 0;\n for (let i in this.tabs) {\n if (this.tabs[i].getPosition(fromRight) === position) {\n return this.tabs[i];\n }\n }\n return null;\n }\n\n getTabByRelPosition (position) {\n position = this.getActiveTab().getPosition() + position;\n if (position <= 0) {\n return null;\n }\n return this.getTabByPosition(position);\n }\n\n getNextTab () {\n return this.getTabByRelPosition(1);\n }\n\n getPreviousTab () {\n return this.getTabByRelPosition(-1);\n }\n\n getTabs () {\n return this.tabs.slice();\n }\n\n eachTab (fn) {\n this.getTabs().forEach(fn);\n return this;\n }\n\n getActiveTab () {\n if (this.tabs.length === 0) return null;\n return this.tabs[0];\n }\n}\n\nconst TabGroupPrivate = {\n initNewTabButton: function () {\n if (!this.options.newTab) return;\n let button = this.buttonContainer.appendChild(document.createElement(\"button\"));\n button.classList.add(`${this.options.tabClass}-button-new`);\n button.innerHTML = this.options.newTabButtonText;\n button.addEventListener(\"click\", this.addTab.bind(this, undefined), false);\n },\n\n initVisibility: function () {\n function toggleTabsVisibility(tab, tabGroup) {\n var visibilityThreshold = this.options.visibilityThreshold;\n var el = tabGroup.tabContainer.parentNode;\n if (this.tabs.length >= visibilityThreshold) {\n el.classList.add(\"visible\");\n } else {\n el.classList.remove(\"visible\");\n }\n }\n\n this.on(\"tab-added\", toggleTabsVisibility);\n this.on(\"tab-removed\", toggleTabsVisibility);\n },\n\n removeTab: function (tab, triggerEvent) {\n let id = tab.id;\n for (let i in this.tabs) {\n if (this.tabs[i].id === id) {\n this.tabs.splice(i, 1);\n break;\n }\n }\n if (triggerEvent) {\n this.emit(\"tab-removed\", tab, this);\n }\n return this;\n },\n\n setActiveTab: function (tab) {\n TabGroupPrivate.removeTab.bind(this)(tab);\n this.tabs.unshift(tab);\n this.emit(\"tab-active\", tab, this);\n return this;\n },\n\n activateRecentTab: function (tab) {\n if (this.tabs.length > 0) {\n this.tabs[0].activate();\n }\n return this;\n }\n};\n\nclass Tab extends EventTarget {\n constructor (tabGroup, id, args) {\n super();\n this.tabGroup = tabGroup;\n this.id = id;\n this.title = args.title;\n this.badge = args.badge;\n this.iconURL = args.iconURL;\n this.icon = args.icon;\n this.closable = args.closable === false ? false : true;\n this.webviewAttributes = args.webviewAttributes || {};\n this.webviewAttributes.src = args.src;\n this.tabElements = {};\n TabPrivate.initTab.bind(this)();\n TabPrivate.initWebview.bind(this)();\n if (args.visible !== false) {\n this.show();\n }\n if (typeof args.ready === \"function\") {\n args.ready(this);\n }\n }\n\n setTitle (title) {\n if (this.isClosed) return;\n let span = this.tabElements.title;\n span.innerHTML = title;\n span.title = title;\n this.title = title;\n this.emit(\"title-changed\", title, this);\n return this;\n }\n\n getTitle () {\n if (this.isClosed) return;\n return this.title;\n }\n\n setBadge (badge) {\n if (this.isClosed) return;\n let span = this.tabElements.badge;\n this.badge = badge;\n\n if (badge) {\n span.innerHTML = badge;\n span.classList.remove(\"hidden\");\n } else {\n span.classList.add(\"hidden\");\n }\n\n this.emit(\"badge-changed\", badge, this);\n }\n\n getBadge () {\n if (this.isClosed) return;\n return this.badge;\n }\n\n setIcon (iconURL, icon) {\n if (this.isClosed) return;\n this.iconURL = iconURL;\n this.icon = icon;\n let span = this.tabElements.icon;\n if (iconURL) {\n span.innerHTML = ``;\n this.emit(\"icon-changed\", iconURL, this);\n } else if (icon) {\n span.innerHTML = ``;\n this.emit(\"icon-changed\", icon, this);\n }\n\n return this;\n }\n\n getIcon () {\n if (this.isClosed) return;\n if (this.iconURL) return this.iconURL;\n return this.icon;\n }\n\n setPosition (newPosition) {\n let tabContainer = this.tabGroup.tabContainer;\n let tabs = tabContainer.children;\n let oldPosition = this.getPosition() - 1;\n\n if (newPosition < 0) {\n newPosition += tabContainer.childElementCount;\n\n if (newPosition < 0) {\n newPosition = 0;\n }\n } else {\n if (newPosition > tabContainer.childElementCount) {\n newPosition = tabContainer.childElementCount;\n }\n\n // Make 1 be leftmost position\n newPosition--;\n }\n\n if (newPosition > oldPosition) {\n newPosition++;\n }\n\n tabContainer.insertBefore(tabs[oldPosition], tabs[newPosition]);\n\n return this;\n }\n\n getPosition (fromRight) {\n let position = 0;\n let tab = this.tab;\n while ((tab = tab.previousSibling) != null) position++;\n\n if (fromRight === true) {\n position -= this.tabGroup.tabContainer.childElementCount;\n }\n\n if (position >= 0) {\n position++;\n }\n\n return position;\n }\n\n activate () {\n if (this.isClosed) return;\n let activeTab = this.tabGroup.getActiveTab();\n if (activeTab) {\n activeTab.tab.classList.remove(\"active\");\n activeTab.webview.classList.remove(\"visible\");\n activeTab.emit(\"inactive\", activeTab);\n }\n TabGroupPrivate.setActiveTab.bind(this.tabGroup)(this);\n this.tab.classList.add(\"active\");\n this.webview.classList.add(\"visible\");\n this.webview.focus();\n this.emit(\"active\", this);\n return this;\n }\n\n show (flag) {\n if (this.isClosed) return;\n if (flag !== false) {\n this.tab.classList.add(\"visible\");\n this.emit(\"visible\", this);\n } else {\n this.tab.classList.remove(\"visible\");\n this.emit(\"hidden\", this);\n }\n return this;\n }\n\n hide () {\n return this.show(false);\n }\n\n flash (flag) {\n if (this.isClosed) return;\n if (flag !== false) {\n this.tab.classList.add(\"flash\");\n this.emit(\"flash\", this);\n } else {\n this.tab.classList.remove(\"flash\");\n this.emit(\"unflash\", this);\n }\n return this;\n }\n\n unflash () {\n return this.flash(false);\n }\n\n hasClass (classname) {\n return this.tab.classList.contains(classname);\n }\n\n close (force) {\n const abortController = new AbortController();\n const abort = () => abortController.abort();\n this.emit(\"closing\", this, abort);\n\n const abortSignal = abortController.signal;\n if (this.isClosed || (!this.closable && !force) || abortSignal.aborted) return;\n\n this.isClosed = true;\n let tabGroup = this.tabGroup;\n tabGroup.tabContainer.removeChild(this.tab);\n tabGroup.viewContainer.removeChild(this.webview);\n let activeTab = this.tabGroup.getActiveTab();\n TabGroupPrivate.removeTab.bind(tabGroup)(this, true);\n\n this.emit(\"close\", this);\n\n if (activeTab.id === this.id) {\n TabGroupPrivate.activateRecentTab.bind(tabGroup)();\n }\n }\n}\n\nconst TabPrivate = {\n initTab: function () {\n let tabClass = this.tabGroup.options.tabClass;\n\n // Create tab element\n let tab = this.tab = document.createElement(\"div\");\n tab.classList.add(tabClass);\n for (let el of [\"icon\", \"title\", \"buttons\", \"badge\"]) {\n let span = tab.appendChild(document.createElement(\"span\"));\n span.classList.add(`${tabClass}-${el}`);\n this.tabElements[el] = span;\n }\n\n this.setTitle(this.title);\n this.setBadge(this.badge);\n this.setIcon(this.iconURL, this.icon);\n TabPrivate.initTabButtons.bind(this)();\n TabPrivate.initTabClickHandler.bind(this)();\n\n this.tabGroup.tabContainer.appendChild(this.tab);\n },\n\n initTabButtons: function () {\n let container = this.tabElements.buttons;\n let tabClass = this.tabGroup.options.tabClass;\n if (this.closable) {\n let button = container.appendChild(document.createElement(\"button\"));\n button.classList.add(`${tabClass}-button-close`);\n button.innerHTML = this.tabGroup.options.closeButtonText;\n button.addEventListener(\"click\", this.close.bind(this, false), false);\n }\n },\n\n initTabClickHandler: function () {\n // Mouse up\n const tabClickHandler = function (e) {\n if (this.isClosed) return;\n if (e.which === 2) {\n this.close();\n }\n };\n this.tab.addEventListener(\"mouseup\", tabClickHandler.bind(this), false);\n // Mouse down\n const tabMouseDownHandler = function (e) {\n if (this.isClosed) return;\n if (e.which === 1) {\n if (e.target.matches(\"button\")) return;\n this.activate();\n }\n };\n this.tab.addEventListener(\"mousedown\", tabMouseDownHandler.bind(this), false);\n },\n\n initWebview: function () {\n const webview = this.webview = document.createElement(\"webview\");\n\n const tabWebviewDidFinishLoadHandler = function (e) {\n this.emit(\"webview-ready\", this);\n };\n\n this.webview.addEventListener(\"did-finish-load\", tabWebviewDidFinishLoadHandler.bind(this), false);\n\n const tabWebviewDomReadyHandler = function (e) {\n // Remove this once https://github.com/electron/electron/issues/14474 is fixed\n webview.blur();\n webview.focus();\n this.emit(\"webview-dom-ready\", this);\n };\n\n this.webview.addEventListener(\"dom-ready\", tabWebviewDomReadyHandler.bind(this), false);\n\n this.webview.classList.add(this.tabGroup.options.viewClass);\n if (this.webviewAttributes) {\n let attrs = this.webviewAttributes;\n for (let key in attrs) {\n const attr = attrs[key];\n if (attr === false) continue;\n this.webview.setAttribute(key, attr);\n }\n }\n\n this.tabGroup.viewContainer.appendChild(this.webview);\n }\n};\n\n/**\n * This makes the browser EventTarget API work similar to EventEmitter\n */\nconst eventEmitterMixin = {\n emit (type, ...args) {\n this.dispatchEvent(new CustomEvent(type, { detail: args }));\n },\n\n on (type, fn) {\n this.addEventListener(type, ({ detail }) => fn.apply(this, detail));\n },\n\n once (type, fn) {\n this.addEventListener(type, ({ detail }) => fn.apply(this, detail), { once: true });\n }\n};\n\nObject.assign(TabGroup.prototype, eventEmitterMixin);\nObject.assign(Tab.prototype, eventEmitterMixin);\n\ncustomElements.define(\"tab-group\", TabGroup);\n",".etabs-tabgroup {\n width: 100%;\n height: 32px;\n background-color: #ccc;\n cursor: default;\n font: caption;\n font-size: 14px;\n -webkit-user-select: none;\n user-select: none;\n display: none;\n}\n\n.etabs-tabgroup.visible {\n\tdisplay: block;\n}\n\n.etabs-tab {\n display: none;\n position: relative;\n color: #333;\n height: 22px;\n padding: 6px 8px 4px;\n border: 1px solid #aaa;\n border-bottom: none;\n border-left: none;\n background: linear-gradient(to bottom, rgba(234,234,234,1) 0%,rgba(204,204,204,1) 100%);\n font: caption;\n font-size: 14px;\n background-color: #ccc;\n cursor: default;\n}\n\n/* Dragula */\n.etabs-tab.gu-mirror {\n padding-bottom: 0;\n}\n\n.etabs-tab:first-child {\n border-left: none;\n}\n\n.etabs-tab.visible {\n display: inline-block;\n}\n\n.etabs-tab.active {\n background: #fff;\n}\n\n.etabs-tab.flash {\n background: linear-gradient(to bottom, rgba(255,243,170,1) 0%,rgba(255,227,37,1) 100%);\n}\n\n.etabs-buttons {\n float: left;\n}\n\n.etabs-buttons button {\n float: left;\n color: #333;\n background: none;\n border: none;\n font-size: 12px;\n margin-top: 6px;\n border-radius: 2px;\n margin-left: 4px;\n width: 20px;\n text-align: center;\n padding: 4px 0;\n}\n\n.etabs-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-tab-badge {\n position: absolute;\n right: 0;\n top: -7px;\n background: red;\n border-radius: 100%;\n text-align: center;\n font-size: 10px;\n padding: 0 5px;\n}\n\n.etabs-tab-badge.hidden {\n display: none;\n}\n\n.etabs-tab-icon {\n display: inline-block;\n height: 16px;\n}\n\n.etabs-tab-icon img {\n max-width: 16px;\n max-height: 16px;\n}\n\n.etabs-tab-title {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons {\n display: inline-block;\n margin-left: 10px;\n}\n\n.etabs-tab-buttons button {\n display: inline-block;\n color: #333;\n background: none;\n border: none;\n width: 20px;\n text-align: center;\n border-radius: 2px;\n}\n\n.etabs-tab-buttons button:hover {\n color: #eee;\n background-color: #aaa;\n}\n\n.etabs-views {\n position: relative;\n border-top: 1px solid #aaa;\n height: calc(100vh - 33px);\n}\n\n.etab-view {\n position: relative;\n}\n\nwebview {\n position: absolute;\n visibility: hidden;\n width: 100%;\n height: 100%;\n}\n\nwebview.visible {\n visibility: visible;\n}\n"],"names":[],"version":3,"file":"electron-tabs.js.map"} \ No newline at end of file diff --git a/src/index.js b/src/index.js index bada450..721c507 100644 --- a/src/index.js +++ b/src/index.js @@ -59,6 +59,10 @@ class TabGroup extends HTMLElement { } } + setNewTab (newTab) { + this.options.newTab = newTab; + } + addTab (args = this.options.newTab) { if (typeof args === "function") { args = args(this);