* 現在のタブを閉じた後に、期待されている物と異なるタブがフォーカスされてしまうことがあった問題を修正

* partTabの引数の仕様を変更


git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4833 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-07-30 09:56:28 +00:00
parent 33d22b9212
commit 7004aa51f9

View File

@ -1380,7 +1380,7 @@ TreeStyleTabBrowser.prototype = {
parent = (positionInTree > -1 && positionInTree < tabs.length) ? tabs[positionInTree] : parent ; parent = (positionInTree > -1 && positionInTree < tabs.length) ? tabs[positionInTree] : parent ;
} }
if (parent) { if (parent) {
this.attachTabTo(tab, parent); this.attachTabTo(tab, parent, { dontMove : true });
} }
let refTab; let refTab;
@ -1480,7 +1480,9 @@ TreeStyleTabBrowser.prototype = {
(closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_DETACH) ? (closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_DETACH) ?
function(aTab) { function(aTab) {
indentModifiedTabs.push(aTab); indentModifiedTabs.push(aTab);
this.partTab(aTab, true); this.partTab(aTab, {
dontUpdateIndent : true
});
this.moveTabSubTreeTo(aTab, this.getLastTab(b)._tPos); this.moveTabSubTreeTo(aTab, this.getLastTab(b)._tPos);
} : } :
(parentTab ? (parentTab ?
@ -1491,22 +1493,23 @@ TreeStyleTabBrowser.prototype = {
closeRootBehavior == this.CLOSE_ROOT_BEHAVIOR_ESCALATE_FIRST closeRootBehavior == this.CLOSE_ROOT_BEHAVIOR_ESCALATE_FIRST
) ? ) ?
function(aTab, aIndex) { function(aTab, aIndex) {
this.partTab(aTab, true); this.partTab(aTab, { dontUpdateIndent : true });
if (aIndex == 0) { if (aIndex == 0) {
nextFocusedTab = aTab; nextFocusedTab = aTab;
indentModifiedTabs.push(aTab); indentModifiedTabs.push(aTab);
if (parentTab) { if (parentTab) {
this.attachTabTo(aTab, parentTab, { this.attachTabTo(aTab, parentTab, {
insertBefore : tab,
dontUpdateIndent : true, dontUpdateIndent : true,
dontExpand : true dontExpand : true,
dontMove : true
}); });
} }
} }
else { else {
this.attachTabTo(aTab, children[0], { this.attachTabTo(aTab, children[0], {
dontUpdateIndent : true, dontUpdateIndent : true,
dontExpand : true dontExpand : true,
dontMove : true
}); });
} }
} : } :
@ -1514,14 +1517,14 @@ TreeStyleTabBrowser.prototype = {
function(aTab) { function(aTab) {
indentModifiedTabs.push(aTab); indentModifiedTabs.push(aTab);
this.attachTabTo(aTab, parentTab, { this.attachTabTo(aTab, parentTab, {
insertBefore : tab,
dontUpdateIndent : true, dontUpdateIndent : true,
dontExpand : true dontExpand : true,
dontMove : true
}); });
} : } :
function(aTab) { function(aTab) {
indentModifiedTabs.push(aTab); indentModifiedTabs.push(aTab);
this.partTab(aTab, true); this.partTab(aTab, { dontUpdateIndent : true });
} }
), this); ), this);
if (closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_ESCALATE_ALL || if (closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_ESCALATE_ALL ||
@ -1558,7 +1561,7 @@ TreeStyleTabBrowser.prototype = {
if (shouldCloseParentTab && nextFocusedTab == parentTab) if (shouldCloseParentTab && nextFocusedTab == parentTab)
nextFocusedTab = this.getNextFocusedTab(parentTab); nextFocusedTab = this.getNextFocusedTab(parentTab);
this.partTab(tab, true); this.partTab(tab, { dontUpdateIndent : true });
if (shouldCloseParentTab) { if (shouldCloseParentTab) {
window.setTimeout(function() { window.setTimeout(function() {
@ -1703,7 +1706,7 @@ TreeStyleTabBrowser.prototype = {
if (newParent != parent) { if (newParent != parent) {
if (newParent) if (newParent)
this.attachTabTo(aTab, newParent, { insertBefore : nextTab }); this.attachTabTo(aTab, newParent, { dontMove : true });
else else
this.partTab(aTab); this.partTab(aTab);
} }
@ -1802,8 +1805,8 @@ TreeStyleTabBrowser.prototype = {
parent = this.getTabById(parent); parent = this.getTabById(parent);
if (parent) { if (parent) {
this.attachTabTo(tab, parent, { this.attachTabTo(tab, parent, {
dontExpand : true, dontExpand : true,
insertBefore : nextTab, insertBefore : nextTab,
dontUpdateIndent : true dontUpdateIndent : true
}); });
this.updateTabsIndent([tab], undefined, undefined, aWithoutAnimation); this.updateTabsIndent([tab], undefined, undefined, aWithoutAnimation);
@ -2807,7 +2810,9 @@ TreeStyleTabBrowser.prototype = {
var id = aChild.getAttribute(this.kID); var id = aChild.getAttribute(this.kID);
this.partTab(aChild, true); this.partTab(aChild, {
dontUpdateIndent : true
});
var children = aParent.getAttribute(this.kCHILDREN) var children = aParent.getAttribute(this.kCHILDREN)
.split('|').filter(function(aId) { .split('|').filter(function(aId) {
@ -2828,8 +2833,8 @@ TreeStyleTabBrowser.prototype = {
} }
else { else {
children.push(id); children.push(id);
var refTab = aParent; let refTab = aParent;
var descendant = this.getDescendantTabs(aParent); let 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;
} }
@ -2840,8 +2845,10 @@ TreeStyleTabBrowser.prototype = {
if (shouldInheritIndent && !aInfo.dontUpdateIndent) if (shouldInheritIndent && !aInfo.dontUpdateIndent)
this.inheritTabIndent(aChild, aParent); this.inheritTabIndent(aChild, aParent);
if (newIndex > aChild._tPos) newIndex--; if (!aInfo.dontMove) {
this.moveTabSubTreeTo(aChild, newIndex); if (newIndex > aChild._tPos) newIndex--;
this.moveTabSubTreeTo(aChild, newIndex);
}
if (!aInfo.dontExpand) { if (!aInfo.dontExpand) {
if (this.getTreePref('autoCollapseExpandSubTreeOnSelect')) { if (this.getTreePref('autoCollapseExpandSubTreeOnSelect')) {
@ -2884,9 +2891,10 @@ TreeStyleTabBrowser.prototype = {
aChild.dispatchEvent(event); aChild.dispatchEvent(event);
}, },
partTab : function(aChild, aDontUpdateIndent) /* PUBLIC API */ partTab : function(aChild, aInfo) /* PUBLIC API */
{ {
if (!aChild) return; if (!aChild) return;
if (!aInfo) aInfo = {};
var parentTab = this.getParentTab(aChild); var parentTab = this.getParentTab(aChild);
if (!parentTab) return; if (!parentTab) return;
@ -2904,7 +2912,7 @@ TreeStyleTabBrowser.prototype = {
this.deleteTabValue(aChild, this.kPARENT); this.deleteTabValue(aChild, this.kPARENT);
this.updateTabsCount(parentTab); this.updateTabsCount(parentTab);
if (!aDontUpdateIndent) { if (!aInfo.dontUpdateIndent) {
this.updateTabsIndent([aChild]); this.updateTabsIndent([aChild]);
this.checkTabsIndentOverflow(); this.checkTabsIndentOverflow();
} }
@ -2922,9 +2930,9 @@ TreeStyleTabBrowser.prototype = {
}, 0, this.getTabBrowserFromChild(parentTab)); }, 0, this.getTabBrowserFromChild(parentTab));
} }
}, },
detachTab : function(aChild, aDontUpdateIndent) // alias detachTab : function(aChild, aInfo) // alias
{ {
return this.partTab(aChild, aDontUpdateIndent); return this.partTab(aChild, aInfo);
}, },
updateTabsIndent : function(aTabs, aLevel, aProp, aJustNow) updateTabsIndent : function(aTabs, aLevel, aProp, aJustNow)