[Pkg-mozext-commits] [tabmixplus] 49/123: Use Firefox's built-in CustomizableUI.jsm to move 'new-tab-button' within TabsToolbar
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:26 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit da3a7d97719e3a9ea0fe5c05c5acf0fc85422eb6
Author: onemen <tabmix.onemen at gmail.com>
Date: Wed Aug 27 00:51:42 2014 +0300
Use Firefox's built-in CustomizableUI.jsm to move 'new-tab-button' within TabsToolbar
---
chrome/content/minit/minit.js | 2 +-
chrome/content/tab/tab.js | 28 +++++++++++++++++++++++-----
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index f16815d..a733e77 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -946,7 +946,7 @@ Tabmix.navToolbox = {
cSet = cSet.replace("tabmixScrollBox", "").replace(",,", ",");
tabsToolbar.setAttribute("currentset", cSet);
document.persist("TabsToolbar", "currentset");
- if (Tabmix.isVersion(280))
+ if (Tabmix.isVersion(290))
CustomizableUI.removeWidgetFromArea("tabmixScrollBox");
}
},
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 8b5389a..99dadda 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -1362,6 +1362,27 @@ var gTMPprefObserver = {
function $(id) document.getElementById(id);
let newTabButton = $("new-tab-button");
if (TabmixTabbar.isButtonOnTabsToolBar(newTabButton)) {
+ // update our attribute
+ let showNewTabButton = Tabmix.prefs.getBoolPref("newTabButton");
+ this.setShowNewTabButtonAttr(showNewTabButton, aPosition);
+ Tabmix.sideNewTabButton = newTabButton;
+
+ // move button within TabsToolbar
+ if (Tabmix.isVersion(290)) {
+ let buttonPosition = CustomizableUI.getPlacementOfWidget("new-tab-button").position;
+ let tabsPosition = CustomizableUI.getPlacementOfWidget("tabbrowser-tabs").position;
+ let changePosition = (aPosition == 0 && buttonPosition > tabsPosition) ||
+ (aPosition == 2 && buttonPosition != tabsPosition + 1 ||
+ buttonPosition < tabsPosition)
+ if (changePosition) {
+ let newPosition = aPosition == 0 ? 0 : 1;
+ if (newPosition > buttonPosition)
+ newPosition++;
+ CustomizableUI.moveWidgetWithinArea("new-tab-button", newPosition);
+ }
+ return;
+ }
+
let sideChanged, tabsToolbar = $("TabsToolbar");
let toolBar = Array.slice(tabsToolbar.childNodes);
let buttonIndex = toolBar.indexOf(newTabButton);
@@ -1380,7 +1401,6 @@ var gTMPprefObserver = {
let before = gBrowser.tabContainer.nextSibling;
if ($("tabmixScrollBox")) {
before = before.nextSibling;
- tabsIndex++;
}
newTabButton.parentNode.insertBefore(newTabButton, before);
sideChanged = true;
@@ -1388,14 +1408,12 @@ var gTMPprefObserver = {
}
if (sideChanged) {
let cSet = tabsToolbar.getAttribute("currentset") || tabsToolbar.getAttribute("defaultset");
+ cSet = cSet.replace("new-tab-button", "").replace(/^,/, "").replace(",,", ",");
cSet = cSet.split(",");
- cSet.splice(tabsIndex, 0, cSet.splice(buttonIndex, 1)[0] || "new-tab-button");
+ cSet.splice(tabsIndex, 0, "new-tab-button");
tabsToolbar.setAttribute("currentset", cSet.join(","));
document.persist("TabsToolbar", "currentset");
}
- let showNewTabButton = Tabmix.prefs.getBoolPref("newTabButton");
- this.setShowNewTabButtonAttr(showNewTabButton, aPosition);
- Tabmix.sideNewTabButton = newTabButton;
}
else {
this.setShowNewTabButtonAttr(false);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git
More information about the Pkg-mozext-commits
mailing list