From 37d1567be7b894f751ec28258ce6f8c5c9d4a980 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 19 Oct 2007 06:40:30 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=BB=E3=82=B5=E3=83=96=E3=83=84=E3=83=AA?= =?UTF-8?q?=E3=83=BC=E3=81=8C=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=81=BE?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=82=BF=E3=83=96=E3=81=AB=E3=80=81=E9=9A=A0?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E3=82=BF=E3=83=96=E3=81=AE?= =?UTF-8?q?=E6=95=B0=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F=20=E3=83=BB=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=BF=E3=83=96=E3=82=92=E9=96=89=E3=81=98=E3=81=9F=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=81=BE=E3=81=A7=E3=83=95=E3=82=A9=E3=83=BC=E3=82=AB?= =?UTF-8?q?=E3=82=B9=E3=82=92=E7=A7=BB=E5=8B=95=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=20=E3=83=BB?= =?UTF-8?q?=E3=82=B5=E3=83=96=E3=83=84=E3=83=AA=E3=83=BC=E3=82=92=E3=82=BF?= =?UTF-8?q?=E3=83=96=E3=81=AE=E3=83=80=E3=83=96=E3=83=AB=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=81=A7=E9=96=8B=E9=96=89=E3=81=99=E3=82=8B?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E5=8A=A0=E3=81=88=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1234 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/config.xul | 6 ++ content/treestyletab/treestyletab.css | 9 +++ content/treestyletab/treestyletab.js | 74 ++++++++++++++++++---- defaults/preferences/treestyletab.js | 1 + locale/en-US/treestyletab/treestyletab.dtd | 1 + locale/ja/treestyletab/treestyletab.dtd | 1 + skin/classic/treestyletab/treestyletab.css | 12 ++-- 7 files changed, 86 insertions(+), 18 deletions(-) diff --git a/content/treestyletab/config.xul b/content/treestyletab/config.xul index 67456a0b..3a12e818 100644 --- a/content/treestyletab/config.xul +++ b/content/treestyletab/config.xul @@ -14,6 +14,9 @@ + @@ -35,6 +38,9 @@ + diff --git a/content/treestyletab/treestyletab.css b/content/treestyletab/treestyletab.css index 0494140a..14584cc0 100644 --- a/content/treestyletab/treestyletab.css +++ b/content/treestyletab/treestyletab.css @@ -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; +} diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 4eff2d94..f3ade609 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -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; diff --git a/defaults/preferences/treestyletab.js b/defaults/preferences/treestyletab.js index fc16dc3f..fa4a6bfa 100644 --- a/defaults/preferences/treestyletab.js +++ b/defaults/preferences/treestyletab.js @@ -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 diff --git a/locale/en-US/treestyletab/treestyletab.dtd b/locale/en-US/treestyletab/treestyletab.dtd index 75f822db..f5d5736a 100644 --- a/locale/en-US/treestyletab/treestyletab.dtd +++ b/locale/en-US/treestyletab/treestyletab.dtd @@ -4,6 +4,7 @@ + diff --git a/locale/ja/treestyletab/treestyletab.dtd b/locale/ja/treestyletab/treestyletab.dtd index 8196d188..b8a9a7e9 100644 --- a/locale/ja/treestyletab/treestyletab.dtd +++ b/locale/ja/treestyletab/treestyletab.dtd @@ -4,6 +4,7 @@ + diff --git a/skin/classic/treestyletab/treestyletab.css b/skin/classic/treestyletab/treestyletab.css index ff58c215..2051db27 100644 --- a/skin/classic/treestyletab/treestyletab.css +++ b/skin/classic/treestyletab/treestyletab.css @@ -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; }