From daff9b637f7a7c62a6008ba8387031acd19809e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=BCppers?= Date: Wed, 15 Feb 2017 13:02:40 +0100 Subject: [PATCH] Update index.js beautified code --- index.js | 72 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/index.js b/index.js index f536d9d..523814d 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,7 @@ if (!document) { } // Inject styles -(function () { +(function() { const styles = ` webview { display: flex; @@ -28,7 +28,7 @@ if (!document) { })(); class TabGroup extends EventEmitter { - constructor (args = {}) { + constructor(args = {}) { super(); let options = this.options = { tabContainerSelector: args.tabContainerSelector || ".etabs-tabs", @@ -51,7 +51,7 @@ class TabGroup extends EventEmitter { } } - addTab (args = this.options.newTab) { + addTab(args = this.options.newTab) { if (typeof args === "function") { args = args(this); } @@ -63,7 +63,7 @@ class TabGroup extends EventEmitter { return tab; } - getTab (id) { + getTab(id) { for (let i in this.tabs) { if (this.tabs[i].id === id) { return this.tabs[i]; @@ -72,14 +72,14 @@ class TabGroup extends EventEmitter { return null; } - getActiveTab () { + getActiveTab() { if (this.tabs.length === 0) return null; return this.tabs[0]; } } const TabGroupPrivate = { - initNewTabButton: function () { + initNewTabButton: function() { if (!this.options.newTab) return; let container = document.querySelector(this.options.buttonsContainerSelector); let button = container.appendChild(document.createElement("button")); @@ -88,7 +88,7 @@ const TabGroupPrivate = { button.addEventListener("click", this.addTab.bind(this, undefined), false); }, - removeTab: function (tab, triggerEvent) { + removeTab: function(tab, triggerEvent) { let id = tab.id; for (let i in this.tabs) { if (this.tabs[i].id === id) { @@ -102,14 +102,14 @@ const TabGroupPrivate = { return this; }, - setActiveTab: function (tab) { + setActiveTab: function(tab) { TabGroupPrivate.removeTab.bind(this)(tab); this.tabs.unshift(tab); this.emit("tab-active", tab, this); return this; }, - activateRecentTab: function (tab) { + activateRecentTab: function(tab) { if (this.tabs.length > 0) { this.tabs[0].activate(); } @@ -118,13 +118,13 @@ const TabGroupPrivate = { }; class Tab extends EventEmitter { - constructor (tabGroup, id, args) { + constructor(tabGroup, id, args) { super(); this.tabGroup = tabGroup; this.id = id; this.title = args.title; this.iconURL = args.iconURL; - this.icon = args.icon; + this.icon = args.icon; this.closable = args.closable === false ? false : true; this.webviewAttributes = args.webviewAttributes || {}; this.webviewAttributes.src = args.src; @@ -142,7 +142,7 @@ class Tab extends EventEmitter { } } - setTitle (title) { + setTitle(title) { if (this.isClosed) return; let span = this.tabElements.title; span.innerHTML = title; @@ -151,34 +151,34 @@ class Tab extends EventEmitter { return this; } - getTitle () { + getTitle() { if (this.isClosed) return; return this.title; } - setIcon (iconURL, icon) { + setIcon(iconURL, icon) { if (this.isClosed) return; this.iconURL = iconURL; - this.icon = icon; + this.icon = icon; let span = this.tabElements.icon; if (iconURL) { span.innerHTML = ``; - this.emit("icon-changed", iconURL, this); - } else if (icon) { - span.innerHTML = ``; - this.emit("icon-changed", icon, this); - } - + this.emit("icon-changed", iconURL, this); + } else if (icon) { + span.innerHTML = ``; + this.emit("icon-changed", icon, this); + } + return this; } - getIcon () { + getIcon() { if (this.isClosed) return; - if(this.iconURL) return this.iconURL; - return this.icon; + if (this.iconURL) return this.iconURL; + return this.icon; } - activate () { + activate() { if (this.isClosed) return; let activeTab = this.tabGroup.getActiveTab(); if (activeTab) { @@ -192,7 +192,7 @@ class Tab extends EventEmitter { return this; } - show (flag) { + show(flag) { if (this.isClosed) return; if (flag !== false) { this.tab.classList.add("visible"); @@ -204,11 +204,11 @@ class Tab extends EventEmitter { return this; } - hide () { + hide() { return this.show(false); } - flash (flag) { + flash(flag) { if (this.isClosed) return; if (flag !== false) { this.tab.classList.add("flash"); @@ -220,11 +220,11 @@ class Tab extends EventEmitter { return this; } - unflash () { + unflash() { return this.flash(false); } - close (force) { + close(force) { if (this.isClosed || (!this.closable && !force)) return; this.isClosed = true; let tabGroup = this.tabGroup; @@ -241,7 +241,7 @@ class Tab extends EventEmitter { } const TabPrivate = { - initTab: function () { + initTab: function() { let tabClass = this.tabGroup.options.tabClass; // Create tab element @@ -261,7 +261,7 @@ const TabPrivate = { this.tabGroup.tabContainer.appendChild(this.tab); }, - initTabButtons: function () { + initTabButtons: function() { let container = this.tabElements.buttons; let tabClass = this.tabGroup.options.tabClass; if (this.closable) { @@ -272,9 +272,9 @@ const TabPrivate = { } }, - initTabClickHandler: function () { + initTabClickHandler: function() { // Click - const tabClickHandler = function (e) { + const tabClickHandler = function(e) { if (this.isClosed) return; if (e.which === 2) { this.close(); @@ -282,7 +282,7 @@ const TabPrivate = { }; this.tab.addEventListener("click", tabClickHandler.bind(this), false); // Mouse down - const tabMouseDownHandler = function (e) { + const tabMouseDownHandler = function(e) { if (this.isClosed) return; if (e.which === 1) { if (e.target.matches("button")) return; @@ -292,7 +292,7 @@ const TabPrivate = { this.tab.addEventListener("mousedown", tabMouseDownHandler.bind(this), false); }, - initWebview: function () { + initWebview: function() { this.webview = document.createElement("webview"); this.webview.classList.add(this.tabGroup.options.viewClass); if (this.webviewAttributes) {