[Pkg-mozext-commits] [tabmixplus] 11/51: Move the content of tabmix-tabbrowser-tabs bindings constructor, destructor and initializeTabmixUI to new function in js object
David Prévot
taffit at moszumanska.debian.org
Mon Feb 2 18:36:46 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository tabmixplus.
commit 71cca10cb124bd9b7ceb64ead9bf5bfc1fd87f67
Author: onemen <tabmix.onemen at gmail.com>
Date: Sun Jan 4 13:30:10 2015 +0200
Move the content of tabmix-tabbrowser-tabs bindings constructor, destructor and initializeTabmixUI to new function in js object
---
chrome/content/tab/tab.js | 133 ++++++++++++++++++++++++++++++++++++
chrome/content/tab/tabbrowser_4.xml | 120 +-------------------------------
chrome/content/tabmix.js | 21 ++++--
3 files changed, 148 insertions(+), 126 deletions(-)
diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index 4e65ac2..79f522c 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -555,6 +555,139 @@ var TabmixTabbar = {
}; // TabmixTabbar end
+Tabmix.tabsUtils = {
+ initialized: false,
+
+ get tabBar() {
+ delete this.tabBar;
+ return (this.tabBar = gBrowser.tabContainer);
+ },
+
+ init: function() {
+ // add dragover event handler to TabsToolbar to capture dragging over
+ // tabbar margin area, filter out events that are out of the tabbar
+ this.tabBar.parentNode.addEventListener("dragover", this, true);
+ if (!Tabmix.isVersion(310))
+ Services.prefs.removeObserver("browser.tabs.closeButtons", this.tabBar._prefObserver);
+
+ if (this.initialized) {
+ Tabmix.log("initializeTabmixUI - some extension initialize tabbrowser-tabs binding again");
+ this.initializeTabmixUI();
+ return;
+ }
+ this.initialized = true;
+
+ var tabbrowser = this.tabBar.tabbrowser;
+ let tab = this.tabBar.firstChild;
+
+ XPCOMUtils.defineLazyGetter(Tabmix, "rtl", function () {
+ return window.getComputedStyle(tabbrowser, null).direction == "rtl";
+ });
+ XPCOMUtils.defineLazyGetter(Tabmix, "ltr", function () {return !Tabmix.rtl;});
+
+ // don't set button to left side if it is not inside tab-content
+ let button = document.getAnonymousElementByAttribute(tab, "anonid", "tmp-close-button") ||
+ document.getAnonymousElementByAttribute(tab, "anonid", "close-button");
+ Tabmix.defaultCloseButtons = button && button.parentNode.className == "tab-content";
+ let onLeft = Tabmix.defaultCloseButtons && Tabmix.prefs.getBoolPref("tabs.closeButtons.onLeft");
+ this.tabBar.setAttribute("closebuttons-side", onLeft ? "left" : "right");
+
+ this.tabBar._keepLastTab = Tabmix.prefs.getBoolPref("keepLastTab");
+ this.tabBar.closeButtonsEnabled = Tabmix.prefs.getBoolPref("tabs.closeButtons.enable");
+ this.tabBar.mCloseButtons = Tabmix.prefs.getIntPref("tabs.closeButtons");
+ this.tabBar._tabmixPositionalTabs = {
+ beforeSelectedTab: null, afterSelectedTab: null,
+ beforeHoveredTab: null, afterHoveredTab: null
+ };
+
+ Tabmix.afterTabsButtonsWidth = [Tabmix.isVersion(280) ? 51.6 : 28];
+ Tabmix.tabsNewtabButton =
+ document.getAnonymousElementByAttribute(this.tabBar, "command", "cmd_newNavigatorTab");
+ Tabmix._show_newtabbutton = "aftertabs";
+
+ let attr = ["notpinned", "autoreload", "protected",
+ "locked"].filter(function(att) {
+ return Tabmix.prefs.getBoolPref("extraIcons." + att);
+ });
+ if (attr.length)
+ this.tabBar.setAttribute("tabmix_icons", attr.join(" "));
+
+ Tabmix._debugMode = TabmixSvc.debugMode();
+
+ // initialize first tab
+ Tabmix._nextSelectedID = 1;
+ TMP_eventListener.setTabAttribute(tab);
+ tab.setAttribute("tabmix_selectedID", Tabmix._nextSelectedID++);
+ tab.setAttribute("visited", true);
+ Tabmix.setTabStyle(tab);
+ TabmixTabbar.lockallTabs = Tabmix.prefs.getBoolPref("lockallTabs");
+ if (TabmixTabbar.lockallTabs) {
+ tab.setAttribute("locked", true);
+ tab.tabmix_allowLoad = false;
+ }
+ if ("linkedBrowser" in tab)
+ tablib.setLoadURIWithFlags(tab.linkedBrowser);
+
+ Tabmix.initialization.run("beforeStartup", tabbrowser, this.tabBar);
+ },
+
+ onUnload: function() {
+ if (this.tabBar.parentNode)
+ this.tabBar.parentNode.removeEventListener("dragover", this, true);
+ delete this.tabBar.tabstripInnerbox;
+ gBrowser.tabContainer._tabmixPositionalTabs = null;
+ },
+
+ handleEvent: function(aEvent) {
+ switch (aEvent.type) {
+ case "dragover":
+ let target = aEvent.target.localName;
+ if (target != "tab" && target != "tabs")
+ return;
+ if (gBrowser.tabContainer.useTabmixDnD(aEvent))
+ TMP_tabDNDObserver.onDragOver(aEvent);
+ break;
+ }
+ },
+
+ initializeTabmixUI: function() {
+ // https://addons.mozilla.org/EN-US/firefox/addon/vertical-tabs/
+ // verticalTabs 0.9.1+ is restartless.
+ if (typeof VerticalTabs == "object" && !Tabmix.extensions.verticalTabs) {
+ Tabmix.setItem("TabsToolbar", "collapsed", null);
+ Tabmix.extensions.verticalTabs = true;
+ Tabmix.extensions.verticalTabBar = true;
+ TabmixTabbar.updateSettings();
+ }
+
+ // tabbrowser-tabs constructor reset first tab label to New Tab
+ this.tabBar.tabbrowser.setTabTitle(this.tabBar.firstChild);
+ let position = Tabmix.prefs.getIntPref("newTabButton.position");
+ if (position !== 0)
+ gTMPprefObserver.changeNewTabButtonSide(position);
+
+ // need to add TabScope eventListener
+ // need to find a way to do it for all extensions that add event to the tabstrip
+ if ("TabScope" in window) {
+ window.TabScope.uninit();
+ window.TabScope.init();
+ }
+
+ TabmixTabbar.flowing = this.tabBar.getAttribute("flowing");
+ this.tabBar.setTabStripOrient();
+ Tabmix.navToolbox.setScrollButtons(true);
+
+ // fix incompatibility with Personal Titlebar extension
+ // the extensions trigger tabbar binding reset on toolbars customize
+ // we need to init our ui settings from here and again after customization
+ if (Tabmix.navToolbox.customizeStarted) {
+ TabmixTabbar.visibleRows = 1;
+ TabmixTabbar.updateSettings(false);
+ Tabmix.navToolbox.resetUI = true;
+ }
+ }
+};
+
Tabmix.visibleTabs = {
get first() {
var tabs = gBrowser.tabs;
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index b8a57ec..57f3ab6 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -350,89 +350,10 @@
<constructor>
<![CDATA[
- // add dragover event handler to TabsToolbar to capture dragging over
- // tabbar margin area filter out events that are out of the tabbar
- this.parentNode.tabmix_handleDragover = function (aEvent) {
- let target = aEvent.target.localName;
- if (target != "tab" && target != "tabs")
- return;
- if (gBrowser.tabContainer.useTabmixDnD(aEvent))
- TMP_tabDNDObserver.onDragOver(aEvent);
- }
- this.parentNode.addEventListener("dragover", this.parentNode.tabmix_handleDragover, true);
- if (!Tabmix.isVersion(310))
- Services.prefs.removeObserver("browser.tabs.closeButtons", this._prefObserver);
-
- if (this.tabmix_inited) {
- Tabmix.log("initializeTabmixUI - some extension initialize tabbrowser-tabs binding again");
- this.initializeTabmixUI();
- return;
- }
- this.tabmix_inited = true;
-
- var tabbrowser = this.tabbrowser;
-
- XPCOMUtils.defineLazyGetter(Tabmix, "rtl", function () {
- return window.getComputedStyle(tabbrowser, null).direction == "rtl";
- });
- XPCOMUtils.defineLazyGetter(Tabmix, "ltr", function () !Tabmix.rtl);
-
- // don't set button to left side if it is not inside tab-content
- let button = document.getAnonymousElementByAttribute(this.firstChild, "anonid", "tmp-close-button") ||
- document.getAnonymousElementByAttribute(this.firstChild, "anonid", "close-button");
- Tabmix.defaultCloseButtons = button && button.parentNode.className == "tab-content";
- let onLeft = Tabmix.defaultCloseButtons && Tabmix.prefs.getBoolPref("tabs.closeButtons.onLeft");
- this.setAttribute("closebuttons-side", onLeft ? "left" : "right");
-
- this._keepLastTab = Tabmix.prefs.getBoolPref("keepLastTab");
- this.closeButtonsEnabled = Tabmix.prefs.getBoolPref("tabs.closeButtons.enable");
- this.mCloseButtons = Tabmix.prefs.getIntPref("tabs.closeButtons");
- this._tabmixPositionalTabs = {beforeSelectedTab: null, afterSelectedTab: null,
- beforeHoveredTab: null, afterHoveredTab: null}
-
- /**
- * if we set this in field[s] they will reset each time the tabbar binding construct
- * by tabbar position change
- */
- Tabmix.afterTabsButtonsWidth = [Tabmix.isVersion(280) ? 51.6 : 28];
- Tabmix.tabsNewtabButton =
- document.getAnonymousElementByAttribute(this, "command", "cmd_newNavigatorTab");
- Tabmix._show_newtabbutton = "aftertabs";
-
- Tabmix._nextSelectedID = 1;
- let tab = this.firstChild;
- TMP_eventListener.setTabAttribute(tab);
- tab.setAttribute("tabmix_selectedID", Tabmix._nextSelectedID++);
- tab.setAttribute("visited", true);
- Tabmix.setTabStyle(tab);
- TabmixTabbar.lockallTabs = Tabmix.prefs.getBoolPref("lockallTabs");
- if (TabmixTabbar.lockallTabs) {
- tab.setAttribute("locked", true);
- tab.tabmix_allowLoad = false;
- }
-
- let attr = ["notpinned", "autoreload", "protected", "locked"]
- .filter(function(att) Tabmix.prefs.getBoolPref("extraIcons." + att));
- if (attr.length)
- this.setAttribute("tabmix_icons", attr.join(" "));
-
- Tabmix._debugMode = TabmixSvc.debugMode();
-
- if ("linkedBrowser" in tab)
- tablib.setLoadURIWithFlags(tab.linkedBrowser);
-
- Tabmix.initialization.run("beforeStartup", tabbrowser, this);
+ Tabmix.initialization.run("init", this);
]]>
</constructor>
- <destructor>
- <![CDATA[
- if (this.parentNode)
- this.parentNode.removeEventListener("dragover", this.parentNode.tabmix_handleDragover, true);
- delete this.tabstripInnerbox;
- ]]>
- </destructor>
-
<method name="updateVerticalTabStrip">
<parameter name="aReset"/>
<body><![CDATA[
@@ -672,45 +593,6 @@
]]></body>
</method>
- <method name="initializeTabmixUI">
- <body><![CDATA[
- // https://addons.mozilla.org/EN-US/firefox/addon/vertical-tabs/
- // verticalTabs 0.9.1+ is restartless.
- if (typeof VerticalTabs == "object" && !Tabmix.extensions.verticalTabs) {
- Tabmix.setItem("TabsToolbar", "collapsed", null);
- Tabmix.extensions.verticalTabs = true;
- Tabmix.extensions.verticalTabBar = true;
- TabmixTabbar.updateSettings();
- }
-
- // tabbrowser-tabs constructor reset first tab label to New Tab
- this.tabbrowser.setTabTitle(this.firstChild);
- let position = Tabmix.prefs.getIntPref("newTabButton.position");
- if (position != 0)
- gTMPprefObserver.changeNewTabButtonSide(position);
-
- // need to add TabScope eventListener
- // need to find a way to do it for all extensions that add event to the tabstrip
- if ("TabScope" in window ) {
- TabScope.uninit();
- TabScope.init();
- }
-
- TabmixTabbar.flowing = this.getAttribute("flowing");
- this.setTabStripOrient();
- Tabmix.navToolbox.setScrollButtons(true);
-
- // fix incompatibility with Personal Titlebar extension
- // the extensions trigger tabbar binding reset on toolbars customize
- // we need to init our ui settings from here and again after customization
- if (Tabmix.navToolbox.customizeStarted) {
- TabmixTabbar.visibleRows = 1;
- TabmixTabbar.updateSettings(false);
- Tabmix.navToolbox.resetUI = true;
- }
- ]]></body>
- </method>
-
<method name="_notifyBackgroundTab">
<parameter name="aTab"/>
<body><![CDATA[
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 86871a8..c05178d 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -1057,7 +1057,6 @@ var TMP_eventListener = {
}
this.toggleEventListener(gBrowser.tabContainer, this._tabEvents, false);
- gBrowser.tabContainer._tabmixPositionalTabs = null;
let alltabsPopup = document.getElementById("alltabs-popup");
if (alltabsPopup && alltabsPopup._tabmix_inited)
@@ -1085,6 +1084,8 @@ var TMP_eventListener = {
let mm = window.getGroupMessageManager("browsers");
mm.removeMessageListener("Tabmix:SetSyncHandler", this);
}
+
+ Tabmix.tabsUtils.onUnload();
},
// some theme not useing up to date Tabmix tab binding
@@ -1121,11 +1122,12 @@ var TMP_eventListener = {
* initialized yet
*/
Tabmix.initialization = {
- beforeStartup: {id: 0, obj: "Tabmix"},
- onContentLoaded: {id: 1, obj: "TMP_eventListener"},
- beforeBrowserInitOnLoad: {id: 2, obj: "Tabmix"},
- onWindowOpen: {id: 3, obj: "TMP_eventListener"},
- delayedStartup: {id: 4, obj: "Tabmix"},
+ init: {id: 0, obj: "Tabmix.tabsUtils"},
+ beforeStartup: {id: 1, obj: "Tabmix"},
+ onContentLoaded: {id: 2, obj: "TMP_eventListener"},
+ beforeBrowserInitOnLoad: {id: 3, obj: "Tabmix"},
+ onWindowOpen: {id: 4, obj: "TMP_eventListener"},
+ delayedStartup: {id: 5, obj: "Tabmix"},
get isValidWindow() {
/**
@@ -1164,6 +1166,11 @@ Tabmix.initialization = {
if (!this.isValidWindow)
return null;
let result, currentPhase = this[aPhase].id;
+ let getObj = function(list) {
+ let obj = window;
+ list.split(".").forEach(function(prop) {obj = obj[prop];});
+ return obj;
+ };
for (let key of Object.keys(this)) {
let phase = this[key];
if (phase.id > currentPhase)
@@ -1171,7 +1178,7 @@ Tabmix.initialization = {
if (!phase.initialized) {
phase.initialized = true;
try {
- let obj = window[phase.obj];
+ let obj = getObj(phase.obj);
result = obj[key].apply(obj, Array.slice(arguments, 1));
} catch (ex) {
Tabmix.assert(ex, phase.obj + "." + key + " failed");
--
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