子タブの管理を配列として行うようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4146 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-04-20 12:03:38 +00:00
parent b9ced78e3d
commit 77b831e6f2

View File

@ -2633,32 +2633,32 @@ TreeStyleTabBrowser.prototype = {
this.partTab(aChild, true); this.partTab(aChild, true);
var children = aParent.getAttribute(this.kCHILDREN); var children = aParent.getAttribute(this.kCHILDREN)
.split('|').filter(function(aId) {
return this.getTabById(aId);
}, this);
var newIndex; var newIndex;
if (children.indexOf(id) > -1) { var oldIndex = children.indexOf(id);
children = ('|'+children).replace('|'+id, '').replace(/^\|/); if (oldIndex > -1) children = children.splice(oldIndex, 1);
}
var insertBefore = aInfo.insertBefore; var insertBefore = aInfo.insertBefore;
var beforeTab = insertBefore ? insertBefore.getAttribute(this.kID) : null ; var beforeTab = insertBefore ? insertBefore.getAttribute(this.kID) : null ;
if (beforeTab && children.indexOf(beforeTab) > -1) { var beforeIndex;
children = children.replace(beforeTab, id+'|'+beforeTab); if (beforeTab && (beforeIndex = children.indexOf(beforeTab)) > -1) {
children.splice(beforeIndex, 0, id);
newIndex = insertBefore._tPos; newIndex = insertBefore._tPos;
} }
else { else {
children = ((children || '')+'|'+id).replace(/^\|/, ''); children.push(id);
var refTab = aParent; var refTab = aParent;
var descendant = this.getDescendantTabs(aParent); var descendant = this.getDescendantTabs(aParent);
if (descendant.length) refTab = descendant[descendant.length-1]; if (descendant.length) refTab = descendant[descendant.length-1];
newIndex = refTab._tPos+1; newIndex = refTab._tPos+1;
} }
children = children.split('|').filter(function(aId) { this.setTabValue(aParent, this.kCHILDREN, children.join('|'));
return this.getTabById(aId);
}, this)
this.setTabValue(aParent, this.kCHILDREN, children);
this.setTabValue(aChild, this.kPARENT, aParent.getAttribute(this.kID)); this.setTabValue(aChild, this.kPARENT, aParent.getAttribute(this.kID));
this.updateTabsCount(aParent); this.updateTabsCount(aParent);
if (shouldInheritIndent) this.inheritTabIndent(aChild, aParent); if (shouldInheritIndent) this.inheritTabIndent(aChild, aParent);
@ -2667,15 +2667,7 @@ TreeStyleTabBrowser.prototype = {
this.moveTabSubTreeTo(aChild, newIndex); this.moveTabSubTreeTo(aChild, newIndex);
if (!aInfo.dontExpand) { if (!aInfo.dontExpand) {
if ( if (this.getTreePref('autoCollapseExpandSubTreeOnSelect')) {
/*
(
aParent.getAttribute(this.kSUBTREE_COLLAPSED) == 'true' ||
children.indexOf('|') > -1 // not a first child
) &&
*/
this.getTreePref('autoCollapseExpandSubTreeOnSelect')
) {
this.collapseExpandTreesIntelligentlyFor(aParent); this.collapseExpandTreesIntelligentlyFor(aParent);
var p = aParent; var p = aParent;
do { do {
@ -2725,10 +2717,15 @@ TreeStyleTabBrowser.prototype = {
if (!parentTab) return; if (!parentTab) return;
var id = aChild.getAttribute(this.kID); var id = aChild.getAttribute(this.kID);
var children = ('|'+parentTab.getAttribute(this.kCHILDREN)) this.setTabValue(
.replace(new RegExp('\\|'+id), '') parentTab,
.replace(/^\|/, ''); this.kCHILDREN,
this.setTabValue(parentTab, this.kCHILDREN, children); parentTab.getAttribute(this.kCHILDREN)
.split('|')
.filter(function(aId) {
return this.getTabById(aId) && aId != id;
}, this).join('|')
);
this.deleteTabValue(aChild, this.kPARENT); this.deleteTabValue(aChild, this.kPARENT);
this.updateTabsCount(parentTab); this.updateTabsCount(parentTab);
@ -2939,8 +2936,8 @@ TreeStyleTabBrowser.prototype = {
this.isSubTreeChildrenMoving = true; this.isSubTreeChildrenMoving = true;
this.internallyTabMoving = true; this.internallyTabMoving = true;
this.getDescendantTabs(aTab).forEach(function(aTab) { this.getDescendantTabs(aTab).forEach(function(aTab, aIndex) {
b.moveTabTo(aTab, aTab._tPos+i+(aTab._tPos < aTab._tPos ? 1 : 0 )); b.moveTabTo(aTab, aTab._tPos + aIndex + (aTab._tPos < aTab._tPos ? 1 : 0 ));
}, this); }, this);
this.internallyTabMoving = false; this.internallyTabMoving = false;
this.isSubTreeChildrenMoving = false; this.isSubTreeChildrenMoving = false;