diff --git a/changelog.md b/changelog.md index f0fc3d4..78d9a4f 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,15 @@ # Changelog +### v0.8.2, 2017-03-30 + * fixed: show checkboxes on the settings page + * fixed: hide tabs in fullscreen + + +*** + + ### v0.8.1, 2017-03-28 - * internal: continue rewriting add-on as a WebExtension + * internal: continue rewriting add-on as a WebExtension (#13) * manage settings UI by WebExtension * move default settings restore function to WebExtension * move more settings logic to WebExtension @@ -12,7 +20,7 @@ ### v0.8.0, 2017-01-09 - * internal: start rewriting add-on as a WebExtension + * internal: start rewriting add-on as a WebExtension (#13) * sync settings between the legacy SDK and the new WebExtension part * this is critical to release as soon as possible, so that in the best case nobody will lose their settings in the end of 2017 * At the end of 2017 non-WebExtensions will stop working. Data migration won't be possible either afterwards diff --git a/index.js b/index.js index 96d464e..644b8e2 100644 --- a/index.js +++ b/index.js @@ -52,18 +52,18 @@ function initHotkeys() { } }); } - + function destroyHotkey() { GLOBAL_SCOPE.vtToggleDisplayHotkey.destroy(); } function changeHotkey() { - destroyHotkey(); + destroyHotkey(); initHotkeys(); } // -// WebExtenions Communication +// WebExtenions Communication // // Send message to WebExtension @@ -75,23 +75,23 @@ function webext_sendMsg(message) // Handle messages from WebExtension function webext_replyHandler(message, sender, sendResponse) -{ - if(message.type == "settings.get") +{ + if(message.type == "settings.get") { // Send settings to WebExt webext_sendChangedSetting(message.name); } - + if(message.type == "settings.post") { // Get settings from WebExt debugOutput(message.name + " new value SDK: " + message.value); preferences[message.name] = message.value; } - + if(message.type == "settings.toggleDrawInTitlebar") { - toggleDrawInTitlebar(); + toggleDrawInTitlebar(); } } @@ -106,26 +106,26 @@ function webext_sendChangedSetting(settingName) } function observPrefs(settingName) -{ - for (let window of windows.browserWindows) +{ + for (let window of windows.browserWindows) { let lowLevelWindow = viewFor(window); let windowID = windowUtils.getOuterId(lowLevelWindow); GLOBAL_SCOPE["vt"+windowID].onPreferenceChange(settingName, preferences[settingName]); } - + webext_sendChangedSetting(settingName); } // -// End of WebExtenions Communication +// End of WebExtenions Communication // function initialize_window(window) { let lowLevelWindow = viewFor(window); let windowID = windowUtils.getOuterId(lowLevelWindow); - GLOBAL_SCOPE["vt"+windowID] = new VerticalTabsReloaded(lowLevelWindow, webextPort, preferences["compact"], preferences["right"], preferences["width"], preferences["tabtoolbarPosition"], preferences["debug"], preferences["theme"]); + GLOBAL_SCOPE["vt"+windowID] = new VerticalTabsReloaded(lowLevelWindow, webextPort, preferences["compact"], preferences["right"], preferences["width"], preferences["tabtoolbarPosition"], preferences["debug"], preferences["theme"], preferences["hideInFullscreen"]); unload(GLOBAL_SCOPE["vt" + windowID].unload.bind(GLOBAL_SCOPE["vt"+windowID]), lowLevelWindow); } @@ -136,38 +136,38 @@ exports.main = function (options, callbacks) { preferencesService.set("browser.tabs.drawInTitlebar", false); } else if (options.loadReason == "upgrade") { - // v0.4.0 -> v0.5.0, remove when most use >= v0.5.0 + // v0.4.0 -> v0.5.0, remove when most use >= v0.5.0 if(preferences["theme"] == "winnt") { preferences["theme"] = "windows"; } } - + // Back up 'browser.tabs.animate' pref before overwriting it preferences["animate"] = preferencesService.get("browser.tabs.animate"); preferencesService.set("browser.tabs.animate", false); - + unload(function () { preferencesService.set("browser.tabs.animate", preferences["animate"]); }); // WebExtension startup + communication - webExtension.startup().then(api => + webExtension.startup().then(api => { const {browser} = api; - - browser.runtime.onMessage.addListener((msg, sender, sendResponse) => + + browser.runtime.onMessage.addListener((msg, sender, sendResponse) => { webext_replyHandler(msg, sender, sendResponse); }); - - browser.runtime.onConnect.addListener((port) => + + browser.runtime.onConnect.addListener((port) => { webextPort = port; // make it global - - + + // Initialize VerticalTabsReloaded object for each window. - - for (let window of windows.browserWindows) + + for (let window of windows.browserWindows) { initialize_window(window); } @@ -185,7 +185,7 @@ exports.main = function (options, callbacks) { initHotkeys(); simplePrefs.on("toggleDisplayHotkey", changeHotkey); - + simplePrefs.on("", observPrefs); unload(function() { @@ -203,9 +203,9 @@ exports.onUnload = function (reason) { { debugOutput("VTR disabled"); } - + unload(); - + // Unloaders might want access to prefs, so do this last if (reason == "uninstall") { // Delete all settings @@ -221,4 +221,3 @@ function debugOutput(output) value: output }); } - diff --git a/lib/verticaltabs.js b/lib/verticaltabs.js index 0108411..2c39308 100644 --- a/lib/verticaltabs.js +++ b/lib/verticaltabs.js @@ -25,7 +25,7 @@ exports.VerticalTabsReloaded = VerticalTabsReloaded; * * Main entry point of this add-on. */ -function VerticalTabsReloaded(window, webextPortP, compact, right, width, tabtoolbarPosition, debug, theme) { +function VerticalTabsReloaded(window, webextPortP, compact, right, width, tabtoolbarPosition, debug, theme, hideInFullscreen) { this.webextPort = webextPortP; this.window = window; this.document = window.document; @@ -35,6 +35,7 @@ function VerticalTabsReloaded(window, webextPortP, compact, right, width, tabtoo this.width = width; this.tabtoolbarPosition = tabtoolbarPosition; this.debug = debug; + this.hideInFullscreen = hideInFullscreen; this.changedDisplayState = false; this.unloaders = []; this.init(); @@ -51,7 +52,7 @@ VerticalTabsReloaded.prototype = { this.initEventListeners(); }, - preferences: function(settingName) + preferences: function(settingName) { return this[settingName]; }, @@ -71,13 +72,13 @@ VerticalTabsReloaded.prototype = { value: newValue }); }, - + installStylesheet: function(uri) { uri = Services.io.newURI(uri, null, null); this.debugOutput(uri); stylesheetUtils.loadSheet(this.window, uri); }, - + removeStylesheet: function(uri) { uri = Services.io.newURI(uri, null, null); stylesheetUtils.removeSheet(this.window, uri); @@ -146,7 +147,7 @@ VerticalTabsReloaded.prototype = { splitter.addEventListener("mouseup", this, false); // Move the tabs next to the app content, make them vertical, - + if (this.preferences("right")) { browserbox.dir = "reverse"; } @@ -165,7 +166,7 @@ VerticalTabsReloaded.prototype = { toolbar.setAttribute("collapsed", "false"); // no more vanishing new tab toolbar toolbar._toolbox = null; // reset value set by constructor toolbar.setAttribute("toolboxid", "navigator-toolbox"); - + if (this.preferences("tabtoolbarPosition") == "top") { leftbox.insertBefore(toolbar, leftbox.firstChild); } else { @@ -181,8 +182,8 @@ VerticalTabsReloaded.prototype = { // And restore the label here. this.debugOutput("label: "+label); tabs.firstChild.label = label; - - let vt = this; + + let vt = this; this.unloaders.push(function() { // Move the bottom back to being the next sibling of contentbox. browserbox.insertBefore(bottom, contentbox.nextSibling); @@ -247,9 +248,9 @@ VerticalTabsReloaded.prototype = { this.window.setTimeout(this.webext_sendChangedSetting("width", tabs.boxObject.width), 10); }, - onPreferenceChange: function(prefName, newValue) + onPreferenceChange: function(prefName, newValue) { - switch (prefName) + switch (prefName) { case "right": this.right = newValue; @@ -266,6 +267,7 @@ VerticalTabsReloaded.prototype = { this.applyThemeStylesheet(); break; case "hideInFullscreen": + this.hideInFullscreen = newValue; this.onSizeModeChange(); break; case "compact": @@ -294,13 +296,13 @@ VerticalTabsReloaded.prototype = { // Note: Not all eventsListener are set up here this.window.addEventListener("sizemodechange", this, false); this.window.addEventListener("resize", this, false); - + this.unloaders.push(function() { this.window.removeEventListener("sizemodechange", this, false); this.window.removeEventListener("resize", this, false); }); }, - + // Event handlers handleEvent: function(aEvent) { //debugOutput("aEvent.type: "+aEvent.type); @@ -327,7 +329,7 @@ VerticalTabsReloaded.prototype = { toggleDisplayState: function() { const document = this.document; - + if(document.getElementById("verticaltabs-box").style.display == "") { this.changeDisplayState("none"); @@ -339,10 +341,10 @@ VerticalTabsReloaded.prototype = { this.changedDisplayState = false; } }, - + changeDisplayState: function(display) { const document = this.document; - + let tabs = document.getElementById("verticaltabs-box").style; let splitter = document.getElementById("verticaltabs-splitter").style; @@ -352,17 +354,17 @@ VerticalTabsReloaded.prototype = { tabs.display = splitter.display = display; }, - - /* + + /* * The size of the window changed, check if we entered/left fullscreen and * hide/show tabs according to user setting */ onSizeModeChange: function() { - if(this.changedDisplayState == true) + if(this.changedDisplayState == true) { return; } - + const window = this.window; const document = this.document; @@ -371,21 +373,21 @@ VerticalTabsReloaded.prototype = { this.changeDisplayState(display); }, - + unload: function() { this.unloaders.forEach(function(func) { func.call(this); }, this); - + this.unloaders = []; }, - - debugOutput: function(output) + + debugOutput: function(output) { this.webext_sendMsg({ type: "debug.log", value: output }); } - + }; diff --git a/package.json b/package.json index 730a2d1..c6cd8f4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "icon": "resource://verticaltabsreloaded-at-go-dev-dot-de/data/icon.png", "author": "Croydon", "license": "MPL-2.0", - "version": "0.8.2-alpha", + "version": "0.8.2", "permissions": { "private-browsing": true, diff --git a/webextension/manifest.json b/webextension/manifest.json index 97833a5..138cf35 100644 --- a/webextension/manifest.json +++ b/webextension/manifest.json @@ -2,7 +2,7 @@ "name": "Vertical Tabs Reloaded", "short_name": "VTR", "description": "This Firefox add-on arranges tabs in a vertical rather than horizontal fashion.", - "version": "0.8.2-alpha", + "version": "0.8.2", "manifest_version": 2, "author": "Michael 'Croydon' Keck", "developer": diff --git a/webextension/options.html b/webextension/options.html index 943ee7c..43b5ee7 100644 --- a/webextension/options.html +++ b/webextension/options.html @@ -2,7 +2,7 @@ - + diff --git a/webextension/options.js b/webextension/options.js index 77aaccf..ab29e65 100644 --- a/webextension/options.js +++ b/webextension/options.js @@ -136,6 +136,8 @@ function save_setting(event) function build() { // This builds the entire setting list from the JSON object + let settingsHTML = ""; + Object.keys(settings).forEach(function(k) { let setting = settings[k]; @@ -147,14 +149,14 @@ function build() if(setting.type == "bool") { - document.getElementById("settings").innerHTML += '
'; + settingsHTML += '
'; } if(setting.type == "string") { if(setting.placeholder == undefined) { setting.placeholder = ""; } - document.getElementById("settings").innerHTML += '' + setting.title + ' '; + settingsHTML += '' + setting.title + ' '; } if(setting.type == "menulist") @@ -168,19 +170,21 @@ function build() newInnerHTML += ''; - document.getElementById("settings").innerHTML += newInnerHTML; + settingsHTML += newInnerHTML; } if(setting.type == "control") { - document.getElementById("settings").innerHTML += '' + setting.title + ' '; + settingsHTML += '' + setting.title + ' '; } if(setting.description != undefined) { - document.getElementById("settings").innerHTML += '' + setting.description + ''; + settingsHTML += '' + setting.description + ''; } }); + + document.getElementById("settings").insertAdjacentHTML("beforeend", settingsHTML); } function load_value(input)