Windowsエクスプローラ風に、邪魔なサブツリーを自動的に畳むようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1227 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
ee84bab985
commit
435e437371
@ -11,13 +11,16 @@
|
||||
|
||||
<prefpane id="prefpane-general" label="&config.tabs.general;">
|
||||
<preferences>
|
||||
<preference id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
name="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
type="bool"/>
|
||||
<preference id="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
name="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
type="bool"/>
|
||||
<preference id="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
name="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
type="bool"
|
||||
inverted="true"/>
|
||||
<preference id="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
name="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
type="bool"/>
|
||||
<preference id="browser.link.open_newwindow"
|
||||
name="browser.link.open_newwindow"
|
||||
type="int"/>
|
||||
@ -26,12 +29,15 @@
|
||||
type="int"/>
|
||||
</preferences>
|
||||
|
||||
<checkbox id="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab-check"
|
||||
preference="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
label="&config.adoptChildrenToGrandParentOnRemoveTab;"/>
|
||||
<checkbox id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect-check"
|
||||
preference="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
|
||||
label="&config.autoCollapseExpandSubTreeOnSelect;"/>
|
||||
<checkbox id="extensions.treestyletab.autoExpandSubTreeOnAppendChild-check"
|
||||
preference="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
|
||||
label="&config.autoExpandSubTreeOnAppendChild;"/>
|
||||
<checkbox id="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab-check"
|
||||
preference="extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab"
|
||||
label="&config.adoptChildrenToGrandParentOnRemoveTab;"/>
|
||||
<groupbox>
|
||||
<caption label="&config.open_newwindow.caption;"/>
|
||||
<vbox>
|
||||
|
@ -171,7 +171,7 @@ var TreeStyleTabService = {
|
||||
var xpathResult = document.evaluate(
|
||||
'descendant::xul:menuseparator',
|
||||
aPopup,
|
||||
this.NSResolver, // document.createNSResolver(document.documentElement),
|
||||
this.NSResolver,
|
||||
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
|
||||
null
|
||||
);
|
||||
@ -188,7 +188,7 @@ var TreeStyleTabService = {
|
||||
var xpathResult = document.evaluate(
|
||||
'descendant::xul:menuseparator[not(@hidden)][not(following-sibling::*[not(@hidden)]) or not(preceding-sibling::*[not(@hidden)]) or local-name(following-sibling::*[not(@hidden)]) = "menuseparator"]',
|
||||
aPopup,
|
||||
this.NSResolver, // document.createNSResolver(document.documentElement),
|
||||
this.NSResolver,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
null
|
||||
);
|
||||
@ -437,12 +437,7 @@ var TreeStyleTabService = {
|
||||
return;
|
||||
|
||||
case 'select':
|
||||
var b = this.getTabBrowserFromChildren(aEvent.currentTarget);
|
||||
var tab = b.selectedTab
|
||||
var p;
|
||||
if (tab.getAttribute(this.kCOLLAPSED) && (p = this.getParentTabOf(tab))) {
|
||||
b.selectedTab = p;
|
||||
}
|
||||
this.onTabSelect(aEvent);
|
||||
return;
|
||||
|
||||
case 'load':
|
||||
@ -616,6 +611,67 @@ var TreeStyleTabService = {
|
||||
aEvent.preventDefault();
|
||||
aEvent.stopPropagation();
|
||||
},
|
||||
|
||||
onTabSelect : function(aEvent)
|
||||
{
|
||||
var b = this.getTabBrowserFromChildren(aEvent.currentTarget);
|
||||
var tab = b.selectedTab
|
||||
|
||||
/*
|
||||
var p;
|
||||
if ((tab.getAttribute(this.kCOLLAPSED) == 'true') &&
|
||||
(p = this.getParentTabOf(tab))) {
|
||||
b.selectedTab = p;
|
||||
}
|
||||
*/
|
||||
if (tab.getAttribute(this.kCOLLAPSED) == 'true') {
|
||||
var parentTab = tab;
|
||||
while (parentTab = this.getParentTabOf(parentTab))
|
||||
{
|
||||
this.collapseExpandTabSubTree(parentTab, false);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
/* Tab Utilities */
|
||||
|
||||
@ -661,7 +717,7 @@ var TreeStyleTabService = {
|
||||
var xpathResult = document.evaluate(
|
||||
'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]',
|
||||
aTabBrowser.mTabContainer,
|
||||
this.NSResolver, // document.createNSResolver(document.documentElement),
|
||||
this.NSResolver,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
null
|
||||
);
|
||||
@ -679,7 +735,7 @@ var TreeStyleTabService = {
|
||||
var xpathResult = document.evaluate(
|
||||
'parent::*/child::xul:tab[contains(@'+this.kCHILDREN+', "'+id+'")]',
|
||||
aTab,
|
||||
this.NSResolver, // document.createNSResolver(document.documentElement),
|
||||
this.NSResolver,
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||
null
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
pref("extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab", true);
|
||||
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true);
|
||||
pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true);
|
||||
pref("extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab", true);
|
||||
|
||||
pref("browser.link.open_newwindow.restriction", 0);
|
||||
|
||||
|
@ -3,10 +3,12 @@
|
||||
|
||||
<!ENTITY config.tabs.general "General">
|
||||
|
||||
<!ENTITY config.adoptChildrenToGrandParentOnRemoveTab "Liberate child tabs from the tree when the parent tab is closed">
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "Collapse distractive subtrees automatically, when a tab is focused">
|
||||
|
||||
<!ENTITY config.autoExpandSubTreeOnAppendChild "Expand subtree automatically, when tabs are inserted into the subtree">
|
||||
|
||||
<!ENTITY config.adoptChildrenToGrandParentOnRemoveTab "Liberate child tabs from the tree when the parent tab is closed">
|
||||
|
||||
<!ENTITY config.open_newwindow.caption "New window opened from links in webpages unexpectedly">
|
||||
<!ENTITY config.open_newwindow.window "Open as Window">
|
||||
<!ENTITY config.open_newwindow.tab "Open as Tab (default)">
|
||||
|
@ -3,9 +3,11 @@
|
||||
|
||||
<!ENTITY config.tabs.general "全般">
|
||||
|
||||
<!ENTITY config.adoptChildrenToGrandParentOnRemoveTab "親のタブを閉じたら子孫のタブをツリーから解放する">
|
||||
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "タブを切り替える時、関係ないサブツリーを自動的に折り畳む">
|
||||
|
||||
<!ENTITY config.autoExpandSubTreeOnAppendChild "畳まれたサブツリー内に子孫のタブが追加された時、サブツリーを自動的に展開する">
|
||||
<!ENTITY config.autoExpandSubTreeOnAppendChild "折り畳まれたサブツリー内に子孫のタブが追加された時、サブツリーを自動的に展開する">
|
||||
|
||||
<!ENTITY config.adoptChildrenToGrandParentOnRemoveTab "親のタブを閉じたら子孫のタブをツリーから解放する">
|
||||
|
||||
<!ENTITY config.open_newwindow.caption "Webページのリンクから勝手に開かれたウィンドウの制御">
|
||||
<!ENTITY config.open_newwindow.window "ウィンドウで開く">
|
||||
|
Loading…
Reference in New Issue
Block a user