タブを移動した時のツリーの自動編集処理を修正
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1633 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
61f22fa749
commit
242c3ccd47
@ -1081,40 +1081,39 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
{
|
{
|
||||||
var parent = this.getParentTab(aTab);
|
var parent = this.getParentTab(aTab);
|
||||||
|
|
||||||
var prevTab = aTab.previousSibling;
|
|
||||||
var nextTab = aTab.nextSibling;
|
|
||||||
|
|
||||||
var prevParent = this.getParentTab(prevTab);
|
|
||||||
var prevLevel = aTab.previousSibling ? Number(prevTab.getAttribute(this.kNEST)) : -1 ;
|
|
||||||
|
|
||||||
var nextParent = this.getParentTab(nextTab);
|
|
||||||
var nextLevel = aTab.hasAttribute(this.kCHILDREN) ? (
|
|
||||||
this.getNextSiblingTab(aTab) ? Number(this.getNextSiblingTab(aTab).getAttribute(this.kNEST)) : 0
|
|
||||||
) :
|
|
||||||
nextTab ? Number(nextTab.getAttribute(this.kNEST)) : -1 ;
|
|
||||||
|
|
||||||
if (aOldPosition === void(0)) aOldPosition = aTab._tPos;
|
if (aOldPosition === void(0)) aOldPosition = aTab._tPos;
|
||||||
|
|
||||||
var pos = this.getChildIndex(aTab, parent);
|
var pos = this.getChildIndex(aTab, parent);
|
||||||
if (aTab._tPos < aOldPosition) aOldPosition--;
|
|
||||||
var oldPos = this.getChildIndex(this.mTabBrowser.mTabContainer.childNodes[aOldPosition], parent);
|
var oldPos = this.getChildIndex(this.mTabBrowser.mTabContainer.childNodes[aOldPosition], parent);
|
||||||
var delta;
|
var delta;
|
||||||
if (
|
if (pos == oldPos) { // no move?
|
||||||
// (parent && (
|
return;
|
||||||
// parent != prevParent ||
|
}
|
||||||
// parent != nextParent
|
else if (pos < 0 || oldPos < 0) {
|
||||||
// )) ||
|
|
||||||
pos < 0 || oldPos < 0
|
|
||||||
) {
|
|
||||||
delta = 2;
|
delta = 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
delta = Math.abs(pos - oldPos);
|
delta = Math.abs(pos - oldPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
var newParent = null;
|
var prevTab = aTab.previousSibling;
|
||||||
|
var nextTab = aTab.nextSibling;
|
||||||
|
|
||||||
|
var tabs = this.getDescendantTabs(aTab);
|
||||||
|
if (tabs.length) {
|
||||||
|
nextTab = tabs[tabs.length-1].nextSibling;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prevParent = this.getParentTab(prevTab);
|
||||||
|
var nextParent = this.getParentTab(nextTab);
|
||||||
|
|
||||||
|
var prevLevel = prevTab ? Number(prevTab.getAttribute(this.kNEST)) : -1 ;
|
||||||
|
var nextLevel = nextTab ? Number(nextTab.getAttribute(this.kNEST)) : -1 ;
|
||||||
|
|
||||||
|
var newParent;
|
||||||
|
|
||||||
if (!prevTab) {
|
if (!prevTab) {
|
||||||
|
newParent = null;
|
||||||
}
|
}
|
||||||
else if (!nextTab) {
|
else if (!nextTab) {
|
||||||
newParent = (delta > 1) ? prevParent : parent ;
|
newParent = (delta > 1) ? prevParent : parent ;
|
||||||
@ -1123,7 +1122,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
newParent = prevParent;
|
newParent = prevParent;
|
||||||
}
|
}
|
||||||
else if (prevLevel > nextLevel) {
|
else if (prevLevel > nextLevel) {
|
||||||
newParent = (delta > 1) ? prevParent : this.getParentTab(prevParent) ;
|
var realDelta = Math.abs(aTab._tPos - aOldPosition);
|
||||||
|
newParent = realDelta < 2 ? prevParent : parent ;
|
||||||
}
|
}
|
||||||
else if (prevLevel < nextLevel) {
|
else if (prevLevel < nextLevel) {
|
||||||
newParent = aTab.previousSibling;
|
newParent = aTab.previousSibling;
|
||||||
@ -1131,7 +1131,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
if (newParent != parent) {
|
if (newParent != parent) {
|
||||||
if (newParent)
|
if (newParent)
|
||||||
this.attachTabTo(aTab, newParent, { insertBefore : aTab.nextSibling });
|
this.attachTabTo(aTab, newParent, { insertBefore : nextTab });
|
||||||
else
|
else
|
||||||
this.partTab(aTab);
|
this.partTab(aTab);
|
||||||
}
|
}
|
||||||
@ -1234,10 +1234,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (!parent && (before = this.getTabById(before))) {
|
if (!parent && (before = this.getTabById(before))) {
|
||||||
var index = before._tPos;
|
var index = before._tPos;
|
||||||
if (index > tab._tPos) index--;
|
if (index > tab._tPos) index--;
|
||||||
// this.internallyTabMoving = true;
|
|
||||||
b.moveTabTo(tab, index);
|
b.moveTabTo(tab, index);
|
||||||
// this.internallyTabMoving = false;
|
|
||||||
// this.attachTabFromPosition(tab);
|
|
||||||
}
|
}
|
||||||
this.deleteTabValue(tab, this.kINSERT_BEFORE);
|
this.deleteTabValue(tab, this.kINSERT_BEFORE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user