文字列やリンクなどのドロップ時に、直接新しいタブを開くようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1257 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
5864932c91
commit
c09a6f7703
@ -543,48 +543,36 @@ catch(e) {
|
||||
|
||||
eval('aTabBrowser.onDrop = '+
|
||||
aTabBrowser.onDrop.toSource().replace(
|
||||
'{', '{ TreeStyleTabService.clearDropPosition(this);'
|
||||
'{',
|
||||
<><![CDATA[
|
||||
{
|
||||
TreeStyleTabService.clearDropPosition(this);
|
||||
var dropActionInfo = TreeStyleTabService.getDropAction(aEvent, aDragSession);
|
||||
]]></>
|
||||
).replace(
|
||||
/(if \([^\)]+\) \{)/,
|
||||
'$1'+<><![CDATA[
|
||||
if ((function(aSelf) {
|
||||
var info = TreeStyleTabService.getDropAction(aEvent, aDragSession);
|
||||
var tab = aDragSession.sourceNode;
|
||||
var tabs = aSelf.mTabContainer.childNodes;
|
||||
if (info.action & TreeStyleTabService.kACTION_PART) {
|
||||
TreeStyleTabService.partTab(tab);
|
||||
if (
|
||||
info.action & TreeStyleTabService.kACTION_MOVE &&
|
||||
(
|
||||
!info.insertBefore ||
|
||||
TreeStyleTabService.getNextVisibleTab(tab) != info.insertBefore
|
||||
)
|
||||
) {
|
||||
var newIndex = info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 ;
|
||||
if (info.insertBefore && newIndex > tab._tPos) newIndex--;
|
||||
aSelf.moveTabTo(tab, newIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (info.action & TreeStyleTabService.kACTION_ATTACH) {
|
||||
TreeStyleTabService.attachTabTo(tab, info.parent);
|
||||
if (
|
||||
info.action & TreeStyleTabService.kACTION_MOVE &&
|
||||
(
|
||||
!info.insertBefore ||
|
||||
TreeStyleTabService.getNextVisibleTab(tab) != info.insertBefore
|
||||
)
|
||||
) {
|
||||
var newIndex = info.insertBefore ? info.insertBefore._tPos : tabs.length - 1 ;
|
||||
if (info.insertBefore && newIndex > tab._tPos) newIndex--;
|
||||
aSelf.moveTabTo(tab, newIndex);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})(this))
|
||||
if (TreeStyleTabService.processDropAction(dropActionInfo, this, aDragSession.sourceNode))
|
||||
return;
|
||||
]]></>
|
||||
).replace(
|
||||
/(this.loadOneTab\([^;]+\));/,
|
||||
<><![CDATA[
|
||||
TreeStyleTabService.processDropAction(dropActionInfo, this, $1);
|
||||
return;
|
||||
]]></>
|
||||
).replace(
|
||||
'document.getBindingParent(aEvent.originalTarget).localName != "tab"',
|
||||
'!TreeStyleTabService.getTabFromEvent(aEvent)'
|
||||
).replace(
|
||||
'var tab = aEvent.target;',
|
||||
<><![CDATA[
|
||||
var tab = aEvent.target;
|
||||
if (dropActionInfo.position != TreeStyleTabService.kDROP_ON) {
|
||||
TreeStyleTabService.processDropAction(dropActionInfo, this, this.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false));
|
||||
return;
|
||||
}
|
||||
]]></>
|
||||
)
|
||||
);
|
||||
|
||||
@ -1127,6 +1115,34 @@ catch(e) {
|
||||
this.setPref('extensions.treestyletab.tabbar.width', b.mStrip.boxObject.width);
|
||||
},
|
||||
|
||||
processDropAction : function(aInfo, aTabBrowser, aTarget)
|
||||
{
|
||||
var b = this.getTabBrowserFromChildren(aTabBrowser);
|
||||
var tabs = b.mTabContainer.childNodes;
|
||||
if (aTarget && aInfo.action & this.kACTION_PART) {
|
||||
this.partTab(aTarget);
|
||||
}
|
||||
else if (aInfo.action & this.kACTION_ATTACH) {
|
||||
this.attachTabTo(aTarget, aInfo.parent);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
aInfo.action & this.kACTION_MOVE &&
|
||||
(
|
||||
!aInfo.insertBefore ||
|
||||
this.getNextVisibleTab(aTarget) != aInfo.insertBefore
|
||||
)
|
||||
) {
|
||||
var newIndex = aInfo.insertBefore ? aInfo.insertBefore._tPos : tabs.length - 1 ;
|
||||
if (aInfo.insertBefore && newIndex > aTarget._tPos) newIndex--;
|
||||
b.moveTabTo(aTarget, newIndex);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/* Tab Utilities */
|
||||
|
||||
getTabValue : function(aTab, aKey)
|
||||
@ -1332,7 +1348,10 @@ catch(e) {
|
||||
{
|
||||
var info = this.getDropActionInternal(aEvent);
|
||||
info.canDrop = true;
|
||||
if (info.action & this.kACTION_ATTACH) {
|
||||
if (info.action & this.kACTION_ATTACH &&
|
||||
aDragSession &&
|
||||
aDragSession.sourceNode &&
|
||||
aDragSession.sourceNode.localName == 'tab') {
|
||||
var orig = aDragSession.sourceNode;
|
||||
if (orig == info.parent) {
|
||||
info.canDrop = false;
|
||||
|
Loading…
Reference in New Issue
Block a user