diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index e412d8f4..9c1585d1 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -35,7 +35,8 @@ TreeStyleTabService.overrideExtensionsPreInit = function() { prefix+this.kCHILDREN, prefix+this.kPARENT, prefix+this.kANCESTOR, - prefix+this.kINSERT_BEFORE + prefix+this.kINSERT_BEFORE, + prefix+this.kINSERT_AFTER ]; eval('SessionData.getTabProperties = '+ SessionData.getTabProperties.toSource().replace( diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index a313ae35..436d7121 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -6,6 +6,7 @@ var TreeStyleTabService = { kANCESTOR : 'treestyletab-ancestors', kNEST : 'treestyletab-nest', kINSERT_BEFORE : 'treestyletab-insert-before', + kINSERT_AFTER : 'treestyletab-insert-after', kSUBTREE_COLLAPSED : 'treestyletab-subtree-collapsed', kCOLLAPSED : 'treestyletab-collapsed', diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 37b9a1b0..81792b8d 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1466,6 +1466,10 @@ TreeStyleTabBrowser.prototype = { if (prev) this.setTabValue(prev, this.kINSERT_BEFORE, tab.getAttribute(this.kID)); + var next = this.getNextSiblingTab(tab); + if (next) + this.setTabValue(next, this.kINSERT_AFTER, tab.getAttribute(this.kID)); + this.showTabbarForFeedback(); }, @@ -1498,17 +1502,24 @@ TreeStyleTabBrowser.prototype = { var parentTab = this.getParentTab(tab); var nextFocusedTab = null; - var next = this.getNextSiblingTab(tab); - if (next) - this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); - var prev = this.getPreviousSiblingTab(tab); + var next = this.getNextSiblingTab(tab); if (prev) { + this.setTabValue(tab, this.kINSERT_AFTER, prev.getAttribute(this.kID)); + if (next) this.setTabValue(prev, this.kINSERT_BEFORE, next.getAttribute(this.kID)); else this.deleteTabValue(prev, this.kINSERT_BEFORE); } + if (next) { + this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); + + if (prev) + this.setTabValue(next, this.kINSERT_AFTER, prev.getAttribute(this.kID)); + else + this.deleteTabValue(next, this.kINSERT_AFTER); + } var backupAttributes = {}; var indentModifiedTabs = []; @@ -1666,6 +1677,12 @@ TreeStyleTabBrowser.prototype = { this.updateTabsCount(tab, true); + var prev = this.getPreviousSiblingTab(tab); + if (prev) + this.setTabValue(tab, this.kINSERT_AFTER, prev.getAttribute(this.kID)); + else + this.deleteTabValue(tab, this.kINSERT_AFTER); + var next = this.getNextSiblingTab(tab); if (next) this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); @@ -1675,6 +1692,13 @@ TreeStyleTabBrowser.prototype = { var old = aEvent.detail; if (old > tab._tPos) old--; old = this.getTabs(b).snapshotItem(old); + + prev = this.getPreviousSiblingTab(old); + if (prev) + this.setTabValue(old, this.kINSERT_AFTER, prev.getAttribute(this.kID)); + else + this.deleteTabValue(old, this.kINSERT_AFTER); + next = this.getNextSiblingTab(old); if (next) this.setTabValue(old, this.kINSERT_BEFORE, next.getAttribute(this.kID)); @@ -1839,6 +1863,12 @@ TreeStyleTabBrowser.prototype = { if (nextTab && maybeDuplicated) nextTab = this.redirectId(nextTab); nextTab = this.getTabById(nextTab); + if (!nextTab) { + var prevTab = this.getTabValue(tab, this.kINSERT_AFTER); + if (prevTab && maybeDuplicated) prevTab = this.redirectId(prevTab); + nextTab = this.getNextSiblingTab(this.getTabById(prevTab)); + } + var ancestors = (this.getTabValue(tab, this.kANCESTOR) || this.getTabValue(tab, this.kPARENT)).split('|'); var parent = null; for (var i in ancestors)