隠し設定で、ドラッグ&ドロップの時にツリーを開く動作を変えられるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1605 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-11-17 17:52:51 +00:00
parent d0ccbba1ec
commit 24bc6f157a
2 changed files with 56 additions and 12 deletions

View File

@ -91,6 +91,7 @@ TreeStyleTabBrowser.prototype = {
b.mStrip.addEventListener('dragenter', this, false); b.mStrip.addEventListener('dragenter', this, false);
b.mStrip.addEventListener('dragexit', this, false); b.mStrip.addEventListener('dragexit', this, false);
b.mStrip.addEventListener('dragover', this, false); b.mStrip.addEventListener('dragover', this, false);
b.mStrip.addEventListener('dragdrop', this, false);
b.mTabContainer.addEventListener('click', this, true); b.mTabContainer.addEventListener('click', this, true);
b.mTabContainer.addEventListener('dblclick', this, true); b.mTabContainer.addEventListener('dblclick', this, true);
b.mTabContainer.addEventListener('mousedown', this, true); b.mTabContainer.addEventListener('mousedown', this, true);
@ -621,9 +622,10 @@ TreeStyleTabBrowser.prototype = {
b.removeEventListener('TabClose', this, true); b.removeEventListener('TabClose', this, true);
b.removeEventListener('TabMove', this, true); b.removeEventListener('TabMove', this, true);
b.removeEventListener('SSTabRestoring', this, true); b.removeEventListener('SSTabRestoring', this, true);
b.removeEventListener.addEventListener('dragenter', this, false); b.mStrip.removeEventListener('dragenter', this, false);
b.removeEventListener.addEventListener('dragexit', this, false); b.mStrip.removeEventListener('dragexit', this, false);
b.removeEventListener.addEventListener('dragover', this, false); b.mStrip.removeEventListener('dragover', this, false);
b.mStrip.removeEventListener('dragdrop', this, false);
b.mTabContainer.removeEventListener('click', this, true); b.mTabContainer.removeEventListener('click', this, true);
b.mTabContainer.removeEventListener('dblclick', this, true); b.mTabContainer.removeEventListener('dblclick', this, true);
b.mTabContainer.removeEventListener('mousedown', this, true); b.mTabContainer.removeEventListener('mousedown', this, true);
@ -900,6 +902,10 @@ TreeStyleTabBrowser.prototype = {
case 'dragover': case 'dragover':
nsDragAndDrop.dragOver(aEvent, this); nsDragAndDrop.dragOver(aEvent, this);
return; return;
case 'dragdrop':
nsDragAndDrop.drop(aEvent, this);
return;
} }
}, },
@ -1343,7 +1349,7 @@ TreeStyleTabBrowser.prototype = {
autoExpandTimer : null, autoExpandTimer : null,
autoExpandTarget : null, autoExpandTarget : null,
autoExpandDelay : 500, autoExpandedTabs : [],
onDragEnter : function(aEvent, aDragSession) onDragEnter : function(aEvent, aDragSession)
{ {
@ -1356,11 +1362,25 @@ TreeStyleTabBrowser.prototype = {
if (this.isTimerSupported || !aDragSession.sourceNode) { if (this.isTimerSupported || !aDragSession.sourceNode) {
window.clearTimeout(this.autoExpandTimer); window.clearTimeout(this.autoExpandTimer);
if (aEvent.target == aDragSession.sourceNode) return; if (aEvent.target == aDragSession.sourceNode) return;
this.autoExpandTimer = window.setTimeout(function(aSelf, aTarget) { this.autoExpandTimer = window.setTimeout(
function(aSelf, aTarget) {
var tab = aSelf.getTabById(aTarget); var tab = aSelf.getTabById(aTarget);
if (tab && tab.getAttribute(aSelf.kSUBTREE_COLLAPSED) == 'true') if (tab &&
tab.getAttribute(aSelf.kSUBTREE_COLLAPSED) == 'true' &&
tab.getAttribute(aSelf.kDROP_POSITION) == 'self') {
if (aSelf.getTreePref('autoExpand.intelligently') {
aSelf.collapseExpandTreesIntelligentlyFor(tab); aSelf.collapseExpandTreesIntelligentlyFor(tab);
}, this.autoCollapseExpandDelay, this, tab.getAttribute(this.kID)); }
else {
aSelf.autoExpandedTabs.push(aTarget);
aSelf.collapseExpandSubtree(tab, false);
}
}
},
this.getTreePref('autoExpand.delay'),
this,
tab.getAttribute(this.kID)
);
} }
else { else {
this.autoExpandTimer = now; this.autoExpandTimer = now;
@ -1389,16 +1409,37 @@ TreeStyleTabBrowser.prototype = {
if (this.isTimerSupported || !aDragSession.sourceNode) return; if (this.isTimerSupported || !aDragSession.sourceNode) return;
var now = (new Date()).getTime(); var now = (new Date()).getTime();
var delay = this.autoExpandDelay; var delay = this.getTreePref('autoExpand.delay');
if (this.autoExpandTimer && (now - delay > this.autoExpandTimer)) { if (this.autoExpandTimer && (now - delay > this.autoExpandTimer)) {
var tab = this.getTabById(this.autoExpandTarget); var tab = this.getTabById(this.autoExpandTarget);
if (tab && tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') if (tab &&
tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true' &&
tab.getAttribute(this.kDROP_POSITION) == 'self') {
if (this.getTreePref('autoExpand.intelligently') {
this.collapseExpandTreesIntelligentlyFor(tab); this.collapseExpandTreesIntelligentlyFor(tab);
}
else {
this.autoExpandedTabs.push(this.autoExpandTarget);
this.collapseExpandSubtree(tab, false);
}
}
this.autoExpandTimer = null; this.autoExpandTimer = null;
this.autoExpandTarget = null; this.autoExpandTarget = null;
} }
}, },
onDrop : function(aEvent, aXferData, aDragSession)
{
if (!this.autoExpandedTabs.length) return;
if (this.getTreePref('autoExpand.collapseFinally')) {
var self = this;
this.autoExpandedTabs.forEach(function(aTarget) {
self.collapseExpandSubtree(self.getTabById(aTarget), true);
});
}
this.autoExpandedTabs = [];
},
getSupportedFlavours : function() getSupportedFlavours : function()
{ {
var flavourSet = new FlavourSet(); var flavourSet = new FlavourSet();

View File

@ -15,6 +15,9 @@ pref("extensions.treestyletab.enableSubtreeIndent", true);
pref("extensions.treestyletab.enableSubtreeIndent.allTabsPopup", true); pref("extensions.treestyletab.enableSubtreeIndent.allTabsPopup", true);
pref("extensions.treestyletab.allowSubtreeCollapseExpand", true); pref("extensions.treestyletab.allowSubtreeCollapseExpand", true);
pref("extensions.treestyletab.showBorderForFirstTab", false); pref("extensions.treestyletab.showBorderForFirstTab", false);
pref("extensions.treestyletab.autoExpand.delay", 500);
pref("extensions.treestyletab.autoExpand.intelligently", true);
pref("extensions.treestyletab.autoExpand.collapseFinally", false);
pref("extensions.treestyletab.levelMargin", 12); pref("extensions.treestyletab.levelMargin", 12);
// 0 = first child, 1 = last child // 0 = first child, 1 = last child
pref("extensions.treestyletab.insertNewChildAt", 1); pref("extensions.treestyletab.insertNewChildAt", 1);