From 2654bb16ac6fd218c9965ac49ad1cf0f00807acc Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 18 Dec 2009 09:05:41 +0000 Subject: [PATCH] =?UTF-8?q?TreeStyleTabService.treeViewEnabled=20=3D=20tru?= =?UTF-8?q?e/false=20=E3=81=A7=E3=83=84=E3=83=AA=E3=83=BC=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=AEON=E3=83=BBOFF=E3=82=92=E5=8D=B3=E5=BA=A7?= =?UTF-8?q?=E3=81=AB=E5=88=87=E3=82=8A=E6=9B=BF=E3=81=88=E3=82=89=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=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@5558 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 100 ++++++++++++-------- content/treestyletab/treestyletabbrowser.js | 91 ++++++++++++------ 2 files changed, 121 insertions(+), 70 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index b83e2376..01b888eb 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1157,48 +1157,6 @@ var TreeStyleTabService = { aTab.linkedBrowser.currentURI.spec.indexOf('about:treestyletab-group') > -1 ); }, - - promoteTab : function(aTab) - { - var b = this.getTabBrowserFromChild(aTab); - var sv = b.treeStyleTab; - - var parent = sv.getParentTab(aTab); - if (!parent) return; - - var nextSibling = sv.getNextSiblingTab(parent); - - var grandParent = sv.getParentTab(parent); - if (grandParent) { - sv.attachTabTo(aTab, grandParent, { - insertBefore : nextSibling - }); - } - else { - sv.partTab(aTab); - let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ; - if (index > aTab._tPos) index--; - b.moveTabTo(aTab, index); - } - }, - promoteCurrentTab : function() - { - this.promoteTab(this.browser.selectedTab); - }, - - demoteTab : function(aTab) - { - var b = this.getTabBrowserFromChild(aTab); - var sv = b.treeStyleTab; - - var previous = this.getPreviousSiblingTab(aTab); - if (previous) - sv.attachTabTo(aTab, previous); - }, - demoteCurrentTab : function() - { - this.demoteTab(this.browser.selectedTab); - }, /* Session Store API */ @@ -2652,6 +2610,64 @@ catch(e) { ); }, + promoteTab : function(aTab) /* PUBLIC API */ + { + var b = this.getTabBrowserFromChild(aTab); + var sv = b.treeStyleTab; + + var parent = sv.getParentTab(aTab); + if (!parent) return; + + var nextSibling = sv.getNextSiblingTab(parent); + + var grandParent = sv.getParentTab(parent); + if (grandParent) { + sv.attachTabTo(aTab, grandParent, { + insertBefore : nextSibling + }); + } + else { + sv.partTab(aTab); + let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ; + if (index > aTab._tPos) index--; + b.moveTabTo(aTab, index); + } + }, + promoteCurrentTab : function() /* PUBLIC API */ + { + this.promoteTab(this.browser.selectedTab); + }, + + demoteTab : function(aTab) /* PUBLIC API */ + { + var b = this.getTabBrowserFromChild(aTab); + var sv = b.treeStyleTab; + + var previous = this.getPreviousSiblingTab(aTab); + if (previous) + sv.attachTabTo(aTab, previous); + }, + demoteCurrentTab : function() /* PUBLIC API */ + { + this.demoteTab(this.browser.selectedTab); + }, + + get treeViewEnabled() /* PUBLIC API */ + { + return this._treeViewEnabled; + }, + set treeViewEnabled(aValue) + { + this._treeViewEnabled = aValue ? true : false ; + this.ObserverService.notifyObservers( + window, + 'TreeStyleTab:changeTreeViewAvailability', + this._treeViewEnabled + ); + return aValue; + }, + _treeViewEnabled : true, + expandTreeAfterKeyReleased : function(aTab) { if (this.getTreePref('autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut')) return; diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index f3e05f4e..10a75328 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -136,6 +136,7 @@ TreeStyleTabBrowser.prototype = { this.internallyTabMovingCount = 0; this.subTreeMovingCount = 0; this.subTreeChildrenMovingCount = 0; + this._treeViewEnabled = true; let (splitter, toggler) { splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER); @@ -581,6 +582,7 @@ TreeStyleTabBrowser.prototype = { this.ObserverService.addObserver(this, 'TreeStyleTab:indentModified', false); this.ObserverService.addObserver(this, 'TreeStyleTab:collapseExpandAllSubtree', false); + this.ObserverService.addObserver(this, 'TreeStyleTab:changeTreeViewAvailability', false); this.addPrefListener(this); this.autoHide; @@ -1077,6 +1079,7 @@ TreeStyleTabBrowser.prototype = { this.ObserverService.removeObserver(this, 'TreeStyleTab:indentModified'); this.ObserverService.removeObserver(this, 'TreeStyleTab:collapseExpandAllSubtree'); + this.ObserverService.removeObserver(this, 'TreeStyleTab:changeTreeViewAvailability'); this.removePrefListener(this); delete this.mTabBrowser; @@ -1113,6 +1116,10 @@ TreeStyleTabBrowser.prototype = { } break; + case 'TreeStyleTab:changeTreeViewAvailability': + this.treeViewEnabled = (aData != 'false'); + break; + case 'nsPref:changed': this.onPrefChange(aData); break; @@ -2865,6 +2872,29 @@ TreeStyleTabBrowser.prototype = { this.resetTab(aTab, aPartChildren); }, this); }, + + get treeViewEnabled() /* PUBLIC API */ + { + return this._treeViewEnabled; + }, + set treeViewEnabled(aValue) + { + this._treeViewEnabled = aValue ? true : false ; + if (this._treeViewEnabled) { + let orient = this.isVertical ? 'vertical' : 'horizontal' ; + if (this.getTreePref('allowSubtreeCollapseExpand.'+orient)) + this.browser.setAttribute(this.kALLOW_COLLAPSE, true); + this.updateTabsIndent(this.rootTabs, undefined, undefined, true); + } + else { + this.browser.removeAttribute(this.kALLOW_COLLAPSE); + this.getTabsArray(this.browser).forEach(function(aTab) { + this.updateTabIndent(aTab, this.indentProp, 0, true); + }, this); + } + return aValue; + }, +// _treeViewEnabled : true, /* attach/part */ @@ -3043,7 +3073,7 @@ TreeStyleTabBrowser.prototype = { updateTabsIndent : function(aTabs, aLevel, aProp, aJustNow) { - if (!aTabs || !aTabs.length) return; + if (!aTabs || !aTabs.length || !this._treeViewEnabled) return; if (aLevel === void(0)) { var parentTab = this.getParentTab(aTabs[0]); @@ -3063,35 +3093,9 @@ TreeStyleTabBrowser.prototype = { var margin = this.indent < 0 ? this.baseIndent : this.indent ; var indent = margin * aLevel; - var multirow = this.isMultiRow(); - var topBottom = this.indentProp.match(/top|bottom/); - var maxIndent = parseInt(aTabs[0].boxObject.height / 2); - Array.slice(aTabs).forEach(function(aTab) { if (!aTab.parentNode) return; // ignore removed tabs - if (multirow) { - indent = Math.min(aLevel * 3, maxIndent); - var colors = '-moz-border-'+topBottom+'-colors:'+(function(aNum) { - var retVal = []; - for (var i = 1; i < aNum; i++) - { - retVal.push('transparent'); - } - retVal.push('ThreeDShadow'); - return retVal.length == 1 ? 'none' : retVal.join(' ') ; - })(indent)+' !important;'; - Array.slice(document.getAnonymousNodes(aTab)).forEach(function(aBox) { - if (aBox.nodeType != Node.ELEMENT_NODE) return; - aBox.setAttribute( - 'style', - aBox.getAttribute('style').replace(/(-moz-)?border-(top|bottom)(-[^:]*)?.*:[^;]+;?/g, '') + - '; border-'+topBottom+': solid transparent '+indent+'px !important;'+colors - ); - }, this); - } - else { - this.updateTabIndent(aTab, aProp, indent, aJustNow); - } + this.updateTabIndent(aTab, aProp, indent, aJustNow); aTab.setAttribute(this.kNEST, aLevel); this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aProp, aJustNow); }, this); @@ -3121,6 +3125,37 @@ TreeStyleTabBrowser.prototype = { { this.stopTabIndentAnimation(aTab); + if (this.isMultiRow()) { + let topBottom = this.indentProp.match(/top|bottom/); + let maxIndent = parseInt(aTabs[0].boxObject.height / 2); + + indent = Math.min(aLevel * 3, maxIndent); + var colors = '-moz-border-'+topBottom+'-colors:'+(function(aNum) { + var retVal = []; + for (var i = 1; i < aNum; i++) + { + retVal.push('transparent'); + } + retVal.push('ThreeDShadow'); + return retVal.length == 1 ? 'none' : retVal.join(' ') ; + })(indent)+' !important;'; + Array.slice(document.getAnonymousNodes(aTab)).forEach(function(aBox) { + if (aBox.nodeType != Node.ELEMENT_NODE) return; + aBox.setAttribute( + 'style', + aBox.getAttribute('style').replace(/(-moz-)?border-(top|bottom)(-[^:]*)?.*:[^;]+;?/g, '') + + '; border-'+topBottom+': solid transparent '+indent+'px !important;'+colors + ); + }, this); + } + + + + + + + + var regexp = this.indentRulesRegExp; if ( !this.animationEnabled ||