now we can set maximum level of nesting
This commit is contained in:
parent
ee0ad57175
commit
89732dc67b
@ -13,7 +13,7 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.tabbrowser-tabs[treestyletab-allow-subtree-collapse="true"]
|
.tabbrowser-tabs[treestyletab-allow-subtree-collapse="true"]
|
||||||
.tabbrowser-tab[treestyletab-children]
|
.tabbrowser-tab[treestyletab-children][treestyletab-allow-subtree-collapse="true"]
|
||||||
.treestyletab-twisty {
|
.treestyletab-twisty {
|
||||||
display: -moz-box;
|
display: -moz-box;
|
||||||
}
|
}
|
||||||
@ -23,7 +23,7 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.tabbrowser-tabs[treestyletab-allow-subtree-collapse="true"]
|
.tabbrowser-tabs[treestyletab-allow-subtree-collapse="true"]
|
||||||
.tabbrowser-tab[treestyletab-children][treestyletab-subtree-collapsed="true"]
|
.tabbrowser-tab[treestyletab-children][treestyletab-subtree-collapsed="true"][treestyletab-allow-subtree-collapse="true"]
|
||||||
.treestyletab-counter-container {
|
.treestyletab-counter-container {
|
||||||
display: -moz-box;
|
display: -moz-box;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,9 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
invertedPositionProp : 'screenX',
|
invertedPositionProp : 'screenX',
|
||||||
invertedSizeProp : 'width',
|
invertedSizeProp : 'width',
|
||||||
|
|
||||||
|
maxTreeLevel : -1,
|
||||||
|
maxTreeLevelPhisical : false,
|
||||||
|
|
||||||
enableSubtreeIndent : true,
|
enableSubtreeIndent : true,
|
||||||
allowSubtreeCollapseExpand : true,
|
allowSubtreeCollapseExpand : true,
|
||||||
hideAlltabsButton : true,
|
hideAlltabsButton : true,
|
||||||
@ -400,7 +403,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
<![CDATA[$&
|
<![CDATA[$&
|
||||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
||||||
treeStyleTab._focusChangedByShortcut = TreeStyleTabService.accelKeyPressed;
|
treeStyleTab._focusChangedByShortcut = TreeStyleTabService.accelKeyPressed;
|
||||||
if (treeStyleTab.canCollapseSubtree() &&
|
if (treeStyleTab.canCollapseSubtree(this.selectedItem) &&
|
||||||
treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) {
|
treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) {
|
||||||
(function(aDir, aWrap, aSelf) {
|
(function(aDir, aWrap, aSelf) {
|
||||||
var nextTab = (aDir < 0) ? treeStyleTab.getPreviousVisibleTab(aSelf.selectedItem) : treeStyleTab.getNextVisibleTab(aSelf.selectedItem) ;
|
var nextTab = (aDir < 0) ? treeStyleTab.getPreviousVisibleTab(aSelf.selectedItem) : treeStyleTab.getNextVisibleTab(aSelf.selectedItem) ;
|
||||||
@ -705,6 +708,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.onPrefChange('extensions.treestyletab.maxTreeLevel');
|
||||||
this.onPrefChange('extensions.treestyletab.tabbar.style');
|
this.onPrefChange('extensions.treestyletab.tabbar.style');
|
||||||
this.onPrefChange('extensions.treestyletab.twisty.style');
|
this.onPrefChange('extensions.treestyletab.twisty.style');
|
||||||
this.onPrefChange('extensions.treestyletab.showBorderForFirstTab');
|
this.onPrefChange('extensions.treestyletab.showBorderForFirstTab');
|
||||||
@ -1841,6 +1845,20 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.checkTabsIndentOverflow();
|
this.checkTabsIndentOverflow();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'extensions.treestyletab.maxTreeLevel':
|
||||||
|
this.maxTreeLevel = value;
|
||||||
|
if (this.maxTreeLevelPhisical)
|
||||||
|
this.promoteTooDeepLevelTabs();
|
||||||
|
else
|
||||||
|
this.updateAllTabsIndent();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'extensions.treestyletab.maxTreeLevel.phisical':
|
||||||
|
this.maxTreeLevelPhisical = value;
|
||||||
|
if (this.maxTreeLevelPhisical)
|
||||||
|
this.promoteTooDeepLevelTabs();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'browser.tabs.animate':
|
case 'browser.tabs.animate':
|
||||||
case 'extensions.treestyletab.animation.enabled':
|
case 'extensions.treestyletab.animation.enabled':
|
||||||
this.setTabbrowserAttribute(this.kANIMATION_ENABLED,
|
this.setTabbrowserAttribute(this.kANIMATION_ENABLED,
|
||||||
@ -3051,7 +3069,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.isEventFiredOnTwisty(aEvent)) {
|
if (this.isEventFiredOnTwisty(aEvent)) {
|
||||||
if (this.hasChildTabs(aTab) && this.canCollapseSubtree()) {
|
if (this.hasChildTabs(aTab) && this.canCollapseSubtree(aTab)) {
|
||||||
this.collapseExpandSubtree(aTab, aTab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
|
this.collapseExpandSubtree(aTab, aTab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
|
||||||
aEvent.preventDefault();
|
aEvent.preventDefault();
|
||||||
aEvent.stopPropagation();
|
aEvent.stopPropagation();
|
||||||
@ -3893,6 +3911,17 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
attachTabTo : function TSTBrowser_attachTabTo(aChild, aParent, aInfo) /* PUBLIC API */
|
attachTabTo : function TSTBrowser_attachTabTo(aChild, aParent, aInfo) /* PUBLIC API */
|
||||||
{
|
{
|
||||||
|
aInfo = aInfo || {};
|
||||||
|
|
||||||
|
if (aParent && this.maxTreeLevelPhisical && this.maxTreeLevel > -1) {
|
||||||
|
let level = parseInt(aParent.getAttribute(this.kNEST) || 0) + 1;
|
||||||
|
while (aParent && level > this.maxTreeLevel)
|
||||||
|
{
|
||||||
|
level--;
|
||||||
|
aParent = this.getParentTab(aParent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var currentParent;
|
var currentParent;
|
||||||
if (
|
if (
|
||||||
!aChild ||
|
!aChild ||
|
||||||
@ -4013,6 +4042,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.checkTabsIndentOverflow();
|
this.checkTabsIndentOverflow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.promoteTooDeepLevelTabs(aChild);
|
||||||
|
|
||||||
this.fireAttachedEvent(aChild, aParent);
|
this.fireAttachedEvent(aChild, aParent);
|
||||||
},
|
},
|
||||||
fireAttachedEvent : function TSTBrowser_fireAttachedEvent(aChild, aParent)
|
fireAttachedEvent : function TSTBrowser_fireAttachedEvent(aChild, aParent)
|
||||||
@ -4157,7 +4188,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var margin = this.indent < 0 ? this.baseIndent : this.indent ;
|
var margin = this.indent < 0 ? this.baseIndent : this.indent ;
|
||||||
var indent = margin * aLevel;
|
var indent = (this.maxTreeLevel < 0 ? aLevel : Math.min(aLevel, this.maxTreeLevel) ) * margin;
|
||||||
|
|
||||||
var multirow = this.isMultiRow();
|
var multirow = this.isMultiRow();
|
||||||
if (multirow) {
|
if (multirow) {
|
||||||
@ -4169,6 +4200,14 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (!aTab.parentNode) return; // ignore removed tabs
|
if (!aTab.parentNode) return; // ignore removed tabs
|
||||||
this.updateTabIndent(aTab, indent, aJustNow);
|
this.updateTabIndent(aTab, indent, aJustNow);
|
||||||
aTab.setAttribute(this.kNEST, aLevel);
|
aTab.setAttribute(this.kNEST, aLevel);
|
||||||
|
if (this.maxTreeLevel < 0 || this.maxTreeLevel > aLevel) {
|
||||||
|
aTab.setAttribute(this.kALLOW_COLLAPSE, true);
|
||||||
|
this.collapseExpandSubtree(aTab, this.isSubtreeCollapsed(aTab));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.collapseExpandSubtree(aTab, false);
|
||||||
|
aTab.removeAttribute(this.kALLOW_COLLAPSE);
|
||||||
|
}
|
||||||
this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aJustNow);
|
this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aJustNow);
|
||||||
}, this);
|
}, this);
|
||||||
},
|
},
|
||||||
@ -4320,7 +4359,10 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var self = this;
|
var self = this;
|
||||||
tabs.sort(function(aA, aB) { return Number(aA.getAttribute(self.kNEST)) - Number(aB.getAttribute(self.kNEST)); });
|
tabs.sort(function(aA, aB) { return Number(aA.getAttribute(self.kNEST)) - Number(aB.getAttribute(self.kNEST)); });
|
||||||
var nest = tabs[tabs.length-1].getAttribute(this.kNEST);
|
var nest = tabs[tabs.length-1].getAttribute(this.kNEST);
|
||||||
if (!nest) return;
|
if (this.maxTreeLevel > -1)
|
||||||
|
nest = Math.min(nest, this.maxTreeLevel);
|
||||||
|
if (!nest)
|
||||||
|
return;
|
||||||
|
|
||||||
var oldIndent = this.indent;
|
var oldIndent = this.indent;
|
||||||
var indent = (oldIndent < 0 ? this.baseIndent : oldIndent ) * nest;
|
var indent = (oldIndent < 0 ? this.baseIndent : oldIndent ) * nest;
|
||||||
@ -4363,6 +4405,32 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.updateTabsCount(parent);
|
this.updateTabsCount(parent);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
promoteTooDeepLevelTabs : function TSTBrowser_promoteTooDeepLevelTabs(aParent)
|
||||||
|
{
|
||||||
|
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ;
|
||||||
|
tabs.forEach(function(aTab) {
|
||||||
|
var level = parseInt(aTab.getAttribute(this.kNEST) || 0);
|
||||||
|
if (level <= this.maxTreeLevel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var parent = this.getParentTab(aTab);
|
||||||
|
var newParent = this.getParentTab(parent);
|
||||||
|
if (this.maxTreeLevel == 0 || !newParent) {
|
||||||
|
this.partTab(aTab);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let nextSibling = this.getNextTab(aTab);
|
||||||
|
this.attachTabTo(aTab, newParent, {
|
||||||
|
dontMove : true,
|
||||||
|
insertBefore : nextSibling
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
/* move */
|
/* move */
|
||||||
|
|
||||||
moveTabSubtreeTo : function TSTBrowser_moveTabSubtreeTo(aTab, aIndex)
|
moveTabSubtreeTo : function TSTBrowser_moveTabSubtreeTo(aTab, aIndex)
|
||||||
@ -4539,7 +4607,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
aJustNow ||
|
aJustNow ||
|
||||||
this.collapseDuration < 1 ||
|
this.collapseDuration < 1 ||
|
||||||
// !this.isVertical ||
|
// !this.isVertical ||
|
||||||
!this.canCollapseSubtree()
|
!this.canCollapseSubtree(this.getParentTab(aTab))
|
||||||
) {
|
) {
|
||||||
if (aCollapsed)
|
if (aCollapsed)
|
||||||
aTab.setAttribute(this.kCOLLAPSED_DONE, true);
|
aTab.setAttribute(this.kCOLLAPSED_DONE, true);
|
||||||
@ -4646,7 +4714,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
{
|
{
|
||||||
if (!aTab ||
|
if (!aTab ||
|
||||||
this.doingCollapseExpand ||
|
this.doingCollapseExpand ||
|
||||||
!this.canCollapseSubtree())
|
!this.canCollapseSubtree(aTab))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
|
@ -56,6 +56,8 @@ pref("extensions.treestyletab.autoExpand.enabled", true);
|
|||||||
pref("extensions.treestyletab.autoExpand.delay", 500);
|
pref("extensions.treestyletab.autoExpand.delay", 500);
|
||||||
pref("extensions.treestyletab.autoExpand.intelligently", true);
|
pref("extensions.treestyletab.autoExpand.intelligently", true);
|
||||||
pref("extensions.treestyletab.autoExpand.collapseFinally", false);
|
pref("extensions.treestyletab.autoExpand.collapseFinally", false);
|
||||||
|
pref("extensions.treestyletab.maxTreeLevel", -1);
|
||||||
|
pref("extensions.treestyletab.maxTreeLevel.phisical", false);
|
||||||
pref("extensions.treestyletab.indent", 12);
|
pref("extensions.treestyletab.indent", 12);
|
||||||
pref("extensions.treestyletab.indent.property", "margin");
|
pref("extensions.treestyletab.indent.property", "margin");
|
||||||
// pref("extensions.treestyletab.indent.property.top", "");
|
// pref("extensions.treestyletab.indent.property.top", "");
|
||||||
|
@ -1338,9 +1338,14 @@ var TreeStyleTabUtils = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
canCollapseSubtree : function TSTUtils_canCollapseSubtree(aTabBrowser) /* PUBLIC API */
|
canCollapseSubtree : function TSTUtils_canCollapseSubtree(aTabOrTabBrowser) /* PUBLIC API */
|
||||||
{
|
{
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowser) || this.browser;
|
if (aTabOrTabBrowser &&
|
||||||
|
aTabOrTabBrowser.localName == 'tab' &&
|
||||||
|
aTabOrTabBrowser.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTabOrTabBrowser) || this.browser;
|
||||||
return b.getAttribute(this.kALLOW_COLLAPSE) == 'true';
|
return b.getAttribute(this.kALLOW_COLLAPSE) == 'true';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user