From e304eec5215a8b44cb87ad2da912b5f2ce621862 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 22 Feb 2008 23:31:22 +0000 Subject: [PATCH] =?UTF-8?q?=E8=A4=87=E6=95=B0=E3=82=BF=E3=83=96=E3=82=92?= =?UTF-8?q?=E3=81=BE=E3=81=A8=E3=82=81=E3=81=A6=E3=83=89=E3=83=A9=E3=83=83?= =?UTF-8?q?=E3=82=B0=E3=81=AB=E5=AF=BE=E5=BF=9C?= 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@1844 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 4 +- content/treestyletab/treestyletabbrowser.js | 113 +++++++++++++++----- 2 files changed, 87 insertions(+), 30 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index acf1c284..92fea2b6 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -41,6 +41,7 @@ var TreeStyleTabService = { kACTION_MOVE : 1, kACTION_ATTACH : 2, kACTION_PART : 4, + kACTION_DUPLICATE : 8, kTABBAR_TOP : 1, kTABBAR_BOTTOM : 2, @@ -875,8 +876,7 @@ catch(e) { ).replace( // Firefox 3 'if (accelKeyPressed) {', <> ).replace( // Firefox 3, duplication of tab diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index ae72a9e0..e3950af4 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1636,21 +1636,26 @@ TreeStyleTabBrowser.prototype = { { var info = this.getDropActionInternal(aEvent); info.canDrop = true; - if (info.action & this.kACTION_ATTACH && - aDragSession && + if (aDragSession && aDragSession.sourceNode && aDragSession.sourceNode.localName == 'tab') { - var orig = aDragSession.sourceNode; - if (orig == info.parent) { - info.canDrop = false; - } - else { - var tab = info.target; - while (tab = this.getParentTab(tab)) - { - if (tab != orig) continue; + if ('duplicateTab' in this.mTabBrowser && + navigator.platform.toLowerCase().indexOf('mac') == 0 ? aEvent.metaKey : aEvent.ctrlKey ) + info.action = info.action | this.kACTION_DUPLICATE; + + if (info.action & this.kACTION_ATTACH) { + var orig = aDragSession.sourceNode; + if (orig == info.parent) { info.canDrop = false; - break; + } + else { + var tab = info.target; + while (tab = this.getParentTab(tab)) + { + if (tab != orig) continue; + info.canDrop = false; + break; + } } } } @@ -1770,20 +1775,61 @@ TreeStyleTabBrowser.prototype = { return info; }, - processDropAction : function(aInfo, aTarget) + processDropAction : function(aInfo, aDraggedTab) { var b = this.mTabBrowser; var tabs = b.mTabContainer.childNodes; - if (aTarget && aInfo.action & this.kACTION_PART) { - this.partTab(aTarget); - this.collapseExpandTab(aTarget, false); + var self = this; + + var draggedTabs = [aDraggedTab]; + + if ('MultipleTabService' in window && + MultipleTabService.isSelected(aDraggedTab) && + MultipleTabService.allowMoveMultipleTabs) { + draggedTabs = MultipleTabService.getSelectedTabs(b); + var baseParent; + var roots = []; + var keepStructure = true; + draggedTabs.forEach(function(aTab) { + var parent = aTab, + current; + do { + current = parent; + parent = self.getParentTab(parent) + if (parent && MultipleTabService.isSelected(parent)) continue; + roots.push(current); + if (baseParent === void(0)) { + baseParent = parent; + } + else if (parent != baseParent) { + keepStructure = false; + } + return; + } + while (parent); + }); + if (keepStructure) + draggedTabs = roots; + } + + if (aDraggedTab && aInfo.action & this.kACTION_PART) { + b.movingSelectedTabs = true; + draggedTabs.forEach(function(aTab) { + self.partTab(aTab); + self.collapseExpandTab(aTab, false); + }); + b.movingSelectedTabs = false; } else if (aInfo.action & this.kACTION_ATTACH) { - if (aInfo.parent) - this.attachTabTo(aTarget, aInfo.parent); - else - this.partTab(aTarget); - this.collapseExpandTab(aTarget, false); + b.movingSelectedTabs = true; + draggedTabs.forEach(function(aTab) { + if (aInfo.parent) + self.attachTabTo(aTab, aInfo.parent); + else + self.partTab(aTab); + self.collapseExpandTab(aTab, false); + }); + b.movingSelectedTabs = false; } else { return false; @@ -1793,15 +1839,26 @@ TreeStyleTabBrowser.prototype = { aInfo.action & this.kACTION_MOVE && ( !aInfo.insertBefore || - this.getNextVisibleTab(aTarget) != aInfo.insertBefore + this.getNextVisibleTab(draggedTabs[0]) != aInfo.insertBefore ) ) { - var newIndex = aInfo.insertBefore ? aInfo.insertBefore._tPos : tabs.length - 1 ; - if (aInfo.insertBefore && newIndex > aTarget._tPos) newIndex--; - this.internallyTabMoving = true; - b.moveTabTo(aTarget, newIndex); - this.collapseExpandTab(aTarget, false); - this.internallyTabMoving = false; + b.movingSelectedTabs = true; + var tab, newIndex; + for (var i = draggedTabs.length-1; i > -1; i--) + { + tab = draggedTabs[i]; + if (aInfo.action & this.kACTION_DUPLICATE) + tab = b.duplicateTab(tab); + + newIndex = aInfo.insertBefore ? aInfo.insertBefore._tPos : tabs.length - 1 ; + if (aInfo.insertBefore && newIndex > tab._tPos) newIndex--; + + this.internallyTabMoving = true; + b.moveTabTo(tab, newIndex); + this.collapseExpandTab(tab, false); + this.internallyTabMoving = false; + } + b.movingSelectedTabs = false; } return true; },