[Pkg-mozext-commits] [tabmixplus] 101/123: Update changeNewTabButtonSide
David Prévot
taffit at moszumanska.debian.org
Wed Sep 17 21:16:31 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 5a03d1950c60359a616559f407289ce65a3c7425
Author: onemen <tabmix.onemen at gmail.com>
Date: Thu Sep 11 22:39:46 2014 +0300
Update changeNewTabButtonSide
---
chrome/content/minit/minit.js | 4 ++++
chrome/content/tab/tab.js | 51 +++++++++++++++++++------------------------
chrome/content/tabmix.js | 13 +++++------
3 files changed, 32 insertions(+), 36 deletions(-)
diff --git a/chrome/content/minit/minit.js b/chrome/content/minit/minit.js
index a41133c..5e754b9 100644
--- a/chrome/content/minit/minit.js
+++ b/chrome/content/minit/minit.js
@@ -1226,7 +1226,11 @@ Tabmix.navToolbox = {
}
},
+ _tabStripInitialized: false,
tabStripAreaChanged: function() {
+ if (this._tabStripInitialized)
+ return;
+ this._tabStripInitialized = true;
/**
* we need to position three elements in TabsToolbar :
* tabmixScrollBox, new-tab-button, and tabmix-tabs-closebutton.
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 8549f41..f70264b 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -1319,43 +1319,38 @@ var gTMPprefObserver = {
if (Tabmix.isVersion(290)) {
let buttonPosition = Tabmix.getPlacement("new-tab-button");
let tabsPosition = Tabmix.getPlacement("tabbrowser-tabs");
+ let boxPositoin = Tabmix.getPlacement("tabmixScrollBox");
+ let after = boxPositoin == tabsPosition + 1 ? boxPositoin : tabsPosition;
let changePosition = (aPosition == 0 && buttonPosition > tabsPosition) ||
- (aPosition == 1 && buttonPosition < tabsPosition) ||
- (aPosition == 2 && buttonPosition != tabsPosition + 1);
+ (aPosition == 1 && buttonPosition < after) ||
+ (aPosition == 2 && buttonPosition != after + 1);
if (changePosition) {
- let newPosition = aPosition == 0 ? -1 : tabsPosition + 1;
+ let newPosition = aPosition == 0 ? tabsPosition : after + 1;
CustomizableUI.moveWidgetWithinArea("new-tab-button", newPosition);
}
return;
}
- let sideChanged, tabsToolbar = $("TabsToolbar");
+ let tabsToolbar = $("TabsToolbar");
let toolBar = Array.slice(tabsToolbar.childNodes);
- let buttonIndex = toolBar.indexOf(newTabButton);
- let tabsIndex = toolBar.indexOf(gBrowser.tabContainer);
- if (aPosition == 0) {
- if (buttonIndex > tabsIndex) {
- newTabButton.parentNode.insertBefore(newTabButton, gBrowser.tabContainer);
- sideChanged = true;
- }
- }
- else {
- // When user show the button after last tab, we show it on the side
- // only on multi-row. place it immediately after gBrowser.tabContainer
- if (aPosition == 2 && buttonIndex != tabsIndex + 1 ||
- buttonIndex < tabsIndex) {
- let before = gBrowser.tabContainer.nextSibling;
- if ($("tabmixScrollBox")) {
- before = before.nextSibling;
- }
- newTabButton.parentNode.insertBefore(newTabButton, before);
- sideChanged = true;
- }
- }
- if (sideChanged) {
+ let buttonPosition = toolBar.indexOf(newTabButton);
+ let tabsPosition = toolBar.indexOf(gBrowser.tabContainer);
+ let scrollBox = $("tabmixScrollBox");
+ let after = scrollBox && toolBar.indexOf(scrollBox) || tabsPosition;
+ let changePosition = (aPosition == 0 && buttonPosition > tabsPosition) ||
+ (aPosition == 1 && buttonPosition < after) ||
+ (aPosition == 2 && buttonPosition != after + 1);
+ if (changePosition) {
+ let newPosition = aPosition == 0 ? tabsPosition : after + 1;
+ tabsToolbar.insertBefore(newTabButton, tabsToolbar.childNodes.item(newPosition));
+ // update currentset
let cSet = tabsToolbar.getAttribute("currentset") || tabsToolbar.getAttribute("defaultset");
- cSet = cSet.replace("new-tab-button", "").replace(/^,/, "").replace(",,", ",");
- cSet = cSet.split(",");
+ cSet = cSet.split(",").filter(function(id) id != "new-tab-button");
+ let tabsIndex = cSet.indexOf("tabbrowser-tabs");
+ if (tabsIndex < 0)
+ return;
+ if (aPosition > 0)
+ tabsIndex++;
cSet.splice(tabsIndex, 0, "new-tab-button");
tabsToolbar.setAttribute("currentset", cSet.join(","));
document.persist("TabsToolbar", "currentset");
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index a22b7c7..e89c37b 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -566,14 +566,11 @@ var TMP_eventListener = {
Tabmix.Shortcuts.onWindowOpen(window);
- var position = Tabmix.prefs.getIntPref("newTabButton.position");
- if (Tabmix.extensions.treeStyleTab) {
- setTimeout(function() {
- gTMPprefObserver.changeNewTabButtonSide(position);
- }, 0);
- }
- else
- gTMPprefObserver.changeNewTabButtonSide(position);
+ // if treeStyleTab extension installed we call this from
+ // Tabmix.delayedStartup
+ if (!Tabmix.extensions.treeStyleTab)
+ Tabmix.navToolbox.tabStripAreaChanged();
+
TMP_ClosedTabs.setButtonType(Tabmix.prefs.getBoolPref("undoCloseButton.menuonly"));
TabmixTabbar.hideMode = Tabmix.prefs.getIntPref("hideTabbar");
--
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