[Pkg-mozext-commits] [tabmixplus] 33/44: Update ordinal set by treeStyleTab extension when close tab button is on the left side

David Prévot taffit at moszumanska.debian.org
Wed Oct 15 02:10:04 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 f87a9475b3a3318d853cc1dd5348f5fa3d9d75f2
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Oct 14 08:38:31 2014 +0300

    Update ordinal set by treeStyleTab extension when close tab button is on the left side
---
 chrome/content/extensions/extensions.js | 59 +++++++++++++++++++++++++++++++--
 chrome/content/overlay/browsr.css       |  1 +
 2 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/chrome/content/extensions/extensions.js b/chrome/content/extensions/extensions.js
index ae1934d..506a118 100644
--- a/chrome/content/extensions/extensions.js
+++ b/chrome/content/extensions/extensions.js
@@ -568,11 +568,12 @@ TMP_extensionsCompatibility.treeStyleTab = {
 
   onContentLoaded: function () {
     if ("TreeStyleTabBrowser" in window) {
+      let obj = TreeStyleTabBrowser.prototype;
       // we don't need this in the new version since we change the tabs-frame place
       // keep it here for non default theme that uses old Tabmix binding
-      let fn = TreeStyleTabBrowser.prototype.initTabbar;
+      let fn = obj.initTabbar;
       if (fn.toString().indexOf("d = this.document") == -1) {
-        Tabmix.changeCode(TreeStyleTabBrowser.prototype, "TreeStyleTabBrowser.prototype.initTabbar")._replace(
+        Tabmix.changeCode(obj, "TreeStyleTabBrowser.prototype.initTabbar")._replace(
           'newTabBox = document.getAnonymousElementByAttribute(b.mTabContainer, "id", "tabs-newbutton-box");',
           'let newTabButton = document.getElementById("new-tab-button"); \
            if (newTabButton && newTabButton.parentNode == gBrowser.tabContainer._container) \
@@ -582,9 +583,61 @@ TMP_extensionsCompatibility.treeStyleTab = {
           'if (newTabBox) $&', {flags: "g"}
         ).toCode();
       }
-      TreeStyleTabBrowser.prototype.getTabClosebox = function(aTab) {
+      obj.getTabClosebox = function(aTab) {
         return this.document.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button close-icon');
       }
+
+      fn = obj.initTabContentsOrderInternal;
+      if (fn.toString().indexOf("closebuttons-side") == -1) {
+        Tabmix.changeCode(obj, "TreeStyleTabBrowser.prototype.initTabContentsOrderInternal")._replace(
+          'if (this.mTabBrowser.getAttribute(this.kTAB_CONTENTS_INVERTED) == \'true\')',
+          'let button = aNamedNodes.close;\n    ' +
+          'index = nodes.indexOf(button);\n   ' +
+          'if (index > -1) {\n    ' +
+          ' let tabbar = this.mTabBrowser.tabContainer;\n   ' +
+          ' let side = tabbar.getAttribute("closebuttons-side");\n    ' +
+          ' if (side == "left") {\n   ' +
+          '   let before = nodes.indexOf(aNamedNodes.twistyAnchor);\n   ' +
+          '   if (before > -1) {\n    ' +
+          '     nodes.splice(index, 1);\n   ' +
+          '     let mOver = tabbar.mCloseButtons;\n   ' +
+          '     mOver = mOver == 4 && button.getAttribute("selected") != "true" || mOver == 2;\n    ' +
+          '     let offset = mOver ? 1 : 0;\n   ' +
+          '     nodes.splice(before + offset, 0, button);\n   ' +
+          '   }\n   ' +
+          ' }\n   ' +
+          '}\n\n    ' +
+          '$&'
+        )._replace(
+          'let key = \'initTabContentsOrderInternal_\'',
+          'let self = this;\n     ' +
+          '$&'
+        ).toCode();
+
+        let callback = function() {
+          TabmixSvc.forEachBrowserWindow(function(aWindow) {
+            aWindow.gBrowser.treeStyleTab.updateInvertedTabContentsOrder(true);
+          });
+        }
+        TabmixSvc.prefs.observe("extensions.tabmix.tabs.closeButtons", callback);
+        TabmixSvc.prefs.observe("extensions.tabmix.tabs.closeButtons.onLeft", callback);
+      }
+
+      // update ordinal on previous selected tab when close tab button is on the
+      // left side and CloseButtons preference is 4 - close buttons on hover
+      // and active tabs
+      let ontabselect = function(event) {
+        let tab = gBrowser.tabContainer.getAttribute("closebuttons-side") == "left" &&
+                  gBrowser.tabContainer.mCloseButtons == 4 &&
+                  event.detail && event.detail.previousTab;
+        if (tab)
+          gBrowser.treeStyleTab.initTabContentsOrder(tab);
+      }
+      gBrowser.tabContainer.addEventListener("TabSelect", ontabselect, true);
+      window.addEventListener("unload", function onunload() {
+        window.removeEventListener("unload", onunload, false);
+        gBrowser.tabContainer.removeEventListener("TabSelect", ontabselect, true);
+      }, false);
     }
 
     // we removed TMP_howToOpen function 2011-11-15
diff --git a/chrome/content/overlay/browsr.css b/chrome/content/overlay/browsr.css
index 6d183c1..70e8adc 100644
--- a/chrome/content/overlay/browsr.css
+++ b/chrome/content/overlay/browsr.css
@@ -59,6 +59,7 @@ label.text-link, label[onclick] {
 .tabbrowser-tabs[closebuttons-side="left"][closebuttons-hover="notactivetab"] > .tabbrowser-tab:not([selected="true"]) > .tab-stack > .tab-content > .tab-label,
 .tabbrowser-tabs[closebuttons-side="left"][closebuttons-hover="alltabs"] > .tabbrowser-tab > .tab-stack > .tab-content > .tab-label {
   -moz-box-ordinal-group: 2 !important;
+  pointer-events: none;
 }
 
 .tabbrowser-tabs:not([closebuttons="noclose"]):not([closebuttons-hover])[closebuttons-side="left"] > .tabbrowser-tab > .tab-stack > .tab-content > *:not(.tab-close-button) {

-- 
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