From af4d2f7b40dfaa2b9dad92a5d20212ee279da8bf Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Tue, 16 Feb 2016 00:29:30 +0900 Subject: [PATCH] Don't show pseud tree in multiple columns if the container is narrow --- modules/groupTab.js | 24 ++---------------------- modules/pseudoTreeBuilder.js | 28 +++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/modules/groupTab.js b/modules/groupTab.js index 21765f63..3ccb49cc 100644 --- a/modules/groupTab.js +++ b/modules/groupTab.js @@ -14,7 +14,7 @@ * The Original Code is the Tree Style Tab. * * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. - * Portions created by the Initial Developer are Copyright (C) 2010-2014 + * Portions created by the Initial Developer are Copyright (C) 2010-2016 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi @@ -404,27 +404,7 @@ GroupTab.prototype = inherit(TreeStyleTabBase, { onResize : function GT_onResize() { var container = this.document.getElementById('tree'); - var tree = container.firstChild; - - var style = tree.style; - var height = tree.clientHeight * (tree.columnCount || 1); - if (height > container.boxObject.height) { - tree.columnCount = style.columnCount = style.MozColumnCount = 2; - var maxWidth = container.boxObject.width; - style.columnWidth = style.MozColumnWidth = Math.floor(maxWidth * 0.45)+'px'; - style.columnGap = style.MozColumnGap = Math.floor(maxWidth * 0.05)+'px'; - } - else { - tree.columnCount = 1; - style.columnCount = style.MozColumnCount = - style.columnWidth = style.MozColumnWidth = - style.columnGap = style.MozColumnGap = ''; - } - - var items = this.document.querySelectorAll('*|*.' + PseudoTreeBuilder.kTREEITEM); - Array.forEach(items, function(aItem) { - aItem.style.minHeight = (aItem.lastChild.boxObject.height + 1) + 'px'; - }, this); + PseudoTreeBuilder.layoutTree(container.firstChild); }, onTabAttached : function GT_onTabAttached(aEvent) diff --git a/modules/pseudoTreeBuilder.js b/modules/pseudoTreeBuilder.js index 874cb75e..f74265c3 100644 --- a/modules/pseudoTreeBuilder.js +++ b/modules/pseudoTreeBuilder.js @@ -14,7 +14,7 @@ * The Original Code is the Tree Style Tab. * * The Initial Developer of the Original Code is YUKI "Piro" Hiroshi. - * Portions created by the Initial Developer are Copyright (C) 2011-2015 + * Portions created by the Initial Developer are Copyright (C) 2011-2016 * the Initial Developer. All Rights Reserved. * * Contributor(s): YUKI "Piro" Hiroshi @@ -146,5 +146,31 @@ var PseudoTreeBuilder = { container.appendChild(this.createTabItem(children[i])); } return container; + }, + + layoutTree : function TB_layoutTree(aTree, aContainer) + { + aContainer = aContainer || aTree.parentNode; + + var style = aTree.style; + var height = aTree.clientHeight * (aTree.columnCount || 1); + if (height > aContainer.boxObject.height && + aContainer.boxObject.height < aContainer.boxObject.width) { + aTree.columnCount = style.columnCount = style.MozColumnCount = 2; + var maxWidth = aContainer.boxObject.width; + style.columnWidth = style.MozColumnWidth = Math.floor(maxWidth * 0.45)+'px'; + style.columnGap = style.MozColumnGap = Math.floor(maxWidth * 0.05)+'px'; + } + else { + aTree.columnCount = 1; + style.columnCount = style.MozColumnCount = + style.columnWidth = style.MozColumnWidth = + style.columnGap = style.MozColumnGap = ''; + } + + var items = aTree.querySelectorAll('*|*.' + this.kTREEITEM); + Array.forEach(items, function(aItem) { + aItem.style.minHeight = (aItem.lastChild.boxObject.height + 1) + 'px'; + }, this); } };