Open new tab next to the current tab correctly, even if the current tab is the last tab
This commit is contained in:
parent
2b13d9996d
commit
c44fa859dc
@ -1307,11 +1307,14 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
|||||||
|
|
||||||
/* notify "ready to open child tab(s)" */
|
/* notify "ready to open child tab(s)" */
|
||||||
|
|
||||||
readyToOpenChildTab : function TSTBase_readyToOpenChildTab(aTabOrSomething, aMultiple, aInsertBefore) /* PUBLIC API */
|
readyToOpenChildTab : function TSTBase_readyToOpenChildTab(aTabOrSomething, aMultiple, aOptions) /* PUBLIC API */
|
||||||
{
|
{
|
||||||
if (!utils.getTreePref('autoAttach'))
|
if (!utils.getTreePref('autoAttach'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (aOptions instanceof Ci.nsIDOMElement) // for backward compatibility
|
||||||
|
aOptions = { insertBefore : aOptions };
|
||||||
|
|
||||||
var browser = this.getBrowserFromTabBrowserElements(aTabOrSomething);
|
var browser = this.getBrowserFromTabBrowserElements(aTabOrSomething);
|
||||||
if (!browser)
|
if (!browser)
|
||||||
return false;
|
return false;
|
||||||
@ -1325,10 +1328,15 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
|||||||
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
||||||
var parentId = parentTab.getAttribute(this.kID);
|
var parentId = parentTab.getAttribute(this.kID);
|
||||||
|
|
||||||
var refId = null;
|
var insertBefore = null;
|
||||||
if (aInsertBefore) {
|
if (aOptions.insertBefore) {
|
||||||
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
||||||
refId = aInsertBefore.getAttribute(this.kID);
|
insertBefore = aOptions.insertBefore.getAttribute(this.kID);
|
||||||
|
}
|
||||||
|
var insertAfter = null;
|
||||||
|
if (aOptions.insertAfter) {
|
||||||
|
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
|
||||||
|
insertAfter = aOptions.insertAfter.getAttribute(this.kID);
|
||||||
}
|
}
|
||||||
|
|
||||||
logWithStackTrace('new child tab is requested.');
|
logWithStackTrace('new child tab is requested.');
|
||||||
@ -1337,7 +1345,8 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
|||||||
ownerBrowser.treeStyleTab.readiedToAttachMultiple = aMultiple || false ;
|
ownerBrowser.treeStyleTab.readiedToAttachMultiple = aMultiple || false ;
|
||||||
ownerBrowser.treeStyleTab.multipleCount = aMultiple ? 0 : -1 ;
|
ownerBrowser.treeStyleTab.multipleCount = aMultiple ? 0 : -1 ;
|
||||||
ownerBrowser.treeStyleTab.parentTab = parentId;
|
ownerBrowser.treeStyleTab.parentTab = parentId;
|
||||||
ownerBrowser.treeStyleTab.insertBefore = refId;
|
ownerBrowser.treeStyleTab.insertBefore = insertBefore;
|
||||||
|
ownerBrowser.treeStyleTab.insertAfter = insertAfter;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
@ -1411,12 +1420,16 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
|||||||
|
|
||||||
var parentTab = this.getParentTab(tab);
|
var parentTab = this.getParentTab(tab);
|
||||||
var nextTab = this.getNextSiblingTab(tab) || this.getNextTab(tab);
|
var nextTab = this.getNextSiblingTab(tab) || this.getNextTab(tab);
|
||||||
|
var previousTab = this.getPreviousTab(tab);
|
||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
/**
|
/**
|
||||||
* If the base tab has a parent, open the new tab as a child of
|
* If the base tab has a parent, open the new tab as a child of
|
||||||
* the parent tab.
|
* the parent tab.
|
||||||
*/
|
*/
|
||||||
return this.readyToOpenChildTab(parentTab, false, nextTab);
|
return this.readyToOpenChildTab(parentTab, false, {
|
||||||
|
insertBefore : nextTab,
|
||||||
|
insertAfter : previousTab
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/**
|
/**
|
||||||
|
@ -3244,6 +3244,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
'readiedToAttachNewTab: '+this.readiedToAttachNewTab,
|
'readiedToAttachNewTab: '+this.readiedToAttachNewTab,
|
||||||
'parentTab: '+this.parentTab + ' (' + this.getTabById(this.parentTab) + ')',
|
'parentTab: '+this.parentTab + ' (' + this.getTabById(this.parentTab) + ')',
|
||||||
'insertBefore: '+this.insertBefore,
|
'insertBefore: '+this.insertBefore,
|
||||||
|
'insertAfter: '+this.insertAfter,
|
||||||
'treeStructure: '+this.treeStructure
|
'treeStructure: '+this.treeStructure
|
||||||
].join('\n '));
|
].join('\n '));
|
||||||
|
|
||||||
@ -3287,6 +3288,11 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
|||||||
newIndex = refTab._tPos;
|
newIndex = refTab._tPos;
|
||||||
log(' newIndex => '+newIndex+' (from "insertBefore")');
|
log(' newIndex => '+newIndex+' (from "insertBefore")');
|
||||||
}
|
}
|
||||||
|
else if (this.insertAfter &&
|
||||||
|
(refTab = this.getTabById(this.insertAfter))) {
|
||||||
|
newIndex = refTab._tPos + 1;
|
||||||
|
log(' newIndex => '+newIndex+' (from "insertAfter")');
|
||||||
|
}
|
||||||
else if (
|
else if (
|
||||||
parent &&
|
parent &&
|
||||||
utils.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
|
utils.getTreePref('insertNewChildAt') == this.kINSERT_FISRT &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user