diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index 2d9b45dd..3eab25de 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -178,8 +178,8 @@ TreeStyleTabService.overrideExtensions = function() { '{', <> + ).replace( + /(aTab = gBrowser.addTab\(url\));/, + <> + ).replace( + /(aTab = event.target;)/, + <> + ).replace( + /aEvent/g, 'event' + ).replace( + /aDragSession/g, 'session' + ) + ); + eval('window.TM_BrowserHome = '+ window.TM_BrowserHome.toSource().replace( /(var bgLoad = )/, diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 8af7f458..9f63648a 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -52,11 +52,12 @@ var TreeStyleTabService = { kINSERT_FISRT : 0, kINSERT_LAST : 1, - levelMargin : 12, - levelMarginProp : 'margin-left', - positionProp : 'screenY', - sizeProp : 'height', - invertedSizeProp : 'width', + levelMargin : 12, + levelMarginProp : 'margin-left', + positionProp : 'screenY', + sizeProp : 'height', + invertedPositionProp : 'screenX', + invertedSizeProp : 'width', tabbarResizing : false, @@ -549,120 +550,7 @@ var TreeStyleTabService = { ) ); - eval('aTabBrowser.canDrop = '+ - aTabBrowser.canDrop.toSource().replace( - /\.screenX/g, '[TreeStyleTabService.positionProp]' - ).replace( - /\.width/g, '[TreeStyleTabService.sizeProp]' - ).replace( - /return true;/, - <> - ) - ); - - eval('aTabBrowser.onDragOver = '+ - aTabBrowser.onDragOver.toSource().replace( - '{', - <> - ) - ); - - eval('aTabBrowser.onDragExit = '+ - aTabBrowser.onDragExit.toSource().replace( - /(this.mTabDropIndicatorBar\.[^;]+;)/, - '$1; TreeStyleTabService.clearDropPosition(this);' - ) - ); - - eval('aTabBrowser.onDrop = '+ - aTabBrowser.onDrop.toSource().replace( - '{', - <> - ).replace( - /(if \([^\)]+\) \{)/, - '$1'+<> - ).replace( - /(this.loadOneTab\([^;]+\));/, - <> - ).replace( - 'document.getBindingParent(aEvent.originalTarget).localName != "tab"', - '!TreeStyleTabService.getTabFromEvent(aEvent)' - ).replace( - 'var tab = aEvent.target;', - <> - ) - ); + this.updateTabDNDObserver(aTabBrowser); eval('aTabBrowser.getNewIndex = '+ aTabBrowser.getNewIndex.toSource().replace( @@ -822,6 +710,131 @@ catch(e) { } }, + updateTabDNDObserver : function(aObserver) + { + eval('aObserver.canDrop = '+ + aObserver.canDrop.toSource().replace( + /\.screenX/g, '[TreeStyleTabService.positionProp]' + ).replace( + /\.width/g, '[TreeStyleTabService.sizeProp]' + ).replace( // Tab Mix Plus + /\.screenY/g, '[TreeStyleTabService.invertedPositionProp]' + ).replace( // Tab Mix Plus + /\.height/g, '[TreeStyleTabService.invertedSizeProp]' + ).replace( + /(return true;)/, + <> + ) + ); + + eval('aObserver.onDragOver = '+ + aObserver.onDragOver.toSource().replace( + '{', + <> + ) + ); + + eval('aObserver.onDragExit = '+ + aObserver.onDragExit.toSource().replace( + /(this.mTabDropIndicatorBar\.[^;]+;)/, + '$1; TreeStyleTabService.clearDropPosition(this);' + ) + ); + + eval('aObserver.onDrop = '+ + aObserver.onDrop.toSource().replace( + '{', + <> + ).replace( + /(if \(aDragSession[^\)]+\) \{)/, + '$1'+<> + ).replace( + /(this.loadOneTab\([^;]+\));/, + <> + ).replace( + 'document.getBindingParent(aEvent.originalTarget).localName != "tab"', + '!TreeStyleTabService.getTabFromEvent(aEvent)' + ).replace( + 'var tab = aEvent.target;', + <> + ) + ); + }, + initTab : function(aTab, aTabBrowser) { if (!aTabBrowser) @@ -2172,9 +2185,10 @@ catch(e) { var tabBarMode = this.getPref('extensions.tabmix.tabBarMode'); if (pos & this.kTABBAR_VERTICAL) { - this.positionProp = 'screenY'; - this.sizeProp = 'height'; - this.invertedSizeProp = 'width'; + this.positionProp = 'screenY'; + this.sizeProp = 'height'; + this.invertedPositionProp = 'screenX'; + this.invertedSizeProp = 'width'; aTabBrowser.mTabBox.orient = 'horizontal'; aTabBrowser.mStrip.orient = @@ -2237,9 +2251,10 @@ catch(e) { } } else { - this.positionProp = 'screenX'; - this.sizeProp = 'width'; - this.invertedSizeProp = 'height'; + this.positionProp = 'screenX'; + this.sizeProp = 'width'; + this.invertedPositionProp = 'screenY'; + this.invertedSizeProp = 'height'; aTabBrowser.mTabBox.orient = 'vertical'; aTabBrowser.mStrip.orient =