From 5818882a068a9a58402f1814f929883cee0fa445 Mon Sep 17 00:00:00 2001 From: piro Date: Sat, 20 Oct 2007 03:38:46 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=89=E3=83=A9=E3=83=83=E3=82=B0&=E3=83=89?= =?UTF-8?q?=E3=83=AD=E3=83=83=E3=83=97=E3=81=A7=E3=81=AE=E3=82=BF=E3=83=96?= =?UTF-8?q?=E3=83=84=E3=83=AA=E3=83=BC=E3=81=AE=E7=B7=A8=E9=9B=86=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=20=EF=BC=88=E3=83=89=E3=83=AD=E3=83=83?= =?UTF-8?q?=E3=83=97=E4=BD=8D=E7=BD=AE=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=81=AF?= =?UTF-8?q?=E3=81=BE=E3=81=A0=EF=BC=89?= 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@1239 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 112 +++++++++++++++++---------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index ffe44300..334e1a61 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -342,6 +342,7 @@ var TreeStyleTabService = { /return true;/, <> + ) + ); + + eval('aTabBrowser.onDrop = '+ + aTabBrowser.onDrop.toSource().replace( + /(if \([^\)]+\) \{)/, + '$1'+<> ) ); @@ -751,8 +783,8 @@ var TreeStyleTabService = { var backupChildren = this.getTabValue(tab, this.kCHILDREN); var children = this.getChildTabs(tab); var self = this; - var attachion = this.getPref('extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab'); - var processTab = !attachion ? function(aTab) { + var attach = this.getPref('extensions.treestyletab.attachChildrenToGrandParentOnRemoveTab'); + var processTab = !attach ? function(aTab) { self.partTab(aTab, true); self.moveTabSubTreeTo(aTab, b.mTabContainer.lastChild._tPos); } : @@ -767,7 +799,7 @@ var TreeStyleTabService = { processTab(children[i]); } this.updateTabsIndent(children); - if (attachion) { + if (attach) { nextFocusedTab = firstChild; } this.setTabValue(tab, this.kCHILDREN, backupChildren); @@ -1101,38 +1133,34 @@ var TreeStyleTabService = { var tabs = b.mTabContainer.childNodes; var isInverted = this.isTabVertical(b) ? false : window.getComputedStyle(b.parentNode, null).direction == 'ltr'; var info = { - tab : null, - target : null, - position : null, - index : null, - action : null + target : null, + position : null, + action : null, + parent : null, + insertBefore : null }; if (tab.localName != 'tab') { if (aEvent[this.positionProp] < tabs[0].boxObject[this.positionProp]) { - info.tab = info.target = tabs[0]; + info.target = info.parent = info.insertBefore = tabs[0]; info.position = isInverted ? this.kDROP_AFTER : this.kDROP_BEFORE ; - info.index = 0; info.action = this.kACTION_MOVE | this.kACTION_PART; return info; } else if (aEvent[this.positionProp] > tabs[tabs.length-1].boxObject[this.positionProp] + tabs[tabs.length-1].boxObject[this.sizeProp]) { - info.tab = info.target = tabs[tabs.length-1]; + info.target = info.parent = tabs[tabs.length-1]; info.position = isInverted ? this.kDROP_BEFORE : this.kDROP_AFTER ; - info.index = tabs.length-1; info.action = this.kACTION_MOVE | this.kACTION_PART; return info; } else { - info.tab = tabs[b.getNewIndex(aEvent)]; + info.target = tabs[Math.min(b.getNewIndex(aEvent), tabs.length - 1)]; } } else { - info.tab = tab; + info.target = tab; } - info.target = tab; - var boxPos = tab.boxObject[this.positionProp]; var boxUnit = Math.round(tab.boxObject[this.sizeProp] / 3); if (aEvent[this.positionProp] < boxPos + boxUnit) { @@ -1148,8 +1176,9 @@ var TreeStyleTabService = { switch (info.position) { case this.kDROP_ON: - info.index = tab._tPos; - info.action = this.kACTION_ATTACH; + info.action = this.kACTION_ATTACH; + info.parent = tab; + info.insertBefore = this.getNextVisibleTab(tab); break; case this.kDROP_BEFORE: @@ -1167,17 +1196,19 @@ var TreeStyleTabService = { */ var prevTab = this.getPreviousVisibleTab(tab); if (!prevTab) { - info.index = 0; - info.action = this.kACTION_MOVE | this.kACTION_PART; + info.action = this.kACTION_MOVE | this.kACTION_PART; + info.insertBefore = tabs[0]; } else { var prevNest = Number(prevTab.getAttribute(this.kNEST)); var targetNest = Number(tab.getAttribute(this.kNEST)); - info.index = tab._tPos; - info.action = this.kACTION_MOVE | this.kACTION_ATTACH; - info.target = (prevNest < targetNest) ? this.getParentTab(prevTab) : + info.action = this.kACTION_MOVE | this.kACTION_ATTACH; + info.parent = ( + (prevNest < targetNest) ? this.getParentTab(prevTab) : (prevNest > targetNest) ? prevTab : - this.getParentTab(tab); + this.getParentTab(tab) + ) || tab ; + info.insertBefore = tab; } break; @@ -1196,16 +1227,17 @@ var TreeStyleTabService = { */ var nextTab = this.getNextVisibleTab(tab); if (!nextTab) { - info.index = tabs.length-1; info.action = this.kACTION_MOVE | this.kACTION_PART; } else { var targetNest = Number(tab.getAttribute(this.kNEST)); var nextNest = Number(nextTab.getAttribute(this.kNEST)); - info.index = tab._tPos + 1; - info.action = this.kACTION_MOVE | this.kACTION_ATTACH; - info.target = (targetNest < nextNest) ? tab : - this.getParentTab(tab); + info.action = this.kACTION_MOVE | this.kACTION_ATTACH; + info.parent = ( + (targetNest < nextNest) ? tab : + this.getParentTab(tab) + ) || tab ; + info.insertBefore = nextTab; } break; } @@ -1219,7 +1251,7 @@ var TreeStyleTabService = { attachTabTo : function(aChild, aParent, aInfo) { - if (!aChild || !aParent) return; + if (!aChild || !aParent || this.getParentTab(aChild) == aParent) return; if (!aInfo) aInfo = {}; var id = aChild.getAttribute(this.kID);