From a5d2fac9f18f121f3bd5fb3c256a227da8d8099c Mon Sep 17 00:00:00 2001 From: YUKI Hiroshi Date: Tue, 13 Sep 2016 12:42:34 +0900 Subject: [PATCH] Allow to disable "shrink others while dragging" feature --- content/treestyletab/res/tabsDragUtils.js | 15 +++++++++++---- defaults/preferences/treestyletab.js | 5 +++++ modules/tabbarDNDObserver.js | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/content/treestyletab/res/tabsDragUtils.js b/content/treestyletab/res/tabsDragUtils.js index 2e2f4722..d35a08db 100644 --- a/content/treestyletab/res/tabsDragUtils.js +++ b/content/treestyletab/res/tabsDragUtils.js @@ -5,7 +5,9 @@ window['piro.sakura.ne.jp'].tabsDragUtils.initTabBrowser(gBrowser); // in dragstart event listener - window['piro.sakura.ne.jp'].tabsDragUtils.startTabsDrag(aEvent, aArrayOfTabs); + window['piro.sakura.ne.jp'].tabsDragUtils.startTabsDrag(aEvent, aArrayOfTabs, { + shrinkOthers : true // shrink other dragged tabs while dragging + }); This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this @@ -433,7 +435,7 @@ TDUContext.destroy(); updateDraggedTabs : function TDU_updateDraggedTabs(context) { context.draggedTabs.forEach(function(draggedTab, aIndex) { - if (aIndex > 0) { + if (draggedTab._dragData.canShrink && aIndex > 0) { let style = draggedTab.style; if (!draggedTab.__tabsDragUtils__backupStyle) { let backup = { @@ -582,8 +584,10 @@ TDUContext.destroy(); this.updatedTabDNDObservers = this.updatedTabDNDObservers.splice(index, 1); }, - startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs) + startTabsDrag : function TDU_startTabsDrag(aEvent, aTabs, aOptions) { + aOptions = aOptions || {}; + var draggedTab = this.getTabFromEvent(aEvent); var tabs = aTabs || []; var index = tabs.indexOf(draggedTab); @@ -622,15 +626,18 @@ TDUContext.destroy(); scrollX: isVertical ? 0 : tabbar.mTabstrip.scrollPosition , scrollY: isVertical ? tabbar.mTabstrip.scrollPosition : 0 , screenX: aEvent.screenX, - screenY: aEvent.screenY + screenY: aEvent.screenY, + canShrink : aOptions.shrinkOthers || false }; }, this); } aEvent.stopPropagation(); + if (aOptions.shrinkOthers) { document.addEventListener('dragend', this, true); document.addEventListener('drop', this, true); + } }, isVertical : function TDS_isVertical(aElement) { diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index 3932068d..27a0e3e9 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -671,6 +671,11 @@ pref("extensions.treestyletab.pinnedTab.faviconized", true); pref("extensions.treestyletab.groupTab.columnize", true); pref("extensions.treestyletab.groupTab.columnize.width", "20em"); +/** + * If true, other dragged tabs are shrunken while dragging. + */ +pref("extensions.treestyletab.shrinkOtherDraggedTabs", true); + /** * If true, TST automatically disables Tabs in Titlebar appearance to avoid * broken appearance problems. diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index 56695ef5..7a6ab9e1 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -773,7 +773,9 @@ catch(e) { ) return; - w['piro.sakura.ne.jp'].tabsDragUtils.startTabsDrag(aEvent, tabsInfo.draggedTabs); + w['piro.sakura.ne.jp'].tabsDragUtils.startTabsDrag(aEvent, tabsInfo.draggedTabs, { + shrinkOthers : utils.getTreePref('shrinkOtherDraggedTabs') + }); }, onTabbarDragStart : function TabbarDND_onTabbarDragStart(aEvent)