・サブツリーが折りたたまれたタブに、隠れているタブの数を表示するようにした

・選択されていないタブを閉じた時にまでフォーカスを移動していたのを修正
・サブツリーをタブのダブルクリックで開閉する機能を加えた


git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1234 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-19 06:40:30 +00:00
parent 7578fb9ad8
commit 37d1567be7
7 changed files with 86 additions and 18 deletions

View File

@ -14,6 +14,9 @@
<preference id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
name="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
type="bool"/>
<preference id="extensions.treestyletab.collapseExpandSubTree.dblclick"
name="extensions.treestyletab.collapseExpandSubTree.dblclick"
type="bool"/>
<!--preference id="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
name="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
type="bool"/-->
@ -35,6 +38,9 @@
<checkbox id="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect-check"
preference="extensions.treestyletab.autoCollapseExpandSubTreeOnSelect"
label="&config.autoCollapseExpandSubTreeOnSelect;"/>
<checkbox id="extensions.treestyletab.collapseExpandSubTree.dblclick-check"
preference="extensions.treestyletab.collapseExpandSubTree.dblclick"
label="&config.collapseExpandSubTree.dblclick;"/>
<!--checkbox id="extensions.treestyletab.autoExpandSubTreeOnAppendChild-check"
preference="extensions.treestyletab.autoExpandSubTreeOnAppendChild"
label="&config.autoExpandSubTreeOnAppendChild;"/-->

View File

@ -1,2 +1,11 @@
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
tab:not([treestyletab-children]) .treestyletab-tab-tree-twisty,
tab:not([treestyletab-children]) .treestyletab-tab-tree-counter-container,
tab:not([treestyletab-subtree-collapsed="true"]) .treestyletab-tab-tree-counter-container {
display: none;
}
tab[treestyletab-tab-collapsed="true"] {
visibility: collapse;
}

View File

