From 5af75957f9ebc3a1783026e10b35936497a5edae Mon Sep 17 00:00:00 2001 From: piro Date: Sat, 20 Oct 2007 13:35:04 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=89=E3=83=AD=E3=83=83=E3=83=97=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E3=81=8C=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F=E3=81=AA?= =?UTF-8?q?=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= 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@1249 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 36 ++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 4490ba35..ca0de413 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -451,15 +451,31 @@ catch(e) { var tabs = aSelf.mTabContainer.childNodes; if (info.action & TreeStyleTabService.kACTION_PART) { TreeStyleTabService.partTab(tab); - if (info.action & TreeStyleTabService.kACTION_MOVE) { - aSelf.moveTabTo(tab, (info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 )); + if ( + info.action & TreeStyleTabService.kACTION_MOVE && + ( + !info.insertBefore || + TreeStyleTabService.getNextVisibleTab(tab) != info.insertBefore + ) + ) { + var newIndex = info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 ; + if (info.insertBefore && newIndex > tab._tPos) newIndex--; + aSelf.moveTabTo(tab, newIndex); } return true; } else if (info.action & TreeStyleTabService.kACTION_ATTACH) { TreeStyleTabService.attachTabTo(tab, info.parent); - if (info.action & TreeStyleTabService.kACTION_MOVE) { - aSelf.moveTabTo(tab, info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 ); + if ( + info.action & TreeStyleTabService.kACTION_MOVE && + ( + !info.insertBefore || + TreeStyleTabService.getNextVisibleTab(tab) != info.insertBefore + ) + ) { + var newIndex = info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 ; + if (info.insertBefore && newIndex > tab._tPos) newIndex--; + aSelf.moveTabTo(tab, newIndex); } return true; } @@ -1286,13 +1302,13 @@ catch(e) { [TARGET ] part from parent, and move [ ] - [TARGET ] attach to the parent of the previous visible, and move + [TARGET ] attach to the parent of the target, and move [ ] [TARGET ] attach to the parent of the target, and move [ ] - [TARGET] attach to the parent of the targetm and move + [TARGET] attach to the parent of the target (previous tab), and move */ var prevTab = this.getPreviousVisibleTab(tab); if (!prevTab) { @@ -1304,7 +1320,6 @@ catch(e) { var targetNest = Number(tab.getAttribute(this.kNEST)); info.action = this.kACTION_MOVE | this.kACTION_ATTACH; info.parent = ( - (prevNest > targetNest) ? this.getParentTab(prevTab) : (prevNest < targetNest) ? prevTab : this.getParentTab(tab) ) || tab ; @@ -1314,7 +1329,7 @@ catch(e) { case this.kDROP_AFTER: /* - [TARGET ] part from parent, and move + [TARGET ] if the target has a parent, attach to it and and move [TARGET] attach to the parent of the target, and move [ ] @@ -1327,14 +1342,14 @@ catch(e) { */ var nextTab = this.getNextVisibleTab(tab); if (!nextTab) { - info.action = this.kACTION_MOVE | this.kACTION_PART; + info.action = this.kACTION_MOVE | this.kACTION_ATTACH; + info.parent = this.getParentTab(tab); } else { var targetNest = Number(tab.getAttribute(this.kNEST)); var nextNest = Number(nextTab.getAttribute(this.kNEST)); info.action = this.kACTION_MOVE | this.kACTION_ATTACH; info.parent = ( - (targetNest > nextNest) ? this.getParentTab(nextTab) : (targetNest < nextNest) ? tab : this.getParentTab(tab) ) || tab ; @@ -1547,6 +1562,7 @@ catch(e) { if (!aDontUpdateIndent) { this.updateTabsIndent([aChild]); + var b = this.getTabBrowserFromChildren(aChild); this.checkTabsIndentOverflow(b); } },