refactor codes to get selected tabs

This commit is contained in:
Piro / SHIMODA Hiroshi 2010-12-02 08:31:11 +09:00
parent 834050f820
commit d35d743e8e
2 changed files with 39 additions and 17 deletions

View File

@ -13,7 +13,7 @@
http://github.com/piroor/fxaddonlibs/blob/master/tabsDragUtils.js
*/
(function() {
const currentRevision = 2;
const currentRevision = 3;
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
@ -166,6 +166,42 @@
return true;
},
getSelectedTabs : function TDU_getSelectedTabs(aEvent)
{
var b = this.getTabBrowserFromChild(aEvent.target);
var w = b.ownerDocument.defaultView;
var isMultipleDragEvent = this.isTabsDragging(aEvent);
var selectedTabs;
var isMultipleDrag = (
(
isMultipleDragEvent &&
(selectedTabs = this.getDraggedTabs(aEvent)) &&
selectedTabs.length
) ||
( // Firefox 4.x (https://bugzilla.mozilla.org/show_bug.cgi?id=566510)
'visibleTabs' in b &&
(selectedTabs = b.visibleTabs.filter(function(aTab) {
return aTab.multiselected;
})) &&
selectedTabs.length
) ||
( // Tab Utilities
'selectedTabs' in b &&
(selectedTabs = b.selectedTabs) &&
selectedTabs.length
) ||
( // Multiple Tab Handler
'MultipleTabService' in w &&
w.MultipleTabService.isSelected(aTab) &&
MultipleTabService.allowMoveMultipleTabs &&
(selectedTabs = w.MultipleTabService.getSelectedTabs(b)) &&
selectedTabs.length
)
);
return isMultipleDrag ? selectedTabs : [] ;
},
getDraggedTabs : function TDU_getDraggedTabs(aEvent)
{
var dt = aEvent.dataTransfer;

View File

@ -3676,22 +3676,8 @@ TreeStyleTabBrowser.prototype = {
var sourceWindow = aTab.ownerDocument.defaultView;
var sourceBrowser = this.getTabBrowserFromChild(aTab);
var dt = aInfo.event && aInfo.event.dataTransfer;
var isMultipleDragEvent = window['piro.sakura.ne.jp'].tabsDragUtils.isTabsDragging(aInfo.event);
var isMultipleMove = (
isMultipleDragEvent ||
(
'MultipleTabService' in sourceWindow &&
sourceWindow.MultipleTabService.isSelected(aTab) &&
MultipleTabService.allowMoveMultipleTabs
)
);
if (isMultipleMove) {
draggedTabs = isMultipleDragEvent ?
window['piro.sakura.ne.jp'].tabsDragUtils.getDraggedTabs(aInfo.event) :
sourceWindow.MultipleTabService.getSelectedTabs(sourceBrowser);
var draggedTabs = window['piro.sakura.ne.jp'].tabsDragUtils.getSelectedTabs(aInfo.event);
if (draggedTabs.length > 1) {
if (!(aInfo.action & this.kACTIONS_FOR_DESTINATION)) {
draggedRoots = [];
draggedTabs.forEach(function(aTab) {