TreeStyleTabService.treeViewEnabled = true/false でツリー表示のON・OFFを即座に切り替えられるようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5558 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
c6a913b03c
commit
2654bb16ac
@ -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;
|
||||
|
@ -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 ||
|
||||
|
Loading…
Reference in New Issue
Block a user