@ -8,8 +8,10 @@ var TreeStyleTabService = {
kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed',
kCOLLAPSED : 'treestyletab-tab-collapsed',
kTWISTY : 'treestyletab-tab-tree-twisty',
kTWISTY_CONTAINER : 'treestyletab-tab-tree-twisty-container',
kTWISTY : 'treestyletab-tab-tree-twisty',
kTWISTY_CONTAINER : 'treestyletab-tab-tree-twisty-container',
kCOUNTER : 'treestyletab-tab-tree-counter',
kCOUNTER_CONTAINER : 'treestyletab-tab-tree-counter-container',
kMENUITEM_REMOVESUBTREE_MULTIPLETAB_SELECTION : 'multipletab-selection-item-removeTabSubTree',
kMENUITEM_REMOVESUBTREE_CONTEXT : 'context-item-removeTabSubTree',
@ -260,6 +262,7 @@ var TreeStyleTabService = {
aTabBrowser.mTabContainer.addEventListener('TabMove', this, true);
aTabBrowser.mTabContainer.addEventListener('SSTabRestoring', this, true);
aTabBrowser.mTabContainer.addEventListener('click', this, true);
aTabBrowser.mTabContainer.addEventListener('dblclick', this, true);
aTabBrowser.mTabContainer.addEventListener('mousedown', this, true);
aTabBrowser.mTabContainer.addEventListener('select', this, true);
aTabBrowser.mPanelContainer.addEventListener('click', this, true);
@ -357,26 +360,43 @@ var TreeStyleTabService = {
this.setTabValue(aTab, this.kID, id);
aTab.__treestyletab__linkedTabBrowser = aTabBrowser;
this.initTabTwisty(aTab);
this.initTabContents(aTab);
var event = document.createEvent('Events');
event.initEvent('TreeStyleTab:TabOpen', true, false);
aTab.dispatchEvent(event);
},
initTabTwisty : function(aTab)
initTabContents : function(aTab)
{
if (document.getAnonymousElementByAttribute(aTab, 'class', this.kTWISTY)) return;
if (!document.getAnonymousElementByAttribute(aTab, 'class', this.kTWISTY)) {
var twisty = document.createElement('image');
twisty.setAttribute('class', this.kTWISTY);
var twisty = document.createElement('image');
twisty.setAttribute('class', this.kTWISTY);
var container = document.createElement('hbox');
container.setAttribute('class', this.kTWISTY_CONTAINER);
container.appendChild(twisty);
var container = document.createElement('hbox');
container.setAttribute('class', this.kTWISTY_CONTAINER);
container.appendChild(twisty);
var icon = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-icon');
icon.appendChild(container);
}
var icon = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-icon');
icon.appendChild(container);
if (!document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER_CONTAINER)) {
var counter = document.createElement('hbox');
counter.setAttribute('class', this.kCOUNTER_CONTAINER);
counter.appendChild(document.createElement('label'));
counter.lastChild.setAttribute('class', this.kCOUNTER);
counter.lastChild.setAttribute('value', '(0)');
var text = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text');
if (text) {
if (text.nextSibling)
text.parentNode.insertBefore(counter, text.nextSibling);
else
text.parentNode.appendChild(counter);
}
}
},
destroy : function()
@ -414,6 +434,7 @@ var TreeStyleTabService = {
aTabBrowser.mTabContainer.removeEventListener('TabMove', this, true);
aTabBrowser.mTabContainer.removeEventListener('SSTabRestoring', this, true);
aTabBrowser.mTabContainer.removeEventListener('click', this, true);
aTabBrowser.mTabContainer.removeEventListener('dblclick', this, true);
aTabBrowser.mTabContainer.removeEventListener('mousedown', this, true);
aTabBrowser.mTabContainer.removeEventListener('select', this, true);
aTabBrowser.mPanelContainer.removeEventListener('click', this, true);
@ -440,7 +461,7 @@ var TreeStyleTabService = {
case 'TabMove':
var tab = aEvent.originalTarget;
this.initTabTwisty(tab); // twisty vanished after the tab is moved!!
this.initTabContents(tab); // twisty vanished after the tab is moved!!
var b = this.getTabBrowserFromChildren(tab);
if (tab.getAttribute(this.kCHILDREN) && !b.__treestyletab__isSubTreeMoving) {
this.moveTabSubTreeTo(tab, tab._tPos);
@ -472,6 +493,17 @@ var TreeStyleTabService = {
}
return;
case 'dblclick':
var tab = this.getTabFromEvent(aEvent);
if (tab &&
tab.getAttribute(this.kCHILDREN) &&
this.getPref('extensions.treestyletab.collapseExpandSubTree.dblclick')) {
this.collapseExpandTabSubTree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault();
aEvent.stopPropagation();
}
return;
case 'mousedown':
this.onTabMouseDown(aEvent);
return;
@ -586,7 +618,7 @@ var TreeStyleTabService = {
}
}
if (nextFocusedTab)
if (nextFocusedTab && b.selectedTab == tab)
b.selectedTab = nextFocusedTab;
},
@ -886,6 +918,7 @@ var TreeStyleTabService = {
}
this.setTabValue(aParent, this.kCHILDREN, children);
this.updateTabsCount(aParent);
if (newIndex > aChild._tPos) newIndex--;
this.moveTabSubTreeTo(aChild, newIndex);
@ -899,6 +932,7 @@ var TreeStyleTabService = {
this.getPref('extensions.treestyletab.autoCollapseExpandSubTreeOnSelect')
) {
this.collapseExpandTreesIntelligentlyFor(aChild);
this.collapseExpandTabSubTree(aParent, false);
}
else if (aParent.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') {
if (this.getPref('extensions.treestyletab.autoExpandSubTreeOnAppendChild')) {
@ -935,6 +969,7 @@ var TreeStyleTabService = {
.replace(new RegExp('\\|'+id), '')
.replace(/^\|/, '');
this.setTabValue(parentTab, this.kCHILDREN, children);
this.updateTabsCount(parentTab);
if (!aDontUpdateIndent) this.updateTabsIndent([aChild]);
},
@ -961,6 +996,17 @@ var TreeStyleTabService = {
}
},
updateTabsCount : function(aTab)
{
var count = document.getAnonymousElementByAttribute(aTab, 'class', this.kCOUNTER);
if (count) {
count.setAttribute('value', '('+this.getDescendantTabsOf(aTab).length+')');
}
var parent = this.getParentTabOf(aTab);
if (parent)
this.updateTabsCount(parent);
},
moveTabSubTreeTo : function(aTab, aIndex)
{
if (!aTab) return;

View File

@ -1,4 +1,5 @@
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true);
pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false);
pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true);
pref("extensions.treestyletab.adoptChildrenToGrandParentOnRemoveTab", true);
// 0 = default, 1 = only visible tabs

View File

@ -4,6 +4,7 @@
<!ENTITY config.tabs.general "General">
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "Collapse distractive subtrees automatically, when a tab is opened or focused">
<!ENTITY config.collapseExpandSubTree.dblclick "Collapse/Expand subtree of the tab by double-click">
<!ENTITY config.autoExpandSubTreeOnAppendChild "Expand subtree automatically, when tabs are inserted into the subtree">

View File

@ -4,6 +4,7 @@
<!ENTITY config.tabs.general "全般">
<!ENTITY config.autoCollapseExpandSubTreeOnSelect "タブを開く時やタブを切り替える時に、関係ないサブツリーを自動的に折り畳む">
<!ENTITY config.collapseExpandSubTree.dblclick "タブのダブルクリックでサブツリーを開閉する">
<!ENTITY config.autoExpandSubTreeOnAppendChild "折り畳まれたサブツリー内に子孫のタブが追加された時、サブツリーを自動的に展開する">

View File

@ -19,10 +19,14 @@ tab[treestyletab-subtree-collapsed="true"] .treestyletab-tab-tree-twisty {
list-style-image: url("tree-twisty-collapsed.png");
}
tab:not([treestyletab-children]) .treestyletab-tab-tree-twisty {
display: none;
.treestyletab-tab-tree-counter-container {
-moz-box-align: center;
-moz-box-pack: end;
}
tab[treestyletab-tab-collapsed="true"] {
visibility: collapse;
.treestyletab-tab-tree-counter {
font-size: 90%;
margin: 0;
padding: 0;
min-width: 0;
}