子孫を持たないタブに新しい子タブを追加した時、自動で他のサブツリーを閉じるようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1228 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
435e437371
commit
9b461385d3
@ -14,9 +14,9 @@
|
||||
<preference id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
name="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
type="bool"/>
|
||||
<preference id="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
<!--preference id="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
name="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
type="bool"/>
|
||||
type="bool"/-->
|
||||
<preference id="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
name="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
type="bool"
|
||||
@ -32,9 +32,9 @@
|
||||
<checkbox id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect-check"
|
||||
preference="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
label="&config.autoCollapseExpandSubTreeOnSelect;"/>
|
||||
<checkbox id="extensions.treestyletab.autoExpandSubTreeOnAppendChild-check"
|
||||
<!--checkbox id="extensions.treestyletab.autoExpandSubTreeOnAppendChild-check"
|
||||
preference="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
label="&config.autoExpandSubTreeOnAppendChild;"/>
|
||||
label="&config.autoExpandSubTreeOnAppendChild;"/-->
|
||||
<checkbox id="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab-check"
|
||||
preference="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
label="&config.adoptChildrenToGrandParentOnRemoveTab;"/>
|
||||
|
@ -39,7 +39,7 @@ var TreeStyleTabService = {
|
||||
_SessionStore : null,
|
||||
|
||||
/* Utilities */
|
||||
|
||||
|
||||
isEventFiredOnTabIcon : function(aEvent)
|
||||
{
|
||||
var tab = this.getTabFromEvent(aEvent);
|
||||
@ -65,7 +65,7 @@ var TreeStyleTabService = {
|
||||
}
|
||||
return (node && node.getAttribute('class') == this.kTWISTY) ? true : false ;
|
||||
},
|
||||
|
||||
|
||||
get browser()
|
||||
{
|
||||
return 'SplitBrowser' ? SplitBrowser.activeBrowser : gBrowser ;
|
||||
@ -200,7 +200,7 @@ var TreeStyleTabService = {
|
||||
},
|
||||
|
||||
/* Initializing */
|
||||
|
||||
|
||||
init : function()
|
||||
{
|
||||
if (!('gBrowser' in window)) return;
|
||||
@ -237,7 +237,7 @@ var TreeStyleTabService = {
|
||||
|
||||
this.initTabBrowser(gBrowser);
|
||||
},
|
||||
|
||||
|
||||
initTabBrowser : function(aTabBrowser)
|
||||
{
|
||||
aTabBrowser.mTabContainer.addEventListener('TreeStyleTab:TabOpen', this, true);
|
||||
@ -634,45 +634,10 @@ var TreeStyleTabService = {
|
||||
else if (tab.getAttribute(this.kCHILDREN) &&
|
||||
(tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') &&
|
||||
this.getPref('extensions.treestyletab.autoCollapseExpandSubTreeOnSelect')) {
|
||||
var expandedParentTabs = [
|
||||
tab.getAttribute(this.kID)
|
||||
];
|
||||
var parentTab = tab;
|
||||
while (parentTab = this.getParentTabOf(parentTab))
|
||||
{
|
||||
expandedParentTabs.push(parentTab.getAttribute(this.kID));
|
||||
}
|
||||
expandedParentTabs = expandedParentTabs.join('|');
|
||||
try {
|
||||
var xpathResult = document.evaluate(
|
||||
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and not(contains("'+expandedParentTabs+'", @'+this.kID+'))]',
|
||||
b.mTabContainer,
|
||||
this.NSResolver,
|
||||
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
||||
null
|
||||
);
|
||||
var collapseTab;
|
||||
var isDescendant;
|
||||
for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++)
|
||||
{
|
||||
isDescendant = false;
|
||||
collapseTab = xpathResult.snapshotItem(i);
|
||||
var parentTab = collapseTab;
|
||||
while (parentTab = this.getParentTabOf(parentTab))
|
||||
{
|
||||
if (parentTab != tab) continue;
|
||||
isDescendant = true;
|
||||
}
|
||||
if (!isDescendant)
|
||||
this.collapseExpandTabSubTree(collapseTab, true);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
this.collapseExpandTabSubTree(tab, false);
|
||||
this.collapseExpandTreesIntelligentlyFor(tab);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/* Tab Utilities */
|
||||
|
||||
getTabValue : function(aTab, aKey)
|
||||
@ -901,13 +866,21 @@ var TreeStyleTabService = {
|
||||
if (newIndex > aChild._tPos) newIndex--;
|
||||
this.moveTabSubTreeTo(aChild, newIndex);
|
||||
|
||||
if (aParent.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') {
|
||||
if (this.getPref('extensions.treestyletab.autoExpandSubTreeOnAppendChild')) {
|
||||
var p = aParent;
|
||||
do {
|
||||
this.collapseExpandTabSubTree(p, false);
|
||||
}
|
||||
while (p = this.getParentTabOf(p));
|
||||
if (
|
||||
(
|
||||
aParent.getAttribute(this.kSUBTREE_COLLAPSED) == 'true' ||
|
||||
children.indexOf('|') < 0 // first child
|
||||
) &&
|
||||
this.getPref('extensions.treestyletab.autoCollapseExpandSubTreeOnSelect')
|
||||
) {
|
||||
this.collapseExpandTreesIntelligentlyFor(aChild);
|
||||
}
|
||||
else if (aParent.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') {
|
||||
var p = aParent;
|
||||
do {
|
||||
this.collapseExpandTabSubTree(p, false);
|
||||
}
|
||||
while (p = this.getParentTabOf(p));
|
||||
}
|
||||
else
|
||||
this.collapseExpandTab(aChild, true);
|
||||
@ -1008,6 +981,47 @@ var TreeStyleTabService = {
|
||||
this.collapseExpandTab(tabs[i], aCollapse);
|
||||
}
|
||||
},
|
||||
|
||||
collapseExpandTreesIntelligentlyFor : function(aTab)
|
||||
{
|
||||
var b = this.getTabBrowserFromChildren(aTab);
|
||||
var expandedParentTabs = [
|
||||
aTab.getAttribute(this.kID)
|
||||
];
|
||||
var parentTab = aTab;
|
||||
while (parentTab = this.getParentTabOf(parentTab))
|
||||
{
|
||||
expandedParentTabs.push(parentTab.getAttribute(this.kID));
|
||||
}
|
||||
expandedParentTabs = expandedParentTabs.join('|');
|
||||
try {
|
||||
var xpathResult = document.evaluate(
|
||||
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and not(contains("'+expandedParentTabs+'", @'+this.kID+'))]',
|
||||
b.mTabContainer,
|
||||
this.NSResolver,
|
||||
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
||||
null
|
||||
);
|
||||
var collapseTab;
|
||||
var isDescendant;
|
||||
for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++)
|
||||
{
|
||||
isDescendant = false;
|
||||
collapseTab = xpathResult.snapshotItem(i);
|
||||
var parentTab = collapseTab;
|
||||
while (parentTab = this.getParentTabOf(parentTab))
|
||||
{
|
||||
if (parentTab != aTab) continue;
|
||||
isDescendant = true;
|
||||
}
|
||||
if (!isDescendant)
|
||||
this.collapseExpandTabSubTree(collapseTab, true);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
this.collapseExpandTabSubTree(aTab, false);
|
||||
},
|
||||
|
||||
/* Pref Listener */
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<!ENTITY config.tabs.general "General">
|
||||
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "Collapse distractive subtrees automatically, when a tab is focused">
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "Collapse distractive subtrees automatically, when a tab is opened or focused">
|
||||
|
||||
<!ENTITY config.autoExpandSubTreeOnAppendChild "Expand subtree automatically, when tabs are inserted into the subtree">
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
<!ENTITY config.tabs.general "全般">
|
||||
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "タブを切り替える時、関係ないサブツリーを自動的に折り畳む">
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "タブを開く時やタブを切り替える時に、関係ないサブツリーを自動的に折り畳む">
|
||||
|
||||
<!ENTITY config.autoExpandSubTreeOnAppendChild "折り畳まれたサブツリー内に子孫のタブが追加された時、サブツリーを自動的に展開する">
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user