Skip to content

Commit

Permalink
Show checkboxes on options page and fix fullscreen mode (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
Croydon committed Mar 30, 2017
1 parent 801ba14 commit b3c2741
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 86 deletions.
12 changes: 10 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
57 changes: 28 additions & 29 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
}
}

Expand All @@ -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);
}

Expand All @@ -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);
}
Expand All @@ -185,7 +185,7 @@ exports.main = function (options, callbacks) {

initHotkeys();
simplePrefs.on("toggleDisplayHotkey", changeHotkey);

simplePrefs.on("", observPrefs);

unload(function() {
Expand All @@ -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
Expand All @@ -221,4 +221,3 @@ function debugOutput(output)
value: output
});
}

50 changes: 26 additions & 24 deletions lib/verticaltabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -51,7 +52,7 @@ VerticalTabsReloaded.prototype = {
this.initEventListeners();
},

preferences: function(settingName)
preferences: function(settingName)
{
return this[settingName];
},
Expand All @@ -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);
Expand Down Expand Up @@ -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";
}
Expand All @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -266,6 +267,7 @@ VerticalTabsReloaded.prototype = {
this.applyThemeStylesheet();
break;
case "hideInFullscreen":
this.hideInFullscreen = newValue;
this.onSizeModeChange();
break;
case "compact":
Expand Down Expand Up @@ -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);
Expand All @@ -327,7 +329,7 @@ VerticalTabsReloaded.prototype = {

toggleDisplayState: function() {
const document = this.document;

if(document.getElementById("verticaltabs-box").style.display == "")
{
this.changeDisplayState("none");
Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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
});
}

};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion webextension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
Loading

0 comments on commit b3c2741

Please sign in to comment.