From b514106153feb384f5a371075c801077409f3b4e Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 1 Sep 2009 14:39:01 +0000 Subject: [PATCH] =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AE=E5=A4=A7=E9=83=A8?= =?UTF-8?q?=E5=88=86=E3=82=92=E5=85=83=E3=81=AB=E6=88=BB=E3=81=97=E3=81=9F?= 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@5031 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletabbrowser.js | 34 +++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index ec193c95..681959b6 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1687,15 +1687,30 @@ TreeStyleTabBrowser.prototype = { ) return; - this.attachTabFromPosition(tab); + this.attachTabFromPosition(tab, aEvent.detail); this.showTabbarForFeedback(); }, - attachTabFromPosition : function(aTab) + attachTabFromPosition : function(aTab, aOldPosition) { var parent = this.getParentTab(aTab); + if (aOldPosition === void(0)) aOldPosition = aTab._tPos; + + var pos = this.getChildIndex(aTab, parent); + var oldPos = this.getChildIndex(this.getTabs(this.mTabBrowser).snapshotItem(aOldPosition), parent); + var delta; + if (pos == oldPos) { // no move? + return; + } + else if (pos < 0 || oldPos < 0) { + delta = 2; + } + else { + delta = Math.abs(pos - oldPos); + } + var prevTab = this.getPreviousTab(aTab); var nextTab = this.getNextTab(aTab); @@ -1712,19 +1727,20 @@ TreeStyleTabBrowser.prototype = { var newParent; - if (!prevTab) { + if (!prevTab) { // moved to topmost position newParent = null; } - else if (!nextTab) { - newParent = prevParent || parent ; + else if (!nextTab) { // moved to last position + newParent = (delta > 1) ? prevParent : parent ; } - else if (prevParent == nextParent) { + else if (prevParent == nextParent) { // moved into existing tree newParent = prevParent; } - else if (prevLevel > nextLevel) { - newParent = prevParent || parent || nextParent; + else if (prevLevel > nextLevel) { // moved to end of existing tree + var realDelta = Math.abs(aTab._tPos - aOldPosition); + newParent = realDelta < 2 ? prevParent : (parent || nextParent) ; } - else if (prevLevel < nextLevel) { + else if (prevLevel < nextLevel) { // moved to first child position of existing tree newParent = parent || nextParent; }