2009-12-24 03:19:52 -05:00
function TreeStyleTabBrowser ( aTabBrowser )
2007-11-14 14:34:36 -05:00
{
this . mTabBrowser = aTabBrowser ;
}
TreeStyleTabBrowser . prototype = {
2010-07-29 22:39:51 -04:00
_ _proto _ _ : TreeStyleTabService ,
2007-11-17 01:05:23 -05:00
2009-12-25 06:19:50 -05:00
kMENUITEM _RELOADSUBTREE : 'context-item-reloadTabSubtree' ,
2009-07-06 05:21:06 -04:00
kMENUITEM _RELOADCHILDREN : 'context-item-reloadDescendantTabs' ,
2009-12-25 06:19:50 -05:00
kMENUITEM _REMOVESUBTREE : 'context-item-removeTabSubtree' ,
2007-11-26 10:07:10 -05:00
kMENUITEM _REMOVECHILDREN : 'context-item-removeDescendantTabs' ,
2007-11-17 01:05:23 -05:00
kMENUITEM _COLLAPSEEXPAND _SEPARATOR : 'context-separator-collapseExpandAll' ,
kMENUITEM _COLLAPSE : 'context-item-collapseAllSubtree' ,
kMENUITEM _EXPAND : 'context-item-expandAllSubtree' ,
kMENUITEM _AUTOHIDE _SEPARATOR : 'context-separator-toggleAutoHide' ,
kMENUITEM _AUTOHIDE : 'context-item-toggleAutoHide' ,
2008-02-22 12:55:35 -05:00
kMENUITEM _FIXED : 'context-item-toggleFixed' ,
2009-12-25 06:19:50 -05:00
kMENUITEM _BOOKMARKSUBTREE : 'context-item-bookmarkTabSubtree' ,
2008-12-01 03:30:36 -05:00
2007-11-14 14:34:36 -05:00
mTabBrowser : null ,
2009-12-18 07:57:21 -05:00
indent : - 1 ,
indentProp : 'margin' ,
indentTarget : 'left' ,
2010-08-13 13:14:46 -04:00
indentCSSProp : 'margin-left' ,
2009-12-18 07:57:21 -05:00
collapseTarget : 'top' ,
2010-08-13 13:14:46 -04:00
collapseCSSProp : 'margin-top' ,
2007-11-14 14:34:36 -05:00
positionProp : 'screenY' ,
sizeProp : 'height' ,
invertedPositionProp : 'screenX' ,
invertedSizeProp : 'width' ,
2010-11-18 23:00:42 -05:00
2010-11-29 03:24:45 -05:00
maxTreeLevel : - 1 ,
maxTreeLevelPhisical : false ,
2010-11-18 23:00:42 -05:00
enableSubtreeIndent : true ,
allowSubtreeCollapseExpand : true ,
hideAlltabsButton : true ,
2007-11-14 14:34:36 -05:00
2007-11-17 07:59:48 -05:00
get browser ( )
{
return this . mTabBrowser ;
} ,
2007-11-14 14:34:36 -05:00
get container ( )
{
2009-09-02 22:05:25 -04:00
if ( ! this . _container ) {
this . _container = document . getElementById ( 'appcontent' ) ;
}
return this . _container ;
2007-11-14 14:34:36 -05:00
} ,
2009-09-02 22:05:25 -04:00
_container : null ,
2007-11-14 14:34:36 -05:00
2008-06-20 01:57:38 -04:00
get scrollBox ( )
{
2009-09-02 22:05:25 -04:00
if ( ! this . _scrollBox ) {
2009-12-15 03:33:03 -05:00
this . _scrollBox = ( // Tab Mix Plus
this . getTreePref ( 'compatibility.TMP' ) &&
document . getAnonymousElementByAttribute ( this . mTabBrowser . mTabContainer , 'class' , 'tabs-frame' )
) ||
this . mTabBrowser . mTabContainer . mTabstrip ;
2009-09-02 22:05:25 -04:00
}
return this . _scrollBox ;
2008-06-20 01:57:38 -04:00
} ,
2009-09-02 22:05:25 -04:00
_scrollBox : null ,
2008-10-17 13:16:16 -04:00
get scrollBoxObject ( )
2008-06-20 01:57:38 -04:00
{
2009-07-07 00:22:08 -04:00
return ( this . scrollBox . scrollBoxObject || this . scrollBox . boxObject )
2009-12-15 03:33:03 -05:00
. QueryInterface ( Components . interfaces . nsIScrollBoxObject ) ; // Tab Mix Plus (ensure scrollbox-ed)
2008-06-20 01:57:38 -04:00
} ,
2010-03-23 15:10:53 -04:00
get splitter ( )
{
return document . getAnonymousElementByAttribute ( this . mTabBrowser , 'class' , this . kSPLITTER ) ||
document . getAnonymousElementByAttribute ( this . mTabBrowser , 'id' , 'tabkit-splitter' ) ; // Tab Kit
} ,
2010-03-25 23:17:16 -04:00
get tabStripPlaceHolder ( )
{
return this . _tabStripPlaceHolder ;
} ,
2010-03-28 14:22:15 -04:00
set tabStripPlaceHolder ( value )
2010-03-25 23:17:16 -04:00
{
2010-03-25 23:32:38 -04:00
return ( this . _tabStripPlaceHolder = value ) ;
2010-03-25 23:17:16 -04:00
} ,
2007-11-14 14:34:36 -05:00
/* utils */
2008-03-09 23:51:21 -04:00
2008-02-22 02:44:06 -05:00
/* get tab contents */
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
getTabLabel : function TSTBrowser _getTabLabel ( aTab )
2007-11-17 00:20:26 -05:00
{
2008-05-29 04:59:41 -04:00
var label = document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-text-stack' ) || // Mac OS X
2009-12-15 03:33:03 -05:00
( // Tab Mix Plus
this . getTreePref ( 'compatibility.TMP' ) &&
document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-text-container' )
) ||
2010-09-15 08:44:22 -04:00
document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-text tab-label' ) || // Firefox 4.0-
2010-11-29 19:42:22 -05:00
document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-text' ) ; // Firefox 3.5 - Firefox 3.6
2007-11-17 00:20:26 -05:00
return label ;
} ,
2009-12-25 03:34:52 -05:00
getTabClosebox : function TSTBrowser _getTabClosebox ( aTab )
2007-11-17 00:20:26 -05:00
{
2009-12-15 03:33:03 -05:00
var close = ( // Tab Mix Plus
this . getTreePref ( 'compatibility.TMP' ) &&
document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-close-button always-right' )
) ||
2007-11-17 00:20:26 -05:00
document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-close-button' ) ;
return close ;
} ,
/* status */
2008-02-22 02:44:06 -05:00
2007-11-14 14:43:54 -05:00
get isVertical ( )
2007-11-14 14:34:36 -05:00
{
2010-09-13 00:57:53 -04:00
if ( ! this . preInitialized )
return [ 'left' , 'right' ] . indexOf ( this . currentTabbarPosition ) > - 1 ;
2007-11-14 14:34:36 -05:00
var b = this . mTabBrowser ;
if ( ! b ) return false ;
2008-06-20 01:57:38 -04:00
var box = this . scrollBox || b . mTabContainer ;
2007-11-14 14:34:36 -05:00
return ( box . getAttribute ( 'orient' ) || window . getComputedStyle ( box , '' ) . getPropertyValue ( '-moz-box-orient' ) ) == 'vertical' ;
} ,
2010-03-25 23:17:16 -04:00
get isFloating ( )
{
2010-03-28 22:11:14 -04:00
return this . _tabStripPlaceHolder ;
2010-03-25 23:17:16 -04:00
} ,
2010-05-15 10:05:02 -04:00
get isFixed ( )
{
2010-09-13 00:57:53 -04:00
var orient = this . isVertical ? 'vertical' : 'horizontal' ;
if ( ! this . preInitialized )
return this . getTreePref ( 'tabbar.fixed.' + orient ) ;
2010-05-15 10:05:02 -04:00
var b = this . mTabBrowser ;
if ( ! b ) return false ;
2010-09-13 00:57:53 -04:00
return b . getAttribute ( this . kFIXED + '-' + orient ) == 'true' ;
2010-05-15 10:05:02 -04:00
} ,
2010-11-24 11:14:36 -05:00
get canStackTabs ( )
{
return (
this . isFloating &&
! this . isVertical &&
this . canCollapseSubtree ( ) &&
this . getTreePref ( 'stackCollapsedTabs' )
) ;
} ,
2009-12-25 03:34:52 -05:00
isTabInViewport : function TSTBrowser _isTabInViewport ( aTab )
2007-11-14 14:34:36 -05:00
{
2010-09-13 00:57:53 -04:00
if ( ! this . preInitialized || ! aTab )
return false ;
2010-09-09 05:38:48 -04:00
if ( aTab . getAttribute ( 'pinned' ) == 'true' )
2010-09-09 05:02:26 -04:00
return true ;
2007-11-14 14:34:36 -05:00
var tabBox = aTab . boxObject ;
2008-06-20 01:57:38 -04:00
var barBox = this . scrollBox . boxObject ;
2009-04-08 11:16:34 -04:00
var xOffset = this . getXOffsetOfTab ( aTab ) ;
var yOffset = this . getYOffsetOfTab ( aTab ) ;
return ( tabBox . screenX + xOffset >= barBox . screenX &&
tabBox . screenX + xOffset + tabBox . width <= barBox . screenX + barBox . width &&
tabBox . screenY + yOffset >= barBox . screenY &&
tabBox . screenY + yOffset + tabBox . height <= barBox . screenY + barBox . height ) ;
2007-11-14 14:34:36 -05:00
} ,
2008-02-22 02:44:06 -05:00
2009-12-25 03:34:52 -05:00
isMultiRow : function TSTBrowser _isMultiRow ( )
2008-02-22 02:44:06 -05:00
{
return false ;
} ,
2010-06-25 11:59:59 -04:00
2010-09-09 06:03:03 -04:00
positionPinnedTabs : function TSTBrowser _positionPinnedTabs ( aWidth , aHeight )
2010-06-25 11:59:59 -04:00
{
2010-09-09 06:03:03 -04:00
if ( ! this . isVertical )
return ;
2010-06-25 11:59:59 -04:00
var b = this . mTabBrowser ;
var tabbar = b . tabContainer ;
2010-09-09 06:03:03 -04:00
var count = this . pinnedTabsCount ;
2010-09-09 05:32:22 -04:00
var width = aWidth || this . PINNED _TAB _DEFAULT _WIDTH ;
var height = aHeight || this . PINNED _TAB _DEFAULT _HEIGHT ;
2010-06-25 11:59:59 -04:00
var maxCol = Math . floor ( tabbar . boxObject . width / width ) ;
var maxRow = Math . ceil ( count / maxCol ) ;
var col = 0 ;
var row = 0 ;
2010-06-25 12:14:49 -04:00
tabbar . style . MozMarginStart = '' ;
2010-06-25 11:59:59 -04:00
tabbar . style . marginTop = ( height * maxRow ) + 'px' ;
2010-06-25 12:14:49 -04:00
for ( var i = 0 ; i < count ; i ++ )
2010-06-25 11:59:59 -04:00
{
2010-06-25 12:14:49 -04:00
let style = tabbar . childNodes [ i ] . style ;
style . MozMarginStart = '' ;
style . setProperty ( 'margin-left' , ( width * col ) + 'px' , 'important' ) ;
style . setProperty ( 'margin-top' , ( - height * ( maxRow - row ) ) + 'px' , 'important' ) ;
2010-09-09 06:03:03 -04:00
style . top = style . right = style . bottom = style . left = '' ;
2010-06-25 11:59:59 -04:00
col ++ ;
if ( col >= maxCol ) {
col = 0 ;
row ++ ;
}
}
} ,
2010-09-09 05:32:22 -04:00
PINNED _TAB _DEFAULT _WIDTH : 24 ,
PINNED _TAB _DEFAULT _HEIGHT : 24 ,
2010-06-25 12:14:49 -04:00
2010-09-09 06:03:03 -04:00
resetPinnedTabs : function TSTBrowser _resetPinnedTabs ( )
2010-06-25 12:14:49 -04:00
{
var b = this . mTabBrowser ;
var tabbar = b . tabContainer ;
2010-09-09 06:03:03 -04:00
tabbar . style . MozMarginStart = tabbar . style . marginTop = '' ;
for ( var i = 0 , count = this . pinnedTabsCount ; i < count ; i ++ )
2010-06-25 12:14:49 -04:00
{
let style = tabbar . childNodes [ i ] . style ;
2010-09-09 06:03:03 -04:00
style . MozMarginStart = style . marginLeft = style . marginTop = '' ;
2010-06-25 12:14:49 -04:00
}
} ,
2010-06-25 12:28:01 -04:00
onPinTab : function TSTBrowser _onPinTab ( aTab )
{
var parentTab = this . getParentTab ( aTab ) ;
2010-06-26 13:10:13 -04:00
if ( ! parentTab )
this . collapseExpandSubtree ( aTab , false ) ;
2010-06-25 12:28:01 -04:00
this . getChildTabs ( aTab ) . reverse ( ) . forEach (
parentTab ?
function ( aChildTab ) {
this . attachTabTo ( aChildTab , parentTab , {
2010-06-26 13:10:13 -04:00
dontExpand : true ,
dontMove : true
2010-06-25 12:28:01 -04:00
} ) ;
} :
this . partTab ,
this ) ;
this . partTab ( aTab ) ;
2010-06-26 13:10:13 -04:00
this . collapseExpandTab ( aTab , false ) ;
2010-06-25 12:28:01 -04:00
} ,
2010-06-25 12:14:49 -04:00
onUnpinTab : function TSTBrowser _onUnpinTab ( aTab )
{
aTab . style . marginLeft = '' ;
aTab . style . marginTop = '' ;
} ,
2010-11-24 11:14:36 -05:00
2010-11-24 18:37:26 -05:00
updateTabsZIndex : function TSTBrowser _updateTabsZIndex ( aStacked )
2010-11-24 11:14:36 -05:00
{
var tabs = this . getTabsArray ( this . mTabBrowser ) ;
var count = tabs . length ;
2010-11-24 18:37:26 -05:00
tabs . forEach (
aStacked ?
function ( aTab , aIndex ) {
aTab . style . zIndex = count * 1000 - aIndex ;
} :
function ( aTab , aIndex ) {
aTab . style . zIndex = '' ;
}
) ;
2010-11-24 11:14:36 -05:00
} ,
2008-02-22 12:55:35 -05:00
2007-11-17 00:20:26 -05:00
/* initialize */
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
init : function TSTBrowser _init ( )
2007-11-14 14:34:36 -05:00
{
2010-02-03 08:43:39 -05:00
this . stopRendering ( ) ;
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
2010-03-23 13:58:23 -04:00
b . tabContainer . treeStyleTab = this ;
2007-11-14 14:34:36 -05:00
2010-03-24 11:38:08 -04:00
this . tabsHash = { } ;
2010-03-25 23:17:16 -04:00
this . tabStripPlaceHolder = null ;
2010-03-03 08:30:49 -05:00
2010-09-16 06:46:15 -04:00
this . tabVisibilityChangedTabs = [ ] ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount = 0 ;
this . subTreeMovingCount = 0 ;
this . subTreeChildrenMovingCount = 0 ;
2009-12-18 04:05:41 -05:00
this . _treeViewEnabled = true ;
2009-09-30 01:42:48 -04:00
2010-03-25 23:17:16 -04:00
let ( toggler , placeHolder ) {
2009-12-24 10:13:04 -05:00
toggler = document . getAnonymousElementByAttribute ( b , 'class' , this . kTABBAR _TOGGLER ) ;
if ( ! toggler ) {
2009-09-03 03:31:49 -04:00
toggler = document . createElement ( 'spacer' ) ;
toggler . setAttribute ( 'class' , this . kTABBAR _TOGGLER ) ;
2010-03-23 13:58:23 -04:00
b . mTabBox . insertBefore ( toggler , b . mTabBox . firstChild ) ;
2010-06-23 07:36:39 -04:00
if ( b . mTabDropIndicatorBar == toggler )
b . mTabDropIndicatorBar = document . getAnonymousElementByAttribute ( b , 'class' , 'tab-drop-indicator-bar' ) ;
2009-09-03 03:31:49 -04:00
}
2010-03-25 23:17:16 -04:00
placeHolder = document . getAnonymousElementByAttribute ( b , 'anonid' , 'strip' ) ;
if ( ! placeHolder ) {
placeHolder = document . createElement ( 'hbox' ) ;
placeHolder . setAttribute ( 'anonid' , 'strip' ) ;
placeHolder . setAttribute ( 'class' , 'tabbrowser-strip' ) ;
2010-04-21 06:21:28 -04:00
placeHolder . setAttribute ( this . kTABBAR _PLACEHOLDER , true ) ;
2010-03-25 23:17:16 -04:00
b . mTabBox . insertBefore ( placeHolder , toggler . nextSibling ) ;
2010-03-23 14:31:55 -04:00
}
2010-03-25 23:17:16 -04:00
if ( placeHolder != this . tabStrip )
this . tabStripPlaceHolder = placeHolder ;
2009-09-03 03:31:49 -04:00
}
2009-12-25 04:49:47 -05:00
let position = this . currentTabbarPosition ;
2010-11-30 05:05:00 -05:00
this . fireTabbarPositionEvent ( this . kEVENT _TYPE _TABBAR _POSITION _CHANGING , 'top' , position ) ; /* PUBLIC API */
2009-12-25 04:49:47 -05:00
2010-05-08 02:22:49 -04:00
this . setTabbrowserAttribute ( this . kFIXED + '-horizontal' , this . getTreePref ( 'tabbar.fixed.horizontal' ) ? 'true' : null , b ) ;
this . setTabbrowserAttribute ( this . kFIXED + '-vertical' , this . getTreePref ( 'tabbar.fixed.vertical' ) ? 'true' : null , b ) ;
2010-05-08 01:37:41 -04:00
this . initTabbar ( null , this . kTABBAR _TOP ) ;
2007-11-14 14:34:36 -05:00
2010-11-30 05:05:00 -05:00
var tabContainer = b . mTabContainer ;
tabContainer . addEventListener ( 'TabOpen' , this , true ) ;
tabContainer . addEventListener ( 'TabClose' , this , true ) ;
tabContainer . addEventListener ( 'TabMove' , this , true ) ;
tabContainer . addEventListener ( 'TabShow' , this , true ) ;
tabContainer . addEventListener ( 'TabHide' , this , true ) ;
tabContainer . addEventListener ( 'SSTabRestoring' , this , true ) ;
tabContainer . addEventListener ( 'SSTabRestored' , this , true ) ;
tabContainer . addEventListener ( 'TabPinned' , this , true ) ;
tabContainer . addEventListener ( 'TabUnpinned' , this , true ) ;
2010-09-17 12:10:59 -04:00
if ( ! this . isFloating && 'tabutils' in window )
2010-11-30 05:05:00 -05:00
tabContainer . addEventListener ( 'DOMAttrModified' , this , true ) ; // Tab Utilities
tabContainer . addEventListener ( 'mouseover' , this , true ) ;
tabContainer . addEventListener ( 'mouseout' , this , true ) ;
tabContainer . addEventListener ( 'dblclick' , this , true ) ;
tabContainer . addEventListener ( 'select' , this , true ) ;
tabContainer . addEventListener ( 'scroll' , this , true ) ;
tabContainer . addEventListener ( 'dragleave' , this , false ) ;
tabContainer . addEventListener ( 'dragover' , this , false ) ;
tabContainer . addEventListener ( 'drop' , this , true ) ;
tabContainer . addEventListener ( 'dragdrop' , this , false ) ; // for Firefox 3.5 or older
2010-11-30 19:51:10 -05:00
tabContainer . addEventListener ( 'MultipleTabHandler:TabsDragStart' , this , true ) ;
2010-11-30 05:05:00 -05:00
var strip = this . tabStrip ;
2010-07-01 23:39:31 -04:00
strip . addEventListener ( 'dragstart' , this , false ) ;
strip . addEventListener ( 'dragenter' , this , false ) ;
strip . addEventListener ( 'dragleave' , this , false ) ;
strip . addEventListener ( 'dragend' , this , false ) ;
strip . addEventListener ( 'dragover' , this , false ) ;
strip . addEventListener ( 'drop' , this , false ) ;
strip . addEventListener ( 'MozMouseHittest' , this , true ) ; // to block default behaviors of the tab bar
strip . addEventListener ( 'mousedown' , this , true ) ;
strip . addEventListener ( 'click' , this , true ) ;
2007-11-14 14:34:36 -05:00
2010-03-25 23:17:16 -04:00
if ( this . isFloating )
2010-03-23 15:10:53 -04:00
window . addEventListener ( 'resize' , this , true ) ;
2010-04-29 23:48:07 -04:00
this . scrollBox . addEventListener ( 'overflow' , this , true ) ;
this . scrollBox . addEventListener ( 'underflow' , this , true ) ;
2010-11-30 05:05:00 -05:00
window . addEventListener ( this . kEVENT _TYPE _PRINT _PREVIEW _ENTERED , this , false ) ;
window . addEventListener ( this . kEVENT _TYPE _PRINT _PREVIEW _EXITED , this , false ) ;
2010-03-28 14:22:15 -04:00
2009-12-25 22:26:40 -05:00
b . addEventListener ( 'MultipleTabHandlerTabsClosing' , this , false ) ;
2009-03-04 15:42:41 -05:00
2010-11-29 22:23:08 -05:00
window [ 'piro.sakura.ne.jp' ] . tabsDragUtils . initTabBrowser ( b ) ;
2010-03-25 13:36:27 -04:00
2007-11-29 11:49:18 -05:00
/ * C l o s i n g c o l l a p s e d l a s t t r e e b r e a k s s e l e c t e d t a b .
To solve this problem , I override the setter to
force to set a tab and forbid it becomes null . * /
2009-05-13 02:09:17 -04:00
let ( getter , setter ) {
getter = b . _ _lookupGetter _ _ ( 'selectedTab' ) ;
setter = b . _ _lookupSetter _ _ ( 'selectedTab' ) ;
eval ( 'setter = ' + setter . toSource ( ) . replace (
'{' ,
< ! [ CDATA [ $ &
if ( ! val ) {
val = TreeStyleTabService . getLastTab ( this ) ;
}
] ] > . toString ( )
) ) ;
/ * W e h a v e t o u s e b o t h _ _ d e f i n e S e t t e r _ _ a n d _ _ d e f i n e G e t t e r _ _
just in same time ! ! If we update only setter ,
getter will be vanished . * /
b . _ _defineGetter _ _ ( 'selectedTab' , getter ) ;
b . _ _defineSetter _ _ ( 'selectedTab' , setter ) ;
getter = null ;
setter = null ;
}
2007-11-29 11:49:18 -05:00
2009-07-24 04:11:05 -04:00
eval ( 'b.mTabContainer._selectNewTab = ' +
2009-07-24 04:41:33 -04:00
b . mTabContainer . _selectNewTab . toSource ( ) . replace (
2007-11-17 00:20:26 -05:00
'{' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ $ &
2008-03-03 04:07:02 -05:00
if ( arguments [ 0 ] . _ _treestyletab _ _preventSelect ) {
arguments [ 0 ] . _ _treestyletab _ _preventSelect = false ;
return ;
}
2009-03-26 11:30:00 -04:00
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2008-03-03 04:07:02 -05:00
eval ( 'b.mTabContainer.adjustTabstrip = ' +
b . mTabContainer . adjustTabstrip . toSource ( ) . replace (
2009-05-12 11:09:49 -04:00
/(\}\)?)$/ ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2008-03-03 04:21:33 -05:00
var b = TreeStyleTabService . getTabBrowserFromChild ( this ) ;
b . treeStyleTab . updateInvertedTabContentsOrder ( true ) ;
2009-05-12 11:09:49 -04:00
$1 ] ] >
2008-03-03 04:07:02 -05:00
)
) ;
2007-11-17 00:20:26 -05:00
eval ( 'b.mTabContainer.advanceSelectedTab = ' +
b . mTabContainer . advanceSelectedTab . toSource ( ) . replace (
'{' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ $ &
2009-08-14 02:12:08 -04:00
var treeStyleTab = TreeStyleTabService . getTabBrowserFromChild ( this ) . treeStyleTab ;
treeStyleTab . _focusChangedByShortcut = TreeStyleTabService . accelKeyPressed ;
2010-11-29 03:24:45 -05:00
if ( treeStyleTab . canCollapseSubtree ( this . selectedItem ) &&
2009-10-25 22:36:42 -04:00
treeStyleTab . getTreePref ( 'focusMode' ) == treeStyleTab . kFOCUS _VISIBLE ) {
2008-03-03 04:07:02 -05:00
( function ( aDir , aWrap , aSelf ) {
var nextTab = ( aDir < 0 ) ? treeStyleTab . getPreviousVisibleTab ( aSelf . selectedItem ) : treeStyleTab . getNextVisibleTab ( aSelf . selectedItem ) ;
if ( ! nextTab && aWrap ) {
2009-01-26 01:13:37 -05:00
nextTab = TreeStyleTabService . evaluateXPath (
'child::xul:tab[not(@' + TreeStyleTabService . kCOLLAPSED + '="true")][' +
( aDir < 0 ? 'last()' : '1' ) +
']' ,
2009-03-24 13:44:30 -04:00
aSelf ,
2009-02-22 12:33:32 -05:00
XPathResult . FIRST _ORDERED _NODE _TYPE
2009-01-26 01:13:37 -05:00
) . singleNodeValue ;
2008-03-03 04:07:02 -05:00
}
if ( nextTab && nextTab != aSelf . selectedItem ) {
2009-07-24 04:42:18 -04:00
aSelf . _selectNewTab ( nextTab , aDir , aWrap ) ;
2008-03-03 04:07:02 -05:00
}
} ) ( arguments [ 0 ] , arguments [ 1 ] , this ) ;
return ;
}
2009-03-26 11:30:00 -04:00
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
eval ( 'b.mTabContainer._handleTabSelect = ' +
b . mTabContainer . _handleTabSelect . toSource ( ) . replace (
'{' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ $ &
2009-03-16 07:58:43 -04:00
if ( ( function ( aTabs ) {
var treeStyleTab = TreeStyleTabService . getTabBrowserFromChild ( aTabs ) . treeStyleTab ;
var tab = aTabs . selectedItem ;
if ( ! treeStyleTab . isTabInViewport ( tab ) ) {
treeStyleTab . scrollToTab ( tab ) ;
return true ;
}
return false ;
} ) ( this ) ) {
2008-03-03 04:07:02 -05:00
return ;
}
2009-03-26 11:30:00 -04:00
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2008-06-18 11:04:37 -04:00
/ *
if ( 'ensureElementIsVisible' in b . mTabContainer . mTabstrip &&
'_smoothScrollByPixels' in b . mTabContainer . mTabstrip ) {
eval ( 'b.mTabContainer.mTabstrip.ensureElementIsVisible = ' +
b . mTabContainer . mTabstrip . ensureElementIsVisible . toSource ( ) . replace (
'{' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ $ &
2008-06-18 11:04:37 -04:00
var browser = TreeStyleTabService . getTabBrowserFromChild ( this ) ;
var startProp = browser . treeStyleTab . isVertical ? 'top' : 'left' ;
var endProp = browser . treeStyleTab . isVertical ? 'bottom' : 'right' ;
2009-03-26 11:30:00 -04:00
] ] >
2008-06-18 11:04:37 -04:00
) . replace (
/\.left/g , '[startProp]'
) . replace (
/\.right/g , '[endProp]'
) . replace (
'|| this.getAttribute("orient") == "vertical"' , ''
)
) ;
eval ( 'b.mTabContainer.mTabstrip._smoothScrollByPixels = ' +
b . mTabContainer . mTabstrip . _smoothScrollByPixels . toSource ( ) . replace (
'{' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ $ &
2008-06-18 11:04:37 -04:00
var TST = TreeStyleTabService . getTabBrowserFromChild ( this ) ;
2009-03-26 11:30:00 -04:00
] ] >
2008-06-18 11:04:37 -04:00
) . replace (
'scrollBy(distance, 0)' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [ scrollBy (
2008-06-18 11:04:37 -04:00
( TST . isVertical ? 0 : distance ) ,
( TST . isVertical ? distance : 0 )
2009-03-26 11:30:00 -04:00
) ] ] >
2008-06-18 11:04:37 -04:00
)
) ;
}
* /
2007-11-17 00:20:26 -05:00
eval ( 'b.mTabContainer._notifyBackgroundTab = ' +
b . mTabContainer . _notifyBackgroundTab . toSource ( ) . replace (
'{' ,
2007-11-17 08:32:41 -05:00
'{ var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;'
2007-11-17 00:20:26 -05:00
) . replace (
/\.screenX/g , '[treeStyleTab.positionProp]'
) . replace (
/\.width/g , '[treeStyleTab.sizeProp]'
)
) ;
2007-11-14 14:34:36 -05:00
2010-06-25 11:59:59 -04:00
if ( b . mTabContainer . _positionPinnedTabs ) {
eval ( 'b.mTabContainer._positionPinnedTabs = ' +
b . mTabContainer . _positionPinnedTabs . toSource ( ) . replace (
'{' ,
< ! [ CDATA [ {
if ( this . tabbrowser . treeStyleTab . isVertical ) {
2010-09-09 06:03:03 -04:00
this . tabbrowser . treeStyleTab . positionPinnedTabs ( ) ;
2010-06-25 11:59:59 -04:00
}
else {
2010-09-09 06:03:03 -04:00
this . tabbrowser . treeStyleTab . resetPinnedTabs ( ) ;
2010-06-25 11:59:59 -04:00
] ] > . toString ( )
) . replace (
'this.mTabstrip.ensureElementIsVisible' ,
'} $&'
)
) ;
}
2010-03-24 13:20:30 -04:00
TreeStyleTabService . updateTabDNDObserver ( b ) ;
2007-11-14 14:34:36 -05:00
2010-08-07 12:15:07 -04:00
if ( b . tabContainer && '_getDropIndex' in b . tabContainer ) { // Firefox 4.0 or later
2010-03-23 13:58:23 -04:00
eval ( 'b.tabContainer._getDropIndex = ' +
b . tabContainer . _getDropIndex . toSource ( ) . replace (
/\.screenX/g , '[this.treeStyleTab.positionProp]'
) . replace (
2010-11-18 23:00:42 -05:00
2010-03-23 13:58:23 -04:00
/\.width/g , '[this.treeStyleTab.sizeProp]'
)
) ;
}
else if ( 'getNewIndex' in b ) { // Firefox 3.6 or older
eval ( 'b.getNewIndex = ' +
b . getNewIndex . toSource ( ) . replace (
/\.screenX/g , '[this.treeStyleTab.positionProp]'
) . replace (
/\.width/g , '[this.treeStyleTab.sizeProp]'
)
) ;
}
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
eval ( 'b.moveTabForward = ' +
b . moveTabForward . toSource ( ) . replace (
'{' , '{ var nextTab;'
) . replace (
'tabPos < this.browsers.length - 1' ,
'nextTab = this.treeStyleTab.getNextSiblingTab(this.mCurrentTab)'
) . replace (
'tabPos + 1' , 'nextTab._tPos'
) . replace (
'this.moveTabTo(' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2007-11-17 00:20:26 -05:00
var descendant = this . treeStyleTab . getDescendantTabs ( nextTab ) ;
if ( descendant . length ) {
nextTab = descendant [ descendant . length - 1 ] ;
}
2009-03-26 11:30:00 -04:00
$ & ] ] >
2007-11-17 00:20:26 -05:00
) . replace (
'this.moveTabToStart();' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2009-09-30 01:42:48 -04:00
this . treeStyleTab . internallyTabMovingCount ++ ;
2007-11-17 00:20:26 -05:00
var parentTab = this . treeStyleTab . getParentTab ( this . mCurrentTab ) ;
if ( parentTab ) {
this . moveTabTo ( this . mCurrentTab , this . treeStyleTab . getFirstChildTab ( parentTab ) . _tPos ) ;
this . mCurrentTab . focus ( ) ;
}
else {
2008-03-03 04:07:02 -05:00
$ &
2007-11-17 00:20:26 -05:00
}
2009-09-30 01:42:48 -04:00
this . treeStyleTab . internallyTabMovingCount -- ;
2009-03-26 11:30:00 -04:00
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
eval ( 'b.moveTabBackward = ' +
b . moveTabBackward . toSource ( ) . replace (
'{' , '{ var prevTab;'
) . replace (
'tabPos > 0' ,
'prevTab = this.treeStyleTab.getPreviousSiblingTab(this.mCurrentTab)'
) . replace (
'tabPos - 1' , 'prevTab._tPos'
) . replace (
'this.moveTabToEnd();' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2009-09-30 01:42:48 -04:00
this . treeStyleTab . internallyTabMovingCount ++ ;
2007-11-17 00:20:26 -05:00
var parentTab = this . treeStyleTab . getParentTab ( this . mCurrentTab ) ;
if ( parentTab ) {
this . moveTabTo ( this . mCurrentTab , this . treeStyleTab . getLastChildTab ( parentTab ) . _tPos ) ;
this . mCurrentTab . focus ( ) ;
}
else {
2008-03-03 04:07:02 -05:00
$ &
2007-11-17 00:20:26 -05:00
}
2009-09-30 01:42:48 -04:00
this . treeStyleTab . internallyTabMovingCount -- ;
2009-03-26 11:30:00 -04:00
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2010-08-07 12:15:07 -04:00
if ( b . tabContainer . tabbrowser == b && '_handleKeyEvent' in b ) { // Firefox 4.0-
2010-03-01 07:02:37 -05:00
eval ( 'b._handleKeyEvent = ' +
b . _handleKeyEvent . toSource ( ) . replace (
'this.moveTabOver(aEvent);' ,
< ! [ CDATA [
if ( ! this . treeStyleTab . isVertical ||
! this . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
) . replace (
'this.moveTabForward();' ,
< ! [ CDATA [
if ( this . treeStyleTab . isVertical ||
! this . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
) . replace (
'this.moveTabBackward();' ,
< ! [ CDATA [
if ( this . treeStyleTab . isVertical ||
! this . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
)
) ;
}
2010-03-25 06:53:39 -04:00
else if ( '_keyEventHandler' in b ) { // Firefox 3.6 or older
2010-03-01 07:02:37 -05:00
eval ( 'b._keyEventHandler.handleEvent = ' +
2010-03-02 09:41:15 -05:00
b . _keyEventHandler . handleEvent . toSource ( ) . replace (
2010-03-01 07:02:37 -05:00
'this.tabbrowser.moveTabOver(aEvent);' ,
< ! [ CDATA [
if ( ! this . tabbrowser . treeStyleTab . isVertical ||
! this . tabbrowser . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
) . replace (
'this.tabbrowser.moveTabForward();' ,
< ! [ CDATA [
if ( this . tabbrowser . treeStyleTab . isVertical ||
! this . tabbrowser . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
) . replace (
'this.tabbrowser.moveTabBackward();' ,
< ! [ CDATA [
if ( this . tabbrowser . treeStyleTab . isVertical ||
! this . tabbrowser . treeStyleTab . moveTabLevel ( aEvent ) ) {
$ &
}
] ] >
)
) ;
}
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
eval ( 'b.loadTabs = ' +
b . loadTabs . toSource ( ) . replace (
'var tabNum = ' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2009-09-08 22:57:30 -04:00
if ( this . treeStyleTab . readiedToAttachNewTabGroup )
2007-11-17 00:20:26 -05:00
TreeStyleTabService . readyToOpenChildTab ( firstTabAdded || this . selectedTab , true ) ;
2009-03-26 11:30:00 -04:00
$ & ] ] >
2007-11-17 00:20:26 -05:00
) . replace (
'if (!aLoadInBackground)' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2007-11-17 00:20:26 -05:00
if ( TreeStyleTabService . checkToOpenChildTab ( this ) )
TreeStyleTabService . stopToOpenChildTab ( this ) ;
2009-03-26 11:30:00 -04:00
$ & ] ] >
2009-06-18 05:05:36 -04:00
) . replace (
'this.selectedTab = firstTabAdded;' ,
< ! [ CDATA [
this . selectedTab = aURIs [ 0 ] . indexOf ( 'about:treestyletab-group' ) < 0 ?
firstTabAdded :
TreeStyleTabService . getNextTab ( firstTabAdded ) ;
] ] >
2007-11-17 00:20:26 -05:00
)
) ;
2007-11-14 14:34:36 -05:00
2007-11-30 14:22:34 -05:00
eval ( 'b.createTooltip = ' +
b . createTooltip . toSource ( ) . replace (
2009-07-31 06:09:11 -04:00
'if ("mOverCloseButton" in tn && tn.mOverCloseButton) {' ,
2009-03-26 11:30:00 -04:00
< ! [ CDATA [
2009-12-17 03:47:02 -05:00
if ( TreeStyleTabService . getTabBrowserFromChild ( tn ) &&
TreeStyleTabService . getTabBrowserFromChild ( tn ) . treeStyleTab . handleTooltip ( event , tn ) ) {
2007-11-30 14:22:34 -05:00
return true ;
}
2009-07-31 06:09:11 -04:00
else $ & ] ] >
2007-11-30 14:22:34 -05:00
)
) ;
2008-12-01 21:51:41 -05:00
if ( '_beginRemoveTab' in b ) {
2009-12-19 00:13:04 -05:00
eval ( 'b._beginRemoveTab = ' +
b . _beginRemoveTab . toSource ( ) . replace (
'if (l == 1) {' ,
2009-12-25 06:19:50 -05:00
'if (l == 1 || this.treeStyleTab.shouldCloseLastTabSubtreeOf(aTab)) {'
2009-12-19 00:13:04 -05:00
) . replace (
'this._removingTabs.length == 0' ,
2009-12-25 06:19:50 -05:00
'(this.treeStyleTab.shouldCloseLastTabSubtreeOf(aTab) || $&)'
2009-12-19 00:13:04 -05:00
)
) ;
2008-12-01 21:51:41 -05:00
}
2009-12-18 00:52:47 -05:00
eval ( 'b.removeCurrentTab = ' + b . removeCurrentTab . toSource ( ) . replace (
'{' ,
2009-12-25 06:19:50 -05:00
'{ if (!this.treeStyleTab.warnAboutClosingTabSubtreeOf(this.selectedTab)) return;'
2009-12-18 00:52:47 -05:00
) ) ;
2010-09-14 03:39:17 -04:00
let ( tabs = this . getAllTabsArray ( b ) ) {
2010-03-03 10:38:35 -05:00
for each ( let tab in tabs )
2009-05-13 02:09:17 -04:00
{
2010-03-03 10:38:35 -05:00
this . initTab ( tab ) ;
2009-05-13 02:09:17 -04:00
}
}
2007-11-14 14:34:36 -05:00
2010-11-29 03:24:45 -05:00
this . onPrefChange ( 'extensions.treestyletab.maxTreeLevel' ) ;
2009-05-13 02:09:17 -04:00
this . onPrefChange ( 'extensions.treestyletab.tabbar.style' ) ;
2010-07-29 21:52:32 -04:00
this . onPrefChange ( 'extensions.treestyletab.twisty.style' ) ;
2009-05-13 02:09:17 -04:00
this . onPrefChange ( 'extensions.treestyletab.showBorderForFirstTab' ) ;
this . onPrefChange ( 'extensions.treestyletab.tabbar.invertTabContents' ) ;
this . onPrefChange ( 'extensions.treestyletab.tabbar.invertClosebox' ) ;
2010-05-02 00:30:51 -04:00
this . onPrefChange ( 'extensions.treestyletab.animation.enabled' ) ;
2009-05-13 02:09:17 -04:00
2010-03-25 20:20:51 -04:00
var tabContextMenu = b . tabContextMenu ||
document . getAnonymousElementByAttribute ( b , 'anonid' , 'tabContextMenu' ) ;
2009-07-08 06:40:51 -04:00
tabContextMenu . addEventListener ( 'popupshowing' , this , false ) ;
if ( ! ( 'MultipleTabService' in window ) ) {
window . setTimeout ( function ( aSelf , aTabBrowser , aPopup ) {
let suffix = '-tabbrowser-' + ( aTabBrowser . id || 'instance-' + parseInt ( Math . random ( ) * 65000 ) ) ;
[
aSelf . kMENUITEM _RELOADSUBTREE ,
aSelf . kMENUITEM _RELOADCHILDREN ,
aSelf . kMENUITEM _REMOVESUBTREE ,
aSelf . kMENUITEM _REMOVECHILDREN ,
aSelf . kMENUITEM _COLLAPSEEXPAND _SEPARATOR ,
aSelf . kMENUITEM _COLLAPSE ,
aSelf . kMENUITEM _EXPAND ,
aSelf . kMENUITEM _AUTOHIDE _SEPARATOR ,
aSelf . kMENUITEM _AUTOHIDE ,
aSelf . kMENUITEM _FIXED ,
aSelf . kMENUITEM _BOOKMARKSUBTREE
] . forEach ( function ( aID ) {
let item = document . getElementById ( aID ) . cloneNode ( true ) ;
item . setAttribute ( 'id' , item . getAttribute ( 'id' ) + suffix ) ;
let refNode = void ( 0 ) ;
let insertAfter = item . getAttribute ( 'multipletab-insertafter' ) ;
if ( insertAfter ) {
try {
eval ( 'refNode = (' + insertAfter + ').nextSibling' ) ;
2009-05-12 12:56:39 -04:00
}
2009-07-08 06:40:51 -04:00
catch ( e ) {
2009-05-12 12:56:39 -04:00
}
2009-07-08 06:40:51 -04:00
}
let insertBefore = item . getAttribute ( 'multipletab-insertbefore' ) ;
if ( refNode === void ( 0 ) && insertBefore ) {
try {
eval ( 'refNode = ' + insertBefore ) ;
}
catch ( e ) {
}
}
aPopup . insertBefore ( item , refNode || null ) ;
} ) ;
2009-07-06 05:21:06 -04:00
tabContextMenu = null ;
2009-07-08 06:40:51 -04:00
} , 0 , this , b , tabContextMenu ) ;
2009-05-12 12:56:39 -04:00
}
2007-11-17 00:20:26 -05:00
2009-12-18 01:08:42 -05:00
let ( removeTabItem = document . getAnonymousElementByAttribute ( b , 'id' , 'context_closeTab' ) ) {
if ( removeTabItem ) {
removeTabItem . setAttribute (
'oncommand' ,
removeTabItem . getAttribute ( 'oncommand' ) . replace (
/(tabbrowser\.removeTab\(([^\)]+)\))/ ,
2009-12-25 06:19:50 -05:00
'if (tabbrowser.treeStyleTab.warnAboutClosingTabSubtreeOf($2)) $1'
2009-12-18 01:08:42 -05:00
)
) ;
}
}
2010-11-30 19:33:07 -05:00
this . ObserverService . addObserver ( this , this . kTOPIC _INDENT _MODIFIED , false ) ;
this . ObserverService . addObserver ( this , this . kTOPIC _COLLAPSE _EXPAND _ALL , false ) ;
2010-07-05 09:29:32 -04:00
this . ObserverService . addObserver ( this , 'private-browsing-change-granted' , false ) ;
2010-11-30 19:33:07 -05:00
this . ObserverService . addObserver ( this , this . kTOPIC _CHANGE _TREEVIEW _AVAILABILITY , false ) ;
2007-11-17 00:20:26 -05:00
this . addPrefListener ( this ) ;
2009-05-13 02:09:17 -04:00
2009-09-03 03:31:49 -04:00
this . autoHide ;
2009-09-03 02:24:06 -04:00
2010-09-10 06:21:26 -04:00
this . fireTabbarPositionEvent ( false , 'top' , position ) ; /* PUBLIC API */
2009-12-25 04:49:47 -05:00
2009-05-13 02:09:17 -04:00
b = null ;
2010-02-03 08:43:39 -05:00
this . startRendering ( ) ;
2007-11-14 14:34:36 -05:00
} ,
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
initTab : function TSTBrowser _initTab ( aTab )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
if ( ! aTab . hasAttribute ( this . kID ) ) {
2008-11-09 23:48:11 -05:00
var id = this . getTabValue ( aTab , this . kID ) || this . makeNewId ( ) ;
2009-09-29 10:31:02 -04:00
aTab . setAttribute ( this . kID , id ) ;
2009-09-29 13:07:02 -04:00
aTab . setAttribute ( this . kSUBTREE _COLLAPSED , true ) ;
2010-11-30 02:45:03 -05:00
aTab . setAttribute ( this . kALLOW _COLLAPSE , true ) ;
2009-09-29 10:31:02 -04:00
window . setTimeout ( function ( aSelf ) {
2010-03-03 08:30:49 -05:00
if ( ! aSelf . getTabValue ( aTab , aSelf . kID ) ) {
2009-09-29 10:31:02 -04:00
aSelf . setTabValue ( aTab , aSelf . kID , id ) ;
2010-03-24 11:38:08 -04:00
if ( ! ( id in aSelf . tabsHash ) )
aSelf . tabsHash [ id ] = aTab ;
2010-03-03 08:30:49 -05:00
}
2009-09-29 10:31:02 -04:00
} , 0 , this ) ;
2010-03-24 11:38:08 -04:00
if ( ! ( id in this . tabsHash ) )
this . tabsHash [ id ] = aTab ;
2007-11-17 00:20:26 -05:00
}
aTab . _ _treestyletab _ _linkedTabBrowser = this . mTabBrowser ;
this . initTabAttributes ( aTab ) ;
this . initTabContents ( aTab ) ;
aTab . setAttribute ( this . kNEST , 0 ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-25 04:15:25 -05:00
isTabInitialized : function TSTBrowser _isTabInitialized ( aTab )
{
return aTab . getAttribute ( this . kID ) ;
} ,
2009-12-25 03:34:52 -05:00
ensureTabInitialized : function TSTBrowser _ensureTabInitialized ( aTab )
2009-03-31 14:25:49 -04:00
{
2009-12-25 04:15:25 -05:00
if ( ! aTab || this . isTabInitialized ( aTab ) ) return ;
2009-03-31 14:25:49 -04:00
this . initTab ( aTab ) ;
} ,
2008-03-09 23:51:21 -04:00
2009-12-25 03:34:52 -05:00
initTabAttributes : function TSTBrowser _initTabAttributes ( aTab )
2007-11-14 14:34:36 -05:00
{
2010-05-08 01:37:41 -04:00
var pos = this . currentTabbarPosition ;
2007-11-17 00:20:26 -05:00
if ( pos == 'left' || pos == 'right' ) {
aTab . setAttribute ( 'align' , 'stretch' ) ;
aTab . removeAttribute ( 'maxwidth' ) ;
aTab . removeAttribute ( 'minwidth' ) ;
aTab . removeAttribute ( 'width' ) ;
aTab . removeAttribute ( 'flex' ) ;
aTab . maxWidth = 65000 ;
aTab . minWidth = 0 ;
2009-12-15 03:33:03 -05:00
if ( this . getTreePref ( 'compatibility.TMP' ) )
aTab . setAttribute ( 'dir' , 'ltr' ) ; // Tab Mix Plus
2007-11-17 00:20:26 -05:00
}
else {
aTab . removeAttribute ( 'align' ) ;
2010-11-26 00:03:09 -05:00
aTab . removeAttribute ( 'maxwidth' ) ;
aTab . removeAttribute ( 'minwidth' ) ;
2010-11-24 09:46:57 -05:00
if ( 'mTabMinWidth' in this . mTabBrowser . mTabContainer ) { // Firefox 3.6 or older
aTab . setAttribute ( 'maxwidth' , 250 ) ;
aTab . setAttribute ( 'minwidth' , this . mTabBrowser . mTabContainer . mTabMinWidth ) ;
aTab . setAttribute ( 'width' , '0' ) ;
aTab . maxWidth = 250 ;
aTab . minWidth = this . mTabBrowser . mTabContainer . mTabMinWidth ;
aTab . setAttribute ( 'flex' , 100 ) ;
}
2009-12-15 03:33:03 -05:00
if ( this . getTreePref ( 'compatibility.TMP' ) )
aTab . removeAttribute ( 'dir' ) ; // Tab Mix Plus
2007-11-14 14:34:36 -05:00
}
} ,
2007-11-17 00:20:26 -05:00
2009-12-25 03:34:52 -05:00
initTabContents : function TSTBrowser _initTabContents ( aTab )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
var icon = document . getAnonymousElementByAttribute ( aTab , 'class' , 'tab-icon' ) ;
2010-09-15 00:51:50 -04:00
var twisty = document . getAnonymousElementByAttribute ( aTab , 'class' , this . kTWISTY ) ;
if ( icon && ! twisty ) {
twisty = document . createElement ( 'image' ) ;
2007-11-17 00:20:26 -05:00
twisty . setAttribute ( 'class' , this . kTWISTY ) ;
2010-09-15 00:51:50 -04:00
let container = document . createElement ( 'hbox' ) ;
2007-11-17 00:20:26 -05:00
container . setAttribute ( 'class' , this . kTWISTY _CONTAINER ) ;
container . appendChild ( twisty ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
icon . appendChild ( container ) ;
2007-11-14 14:34:36 -05:00
2010-09-15 00:51:50 -04:00
let marker = document . createElement ( 'image' ) ;
2007-11-17 00:20:26 -05:00
marker . setAttribute ( 'class' , this . kDROP _MARKER ) ;
container = document . createElement ( 'hbox' ) ;
container . setAttribute ( 'class' , this . kDROP _MARKER _CONTAINER ) ;
container . appendChild ( marker ) ;
icon . appendChild ( container ) ;
2007-11-14 14:34:36 -05:00
}
2010-09-15 00:51:50 -04:00
var label = this . getTabLabel ( aTab ) ;
var counter = document . getAnonymousElementByAttribute ( aTab , 'class' , this . kCOUNTER _CONTAINER ) ;
if ( label && label . parentNode != aTab && ! counter ) {
counter = document . createElement ( 'hbox' ) ;
2007-11-17 00:20:26 -05:00
counter . setAttribute ( 'class' , this . kCOUNTER _CONTAINER ) ;
2010-09-15 00:51:50 -04:00
let startParen = counter . appendChild ( document . createElement ( 'label' ) ) ;
startParen . setAttribute ( 'class' , this . kCOUNTER _PAREN ) ;
startParen . setAttribute ( 'value' , '(' ) ;
2010-01-31 23:06:09 -05:00
2010-09-15 00:51:50 -04:00
let counterLabel = counter . appendChild ( document . createElement ( 'label' ) ) ;
counterLabel . setAttribute ( 'class' , this . kCOUNTER ) ;
counterLabel . setAttribute ( 'value' , '0' ) ;
2010-01-31 23:06:09 -05:00
2010-09-15 00:51:50 -04:00
let endParen = counter . appendChild ( document . createElement ( 'label' ) ) ;
endParen . setAttribute ( 'class' , this . kCOUNTER _PAREN ) ;
endParen . setAttribute ( 'value' , ')' ) ;
2007-11-17 00:20:26 -05:00
2010-09-15 00:51:50 -04:00
label . parentNode . insertBefore ( counter , label . nextSibling ) ;
2007-11-14 14:34:36 -05:00
}
2010-09-15 00:51:50 -04:00
2007-11-17 00:20:26 -05:00
this . initTabContentsOrder ( aTab ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-25 03:34:52 -05:00
initTabContentsOrder : function TSTBrowser _initTabContentsOrder ( aTab )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
var label = this . getTabLabel ( aTab ) ;
var close = this . getTabClosebox ( aTab ) ;
2009-05-11 19:19:11 -04:00
var inverted = this . mTabBrowser . getAttribute ( this . kTAB _CONTENTS _INVERTED ) == 'true' ;
2009-04-28 00:11:22 -04:00
var nodes = Array . slice ( document . getAnonymousNodes ( aTab ) ) ;
2009-05-12 11:09:49 -04:00
// reset order
nodes . forEach ( function ( aNode , aIndex ) {
aNode . setAttribute ( 'ordinal' , aIndex ) ;
} , this ) ;
// rearrange top-level contents
2009-04-28 00:11:22 -04:00
nodes . splice ( nodes . indexOf ( close ) , 1 ) ;
if ( inverted ) {
if ( this . mTabBrowser . getAttribute ( this . kCLOSEBOX _INVERTED ) == 'true' )
nodes . splice ( nodes . indexOf ( label . parentNode ) + 1 , 0 , close ) ;
else
nodes . splice ( nodes . indexOf ( label . parentNode ) , 0 , close ) ;
}
else {
if ( this . mTabBrowser . getAttribute ( this . kCLOSEBOX _INVERTED ) == 'true' )
nodes . splice ( nodes . indexOf ( label . parentNode ) , 0 , close ) ;
else
nodes . splice ( nodes . indexOf ( label . parentNode ) + 1 , 0 , close ) ;
}
2009-04-20 07:38:58 -04:00
var count = nodes . length ;
Array . slice ( nodes ) . reverse ( )
2009-04-20 07:25:14 -04:00
. forEach ( function ( aNode , aIndex ) {
2009-04-28 00:11:22 -04:00
aNode . setAttribute ( 'ordinal' , ( count - aIndex + 1 ) * 100 ) ;
2009-04-20 07:25:14 -04:00
} , this ) ;
2007-11-14 14:34:36 -05:00
2009-05-12 11:09:49 -04:00
// rearrange contents in "tab-image-middle"
2009-04-20 07:38:58 -04:00
nodes = Array . slice ( label . parentNode . childNodes ) ;
2010-09-15 00:51:50 -04:00
if ( inverted )
nodes . reverse ( ) ;
var counter = document . getAnonymousElementByAttribute ( aTab , 'class' , this . kCOUNTER _CONTAINER ) ;
if ( counter ) {
nodes . splice ( nodes . indexOf ( counter ) , 1 ) ;
nodes . splice ( nodes . indexOf ( label ) + 1 , 0 , counter ) ;
}
2009-04-20 07:38:58 -04:00
count = nodes . length ;
2009-04-28 00:11:22 -04:00
nodes . reverse ( ) . forEach ( function ( aNode , aIndex ) {
if ( aNode . getAttribute ( 'class' ) == 'informationaltab-thumbnail-container' )
return ;
aNode . setAttribute ( 'ordinal' , ( count - aIndex + 1 ) * 100 ) ;
} , this ) ;
2007-11-14 14:34:36 -05:00
} ,
2008-03-03 04:21:33 -05:00
2009-12-25 03:34:52 -05:00
updateInvertedTabContentsOrder : function TSTBrowser _updateInvertedTabContentsOrder ( aAll )
2008-03-03 04:21:33 -05:00
{
2009-05-12 11:09:49 -04:00
if ( ! this . getTreePref ( 'tabbar.invertTabContents' ) ) return ;
2008-03-03 04:21:33 -05:00
window . setTimeout ( function ( aSelf ) {
var b = aSelf . mTabBrowser ;
2010-09-14 03:39:17 -04:00
var tabs = aAll ? aSelf . getAllTabsArray ( b ) : [ b . selectedTab ] ;
2009-05-12 11:09:49 -04:00
tabs . forEach ( function ( aTab ) {
aSelf . initTabContentsOrder ( aTab ) ;
} ) ;
2009-05-13 02:09:17 -04:00
b = null ;
tabs = null ;
2008-03-03 04:21:33 -05:00
} , 0 , this ) ;
} ,
2008-03-08 03:57:17 -05:00
2010-05-08 01:37:41 -04:00
initTabbar : function TSTBrowser _initTabbar ( aNewPosition , aOldPosition )
2007-11-14 14:34:36 -05:00
{
2009-12-21 00:45:07 -05:00
this . stopRendering ( ) ;
2007-11-14 14:34:36 -05:00
var b = this . mTabBrowser ;
2010-05-08 01:37:41 -04:00
var pos = aNewPosition || this . getPositionFlag ( this . currentTabbarPosition ) ;
2008-10-17 11:47:45 -04:00
if ( b . getAttribute ( 'id' ) != 'content' &&
! this . getTreePref ( 'tabbar.position.subbrowser.enabled' ) ) {
2010-02-03 08:43:39 -05:00
pos = this . kTABBAR _TOP ;
2007-11-14 14:34:36 -05:00
}
2010-02-03 08:43:39 -05:00
aOldPosition = aOldPosition || pos ;
// We have to use CSS property hack instead, because the stopRendering()
// doesn't effect on the first time of startup.
// * This hack works in a "stop"-"start" pair, so, people never see the side effect.
// * This hack works only when "ordinal" properties are modified.
// So, this is just for the case: "right" or "bottom" tab bar on the startup.
if (
pos != aOldPosition &&
(
( ( pos & this . kTABBAR _REGULAR ) && ( aOldPosition & this . kTABBAR _INVERTED ) ) ||
( ( pos & this . kTABBAR _INVERTED ) && ( aOldPosition & this . kTABBAR _REGULAR ) )
)
)
b . style . visibility = 'hidden' ;
2007-11-14 14:34:36 -05:00
2010-03-23 09:33:00 -04:00
var strip = this . tabStrip ;
2010-03-25 23:17:16 -04:00
var placeHolder = this . tabStripPlaceHolder || strip ;
2009-12-24 10:13:04 -05:00
var splitter = this . _ensureNewSplitter ( ) ;
2009-03-30 12:36:54 -04:00
var toggler = document . getAnonymousElementByAttribute ( b , 'class' , this . kTABBAR _TOGGLER ) ;
2010-03-23 13:58:23 -04:00
var indicator = b . mTabDropIndicatorBar || b . tabContainer . _tabDropIndicator ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
// Tab Mix Plus
2009-12-15 03:33:03 -05:00
var scrollFrame , newTabBox , tabBarMode ;
if ( this . getTreePref ( 'compatibility.TMP' ) ) {
2009-12-20 22:24:41 -05:00
scrollFrame = document . getAnonymousElementByAttribute ( b . mTabContainer , 'class' , 'tabs-frame' ) ||
document . getAnonymousElementByAttribute ( b . mTabContainer , 'anonid' , 'scroll-tabs-frame' ) ;
2009-12-15 03:33:03 -05:00
newTabBox = document . getAnonymousElementByAttribute ( b . mTabContainer , 'id' , 'tabs-newbutton-box' ) ;
tabBarMode = this . getPref ( 'extensions.tabmix.tabBarMode' ) ;
}
2007-11-14 14:34:36 -05:00
2008-03-03 01:00:59 -05:00
// All-in-One Sidebar
2010-03-23 09:33:00 -04:00
var toolboxContainer = document . getAnonymousElementByAttribute ( strip , 'anonid' , 'aiostbx-toolbox-tableft' ) ;
2008-03-03 01:00:59 -05:00
if ( toolboxContainer ) toolboxContainer = toolboxContainer . parentNode ;
2009-03-16 07:58:43 -04:00
var scrollInnerBox = b . mTabContainer . mTabstrip . _scrollbox ?
document . getAnonymousNodes ( b . mTabContainer . mTabstrip . _scrollbox ) [ 0 ] :
scrollFrame ; // Tab Mix Plus
2010-03-28 14:22:15 -04:00
this . removeTabbrowserAttribute ( this . kRESIZING , b ) ;
2007-11-14 14:34:36 -05:00
2010-03-25 23:17:16 -04:00
this . removeTabStripAttribute ( 'width' ) ;
2009-07-07 04:30:30 -04:00
b . mPanelContainer . removeAttribute ( 'width' ) ;
2009-07-07 21:41:37 -04:00
var delayedPostProcess ;
2007-11-17 00:20:26 -05:00
if ( pos & this . kTABBAR _VERTICAL ) {
2009-07-07 11:56:38 -04:00
2009-12-18 07:57:21 -05:00
this . collapseTarget = 'top' ;
2007-11-17 00:20:26 -05:00
this . positionProp = 'screenY' ;
this . sizeProp = 'height' ;
this . invertedPositionProp = 'screenX' ;
this . invertedSizeProp = 'width' ;
2007-11-14 14:34:36 -05:00
2008-10-17 11:47:45 -04:00
b . mTabBox . orient = splitter . orient = 'horizontal' ;
2010-03-23 09:33:00 -04:00
strip . orient =
2010-03-25 23:17:16 -04:00
placeHolder . orient =
2009-03-30 12:36:54 -04:00
toggler . orient =
2007-11-17 00:20:26 -05:00
b . mTabContainer . orient =
b . mTabContainer . mTabstrip . orient =
b . mTabContainer . mTabstrip . parentNode . orient = 'vertical' ;
b . mTabContainer . setAttribute ( 'align' , 'stretch' ) ; // for Mac OS X
2009-12-15 03:58:29 -05:00
if ( scrollInnerBox )
scrollInnerBox . removeAttribute ( 'flex' ) ;
2007-11-14 14:34:36 -05:00
2009-12-15 03:33:03 -05:00
if ( this . getTreePref ( 'compatibility.TMP' ) && scrollFrame ) { // Tab Mix Plus
2009-04-28 00:55:59 -04:00
document . getAnonymousNodes ( scrollFrame ) [ 0 ] . removeAttribute ( 'flex' ) ;
2007-11-17 00:20:26 -05:00
scrollFrame . parentNode . orient =
scrollFrame . orient = 'vertical' ;
newTabBox . orient = 'horizontal' ;
if ( tabBarMode == 2 )
this . setPref ( 'extensions.tabmix.tabBarMode' , 1 ) ;
2007-11-14 14:34:36 -05:00
}
2008-03-03 01:00:59 -05:00
if ( toolboxContainer )
toolboxContainer . orient = 'vertical' ;
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kMODE , 'vertical' ) ;
2009-07-07 11:56:38 -04:00
2010-04-22 04:12:31 -04:00
let width = this . maxTabbarWidth ( this . getTreePref ( 'tabbar.width' ) , b ) ;
this . setTabStripAttribute ( 'width' , width ) ;
2010-03-25 23:17:16 -04:00
this . removeTabStripAttribute ( 'height' ) ;
2009-07-07 11:56:38 -04:00
b . mPanelContainer . removeAttribute ( 'height' ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
if ( pos == this . kTABBAR _RIGHT ) {
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTABBAR _POSITION , 'right' ) ;
2009-05-11 03:19:37 -04:00
if ( this . getTreePref ( 'tabbar.invertTab' ) ) {
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTAB _INVERTED , 'true' ) ;
2009-12-18 07:57:21 -05:00
this . indentTarget = 'right' ;
2007-11-17 00:20:26 -05:00
}
else {
2010-03-28 14:22:15 -04:00
this . removeTabbrowserAttribute ( this . kTAB _INVERTED ) ;
2009-12-18 07:57:21 -05:00
this . indentTarget = 'left' ;
2007-11-17 00:20:26 -05:00
}
2009-07-07 21:41:37 -04:00
delayedPostProcess = function ( aSelf , aTabBrowser , aSplitter , aToggler ) {
2007-11-17 00:20:26 -05:00
/ * i n F i r e f o x 3 , t h e w i d t h o f t h e r i g h t s i d e t a b b a r
unexpectedly becomes 0 on the startup . so , we have
to set the width again . * /
2010-04-22 04:12:31 -04:00
aSelf . setTabStripAttribute ( 'width' , width ) ;
2010-03-23 13:58:23 -04:00
indicator . setAttribute ( 'ordinal' , 1 ) ;
2010-03-25 23:17:16 -04:00
aSelf . setTabStripAttribute ( 'ordinal' , 30 ) ;
2009-05-13 02:09:17 -04:00
aSplitter . setAttribute ( 'ordinal' , 20 ) ;
aToggler . setAttribute ( 'ordinal' , 40 ) ;
aTabBrowser . mPanelContainer . setAttribute ( 'ordinal' , 10 ) ;
aSplitter . setAttribute ( 'collapse' , 'after' ) ;
2009-07-07 21:41:37 -04:00
} ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
else {
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTABBAR _POSITION , 'left' ) ;
this . removeTabbrowserAttribute ( this . kTAB _INVERTED ) ;
2009-12-18 07:57:21 -05:00
this . indentTarget = 'left' ;
2009-07-07 21:41:37 -04:00
delayedPostProcess = function ( aSelf , aTabBrowser , aSplitter , aToggler ) {
2010-03-23 13:58:23 -04:00
indicator . setAttribute ( 'ordinal' , 1 ) ;
2010-03-25 23:17:16 -04:00
aSelf . setTabStripAttribute ( 'ordinal' , 10 ) ;
2009-05-13 02:09:17 -04:00
aSplitter . setAttribute ( 'ordinal' , 20 ) ;
aToggler . setAttribute ( 'ordinal' , 5 ) ;
aTabBrowser . mPanelContainer . setAttribute ( 'ordinal' , 30 ) ;
aSplitter . setAttribute ( 'collapse' , 'before' ) ;
2009-07-07 21:41:37 -04:00
} ;
2007-11-14 14:34:36 -05:00
}
}
2007-11-17 00:20:26 -05:00
else {
2009-12-18 07:57:21 -05:00
this . collapseTarget = 'left' ;
2007-11-17 00:20:26 -05:00
this . positionProp = 'screenX' ;
this . sizeProp = 'width' ;
this . invertedPositionProp = 'screenY' ;
this . invertedSizeProp = 'height' ;
2007-11-14 14:34:36 -05:00
2008-10-17 11:47:45 -04:00
b . mTabBox . orient = splitter . orient = 'vertical' ;
2010-03-23 09:33:00 -04:00
strip . orient =
2010-03-25 23:17:16 -04:00
placeHolder . orient =
2009-03-30 12:36:54 -04:00
toggler . orient =
2007-11-17 00:20:26 -05:00
b . mTabContainer . orient =
b . mTabContainer . mTabstrip . orient =
b . mTabContainer . mTabstrip . parentNode . orient = 'horizontal' ;
b . mTabContainer . removeAttribute ( 'align' ) ; // for Mac OS X
2009-12-15 03:58:29 -05:00
if ( scrollInnerBox )
scrollInnerBox . setAttribute ( 'flex' , 1 ) ;
2007-11-14 14:34:36 -05:00
2009-12-15 03:33:03 -05:00
if ( this . getTreePref ( 'compatibility.TMP' ) && scrollFrame ) { // Tab Mix Plus
2009-04-28 00:55:59 -04:00
document . getAnonymousNodes ( scrollFrame ) [ 0 ] . setAttribute ( 'flex' , 1 ) ;
2007-11-17 00:20:26 -05:00
scrollFrame . parentNode . orient =
scrollFrame . orient = 'horizontal' ;
newTabBox . orient = 'vertical' ;
}
2007-11-14 14:34:36 -05:00
2008-03-03 01:00:59 -05:00
if ( toolboxContainer )
toolboxContainer . orient = 'horizontal' ;
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kMODE , this . getTreePref ( 'tabbar.multirow' ) ? 'multirow' : 'horizontal' ) ;
this . removeTabbrowserAttribute ( this . kTAB _INVERTED ) ;
2009-07-07 11:56:38 -04:00
2007-11-17 00:20:26 -05:00
if ( pos == this . kTABBAR _BOTTOM ) {
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTABBAR _POSITION , 'bottom' ) ;
2009-12-18 07:57:21 -05:00
this . indentTarget = 'bottom' ;
2009-07-07 21:41:37 -04:00
delayedPostProcess = function ( aSelf , aTabBrowser , aSplitter , aToggler ) {
2010-03-23 13:58:23 -04:00
indicator . setAttribute ( 'ordinal' , 1 ) ;
2010-03-25 23:17:16 -04:00
aSelf . setTabStripAttribute ( 'ordinal' , 30 ) ;
2009-08-25 04:36:50 -04:00
aSplitter . setAttribute ( 'ordinal' , 20 ) ;
aToggler . setAttribute ( 'ordinal' , 40 ) ;
2009-05-13 02:09:17 -04:00
aTabBrowser . mPanelContainer . setAttribute ( 'ordinal' , 10 ) ;
2009-07-07 21:41:37 -04:00
} ;
2007-11-17 00:20:26 -05:00
}
else {
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTABBAR _POSITION , 'top' ) ;
2009-12-18 07:57:21 -05:00
this . indentTarget = 'top' ;
2009-07-07 21:41:37 -04:00
delayedPostProcess = function ( aSelf , aTabBrowser , aSplitter , aToggler ) {
2010-03-23 13:58:23 -04:00
indicator . setAttribute ( 'ordinal' , 1 ) ;
2010-03-25 23:17:16 -04:00
aSelf . setTabStripAttribute ( 'ordinal' , 10 ) ;
2009-05-13 02:09:17 -04:00
aSplitter . setAttribute ( 'ordinal' , 20 ) ;
aToggler . setAttribute ( 'ordinal' , 5 ) ;
aTabBrowser . mPanelContainer . setAttribute ( 'ordinal' , 30 ) ;
2009-07-07 21:41:37 -04:00
} ;
2007-11-14 14:34:36 -05:00
}
}
2009-04-07 13:19:30 -04:00
2010-09-14 03:39:17 -04:00
var tabs = this . getAllTabsArray ( b ) ;
2010-08-13 13:14:46 -04:00
tabs . forEach ( function ( aTab ) {
aTab . style . removeProperty ( this . indentCSSProp ) ;
aTab . style . removeProperty ( this . collapseCSSProp ) ;
} , this ) ;
2009-12-18 07:57:21 -05:00
this . indentProp = this . getTreePref ( 'indent.property' ) ;
2010-08-13 13:14:46 -04:00
this . indentCSSProp = this . indentProp + '-' + this . indentTarget ;
this . collapseCSSProp = 'margin-' + this . collapseTarget ;
2009-12-18 07:57:21 -05:00
2010-08-13 13:14:46 -04:00
tabs . forEach ( function ( aTab ) {
2009-04-07 13:19:30 -04:00
this . updateTabCollapsed ( aTab , aTab . getAttribute ( this . kCOLLAPSED ) == 'true' , true ) ;
} , this ) ;
2009-05-13 02:09:17 -04:00
2009-08-26 05:33:54 -04:00
this . updateTabbarState ( ) ;
2009-07-07 21:41:37 -04:00
window . setTimeout ( function ( aSelf , aTabBrowser , aSplitter , aToggler ) {
delayedPostProcess ( aSelf , aTabBrowser , aSplitter , aToggler ) ;
2009-07-21 23:35:54 -04:00
aSelf . updateTabbarOverflow ( ) ;
2010-04-30 00:49:00 -04:00
aSelf . updateAllTabsButton ( aTabBrowser ) ;
2009-07-07 21:41:37 -04:00
delayedPostProcess = null ;
2010-02-03 08:43:39 -05:00
aSelf . mTabBrowser . style . visibility = '' ;
aSelf . startRendering ( ) ;
2009-07-07 21:41:37 -04:00
} , 0 , this , b , splitter , toggler ) ;
2009-07-07 21:37:00 -04:00
2009-05-13 02:09:17 -04:00
b = null ;
pos = null ;
splitter = null ;
toggler = null ;
scrollFrame = null ;
newTabBox = null
tabBarMode = null ;
toolboxContainer = null ;
scrollInnerBox = null ;
scrollInnerBox = null ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-24 10:13:46 -05:00
2009-12-25 15:48:14 -05:00
_ensureNewSplitter : function TSTBrowser _ _ensureNewSplitter ( )
2009-12-24 10:13:04 -05:00
{
2010-03-23 15:10:53 -04:00
var splitter = this . splitter ;
2009-12-24 10:13:04 -05:00
// We always have to re-create splitter, because its "collapse"
// behavior becomes broken by repositioning of the tab bar.
if ( splitter ) {
2010-03-23 15:10:53 -04:00
try {
2010-09-12 23:54:04 -04:00
splitter . removeEventListener ( 'mousedown' , TreeStyleTabService , false ) ;
splitter . removeEventListener ( 'mouseup' , TreeStyleTabService , false ) ;
splitter . removeEventListener ( 'dblclick' , TreeStyleTabService , false ) ;
2010-03-23 15:10:53 -04:00
}
catch ( e ) {
}
2010-03-02 09:40:12 -05:00
let oldSplitter = splitter ;
splitter = oldSplitter . cloneNode ( true ) ;
oldSplitter . parentNode . removeChild ( oldSplitter ) ;
}
else {
splitter = document . createElement ( 'splitter' ) ;
splitter . setAttribute ( 'state' , 'open' ) ;
splitter . appendChild ( document . createElement ( 'grippy' ) ) ;
2009-12-24 10:13:04 -05:00
}
2010-03-02 09:40:12 -05:00
var splitterClass = splitter . getAttribute ( 'class' ) || '' ;
if ( splitterClass . indexOf ( this . kSPLITTER ) < 0 )
splitterClass += ( splitterClass ? ' ' : '' ) + this . kSPLITTER ;
splitter . setAttribute ( 'class' , splitterClass ) ;
2009-12-24 10:13:04 -05:00
2010-09-12 23:54:04 -04:00
splitter . addEventListener ( 'mousedown' , TreeStyleTabService , false ) ;
splitter . addEventListener ( 'mouseup' , TreeStyleTabService , false ) ;
splitter . addEventListener ( 'dblclick' , TreeStyleTabService , false ) ;
2010-03-23 15:10:53 -04:00
2009-12-24 10:13:04 -05:00
var ref = this . mTabBrowser . mPanelContainer ;
ref . parentNode . insertBefore ( splitter , ref ) ;
return splitter ;
} ,
2009-12-24 10:13:46 -05:00
2009-12-25 03:34:52 -05:00
updateTabbarState : function TSTBrowser _updateTabbarState ( )
2009-07-07 11:56:38 -04:00
{
2009-12-21 00:45:07 -05:00
this . stopRendering ( ) ;
2009-07-07 11:56:38 -04:00
var b = this . mTabBrowser ;
2009-07-07 20:09:13 -04:00
var orient ;
2010-04-06 21:37:58 -04:00
var toggleTabsOnTop = document . getElementById ( 'cmd_ToggleTabsOnTop' ) ;
2009-07-07 11:56:38 -04:00
if ( this . isVertical ) {
2009-07-07 20:09:13 -04:00
orient = 'vertical' ;
2010-06-27 00:01:15 -04:00
this . setTabbrowserAttribute ( this . kFIXED , this . isFixed ? 'true' : null , b ) ;
2010-04-06 21:37:58 -04:00
if ( toggleTabsOnTop )
toggleTabsOnTop . setAttribute ( 'disabled' , true ) ;
2009-07-07 11:56:38 -04:00
}
else {
2009-07-07 20:09:13 -04:00
orient = 'horizontal' ;
2010-06-27 00:01:15 -04:00
if ( this . isFixed ) {
2010-05-08 02:22:49 -04:00
this . setTabbrowserAttribute ( this . kFIXED , true , b ) ;
2009-07-07 12:00:17 -04:00
if ( ! this . isMultiRow ( ) ) {
2010-03-25 23:17:16 -04:00
this . removeTabStripAttribute ( 'height' ) ;
2009-07-07 11:56:38 -04:00
b . mPanelContainer . removeAttribute ( 'height' ) ;
}
2010-04-06 19:56:10 -04:00
// remove ordinal for "tabs on top" https://bugzilla.mozilla.org/show_bug.cgi?id=544815
if ( this . isFloating && this . currentTabbarPosition == 'top' ) {
this . removeTabStripAttribute ( 'ordinal' ) ;
if ( 'TabsOnTop' in window ) {
// workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=555987
TabsOnTop . enabled = ! TabsOnTop . enabled ;
window . setTimeout ( function ( ) {
TabsOnTop . enabled = ! TabsOnTop . enabled ;
} , 0 ) ;
}
}
2009-07-07 11:56:38 -04:00
}
else {
2010-03-28 14:22:15 -04:00
this . removeTabbrowserAttribute ( this . kFIXED , b ) ;
2010-04-22 04:12:31 -04:00
this . setTabStripAttribute ( 'height' , this . maxTabbarHeight ( this . getTreePref ( 'tabbar.height' ) , b ) ) ;
2010-06-27 00:01:15 -04:00
}
if ( toggleTabsOnTop ) {
if ( this . currentTabbarPosition == 'top' )
toggleTabsOnTop . removeAttribute ( 'disabled' ) ;
else
2010-04-06 21:37:58 -04:00
toggleTabsOnTop . setAttribute ( 'disabled' , true ) ;
2009-07-07 11:56:38 -04:00
}
}
2009-07-07 20:09:13 -04:00
2010-06-27 00:01:15 -04:00
if ( 'TabsOnTop' in window )
TabsOnTop . enabled = TabsOnTop . enabled && this . currentTabbarPosition == 'top' && this . isFixed ;
2010-03-25 06:04:47 -04:00
window . setTimeout ( function ( aSelf ) {
aSelf . updateFloatingTabbar ( ) ;
aSelf . startRendering ( ) ;
2010-06-25 11:59:59 -04:00
if ( '_positionPinnedTabs' in b . mTabContainer )
b . mTabContainer . _positionPinnedTabs ( ) ;
2010-03-25 06:04:47 -04:00
} , 0 , this ) ;
2010-03-23 15:10:53 -04:00
2010-11-18 23:00:42 -05:00
this . allowSubtreeCollapseExpand = this . getTreePref ( 'allowSubtreeCollapseExpand.' + orient ) ;
this . setTabbrowserAttribute ( this . kALLOW _COLLAPSE , this . allowSubtreeCollapseExpand ? 'true' : null ) ;
2010-09-16 00:19:17 -04:00
2010-11-29 03:42:06 -05:00
this . maxTreeLevel = this . getTreePref ( 'maxTreeLevel.' + orient ) ;
2010-11-29 05:35:47 -05:00
this . setTabbrowserAttribute ( this . kMAX _LEVEL , this . maxTreeLevel || '0' ) ;
2010-11-29 03:42:06 -05:00
this . enableSubtreeIndent = this . maxTreeLevel != 0 ;
this . setTabbrowserAttribute ( this . kINDENTED , this . enableSubtreeIndent ? 'true' : null ) ;
2010-11-24 11:14:36 -05:00
this . setTabbrowserAttribute ( this . kALLOW _STACK , this . canStackTabs ? 'true' : null ) ;
2010-11-24 18:37:26 -05:00
this . updateTabsZIndex ( this . canStackTabs ) ;
2010-11-24 11:14:36 -05:00
2010-11-18 23:00:42 -05:00
if ( ! this . isFloating ) {
this . hideAlltabsButton = this . getTreePref ( 'tabbar.hideAlltabsButton.' + orient ) ;
this . setTabbrowserAttribute ( this . kHIDE _ALLTABS , this . hideAlltabsButton ? 'true' : null ) ;
}
2009-07-21 22:22:00 -04:00
2010-11-29 03:42:06 -05:00
if ( this . maxTreeLevelPhisical )
this . promoteTooDeepLevelTabs ( ) ;
2009-07-07 20:09:13 -04:00
this . updateAllTabsIndent ( ) ;
2009-07-07 11:56:38 -04:00
} ,
2009-07-21 23:35:54 -04:00
2010-06-27 00:01:15 -04:00
onTabsOnTopSyncCommand : function TSTBrowser _onTabsOnTopSyncCommand ( aEnabled )
{
if (
! aEnabled ||
this . currentTabbarPosition != 'top' ||
this . isFixed
)
return ;
window . setTimeout ( function ( aTabBrowser ) {
TreeStyleTabService . toggleFixed ( aTabBrowser ) ;
2010-07-02 05:47:52 -04:00
window . setTimeout ( function ( ) {
if ( TabsOnTop . enabled != aEnabled )
TabsOnTop . enabled = aEnabled ;
} , 0 ) ;
2010-06-27 00:01:15 -04:00
} , 0 , this . mTabBrowser ) ;
} ,
2010-09-10 06:21:26 -04:00
updateFloatingTabbar : function TSTBrowser _updateFloatingTabbar ( aJustNow )
2010-03-23 14:31:55 -04:00
{
2010-08-07 12:15:07 -04:00
// this method is just for Firefox 4.0 or later
2010-03-31 14:24:23 -04:00
if ( ! this . isFloating ) return ;
2010-09-09 22:39:39 -04:00
if ( this . updateFloatingTabbarTimer ) {
window . clearTimeout ( this . updateFloatingTabbarTimer ) ;
2010-03-31 14:24:23 -04:00
this . updateFloatingTabbarTimer = null ;
2010-09-09 22:39:39 -04:00
}
if ( aJustNow ) {
2010-09-10 06:21:26 -04:00
this . updateFloatingTabbarInternal ( ) ;
2010-03-31 14:24:23 -04:00
}
else {
this . updateFloatingTabbarTimer = window . setTimeout ( function ( aSelf ) {
aSelf . updateFloatingTabbarTimer = null ;
2010-09-10 06:21:26 -04:00
aSelf . updateFloatingTabbarInternal ( )
2010-03-31 14:24:23 -04:00
} , 0 , this ) ;
}
2010-03-30 22:48:09 -04:00
} ,
2010-09-10 06:21:26 -04:00
updateFloatingTabbarInternal : function TSTBrowser _updateFloatingTabbarInternal ( )
2010-03-30 22:48:09 -04:00
{
2010-09-16 00:05:12 -04:00
if ( this . splitter . collapsed || this . splitter . getAttribute ( 'state' ) != 'collapsed' ) {
this . _tabStripPlaceHolder . collapsed =
this . splitter . collapsed =
( this . getPref ( 'browser.tabs.autoHide' ) && this . getTabsArray ( this . mTabBrowser ) . length == 1 ) ;
}
2010-03-23 14:31:55 -04:00
var strip = this . tabStrip ;
2010-04-29 23:20:18 -04:00
var tabContainerBox = this . getTabContainerBox ( this . mTabBrowser ) ;
2010-09-09 23:27:19 -04:00
var pos = this . currentTabbarPosition ;
if ( pos != 'top' ||
2010-03-25 04:51:49 -04:00
this . mTabBrowser . getAttribute ( this . kFIXED ) != 'true' ) {
2010-03-25 06:04:47 -04:00
2010-03-25 23:17:16 -04:00
let box = this . _tabStripPlaceHolder . boxObject ;
2010-03-23 15:10:53 -04:00
let root = document . documentElement . boxObject ;
2010-09-09 22:45:40 -04:00
let realWidth = parseInt ( this . _tabStripPlaceHolder . getAttribute ( 'width' ) || box . width ) ;
let realHeight = parseInt ( this . _tabStripPlaceHolder . getAttribute ( 'height' ) || box . height ) ;
2010-09-12 23:54:04 -04:00
let width = ( this . autoHide . expanded && this . isVertical ?
this . maxTabbarWidth ( this . getTreePref ( 'tabbar.width' ) ) :
0
) || realWidth ;
let height = ( this . autoHide . expanded && ! this . isVertical ?
this . maxTabbarHeight ( this . getTreePref ( 'tabbar.height' ) ) :
0
) || realHeight ;
2010-09-09 23:27:19 -04:00
let xOffset = pos == 'right' ? width - realWidth : 0 ;
let yOffset = pos == 'bottom' ? height - realHeight : 0 ;
2010-09-09 22:45:40 -04:00
strip . style . top = ( box . screenY - root . screenY + root . y - yOffset ) + 'px' ;
strip . style . left = ( box . screenX - root . screenX + root . x - xOffset ) + 'px' ;
2010-06-26 10:12:45 -04:00
strip . style . width = ( tabContainerBox . width = width ) + 'px' ;
strip . style . height = ( tabContainerBox . height = height ) + 'px' ;
2010-03-23 15:10:53 -04:00
2010-09-10 06:21:26 -04:00
this . updateFloatingTabbarResizer ( {
width : width ,
realWidth : realWidth ,
height : height ,
realHeight : realHeight
} ) ;
2010-09-09 23:27:19 -04:00
2010-04-29 23:20:18 -04:00
tabContainerBox . collapsed = ( this . splitter && this . splitter . getAttribute ( 'state' ) == 'collapsed' ) ;
2010-07-21 10:42:40 -04:00
this . mTabBrowser . tabContainer . setAttribute ( 'context' , this . mTabBrowser . tabContextMenu . id ) ;
2010-03-23 14:31:55 -04:00
}
2010-04-06 19:56:10 -04:00
else {
2010-04-29 23:20:18 -04:00
tabContainerBox . collapsed = false ;
2010-04-06 19:56:10 -04:00
strip . style . top = '' ;
strip . style . left = '' ;
strip . style . width = '' ;
strip . style . height = '' ;
2010-07-21 10:42:40 -04:00
this . mTabBrowser . tabContainer . removeAttribute ( 'context' ) ;
2010-04-06 19:56:10 -04:00
}
2010-03-25 06:04:47 -04:00
2010-06-25 11:59:59 -04:00
if ( '_positionPinnedTabs' in this . mTabBrowser . mTabContainer )
this . mTabBrowser . mTabContainer . _positionPinnedTabs ( ) ;
2010-03-23 14:31:55 -04:00
} ,
2010-09-10 06:21:26 -04:00
updateFloatingTabbarResizer : function TSTBrowser _updateFloatingTabbarResizer ( aSize )
2010-09-09 23:27:19 -04:00
{
2010-09-10 06:21:26 -04:00
var width = aSize . width ;
2010-09-10 09:46:06 -04:00
var realWidth = this . autoHide . mode == this . autoHide . kMODE _HIDE ? 0 : aSize . realWidth ;
2010-09-10 06:21:26 -04:00
var height = aSize . height ;
2010-09-10 09:46:06 -04:00
var realHeight = this . autoHide . mode == this . autoHide . kMODE _HIDE ? 0 : aSize . realHeight ;
2010-09-10 06:21:26 -04:00
var pos = this . currentTabbarPosition ;
var vertical = this . isVertical ;
var splitter = document . getElementById ( 'treestyletab-tabbar-resizer-splitter' ) ;
var box = splitter . parentNode ;
box . orient = splitter . orient = vertical ? 'horizontal' : 'vertical' ;
box . width = ( width - realWidth ) || width ;
box . height = ( height - realHeight ) || height ;
var boxStyle = box . style ;
boxStyle . top = pos == 'top' ? realHeight + 'px' : '' ;
boxStyle . right = pos == 'right' ? realWidth + 'px' : '' ;
boxStyle . left = pos == 'left' ? realWidth + 'px' : '' ;
boxStyle . bottom = pos == 'bottom' ? realHeight + 'px' : '' ;
if ( vertical ) {
splitter . removeAttribute ( 'width' ) ;
splitter . setAttribute ( 'height' , height ) ;
}
else {
splitter . setAttribute ( 'width' , width ) ;
splitter . removeAttribute ( 'height' ) ;
}
var splitterWidth = splitter . boxObject . width ;
var splitterHeight = splitter . boxObject . height ;
var splitterStyle = splitter . style ;
splitterStyle . marginTop = pos == 'bottom' ? ( - splitterHeight ) + 'px' :
vertical ? '0' :
box . height + 'px' ;
splitterStyle . marginRight = pos == 'left' ? ( - splitterWidth ) + 'px' :
! vertical ? '0' :
box . width + 'px' ;
splitterStyle . marginLeft = pos == 'right' ? ( - splitterWidth ) + 'px' :
! vertical ? '0' :
box . width + 'px' ;
splitterStyle . marginBottom = pos == 'top' ? ( - splitterHeight ) + 'px' :
vertical ? '0' :
box . height + 'px' ;
2010-09-09 23:27:19 -04:00
} ,
2010-03-23 14:31:55 -04:00
2010-03-25 06:19:29 -04:00
resetTabbarSize : function TSTBrowser _resetTabbarSize ( )
{
2010-09-12 23:54:04 -04:00
if ( this . isVertical ) {
2010-11-29 05:24:27 -05:00
2010-09-12 23:54:04 -04:00
this . clearTreePref ( 'tabbar.shrunkenWidth' ) ;
this . clearTreePref ( 'tabbar.width' ) ;
}
else {
2010-03-25 06:19:29 -04:00
this . clearTreePref ( 'tabbar.height' ) ;
2010-03-25 23:17:16 -04:00
if ( this . isFloating ) {
2010-04-29 23:20:18 -04:00
let tabContainerBox = this . getTabContainerBox ( this . mTabBrowser ) ;
tabContainerBox . removeAttribute ( 'height' ) ;
this . _tabStripPlaceHolder . height = tabContainerBox . boxObject . height ;
2010-03-25 06:19:29 -04:00
}
}
2010-09-12 23:54:04 -04:00
this . updateFloatingTabbar ( ) ;
2010-03-25 06:19:29 -04:00
} ,
2009-12-25 03:34:52 -05:00
updateTabbarOverflow : function TSTBrowser _updateTabbarOverflow ( )
2009-07-21 23:35:54 -04:00
{
var b = this . mTabBrowser ;
2010-11-29 19:12:22 -05:00
b . mTabContainer . removeAttribute ( 'overflow' ) ; // Firefox 4.0
2009-07-21 23:35:54 -04:00
var container = document . getAnonymousElementByAttribute ( b . mTabContainer , 'class' , 'tabs-container' ) ;
2010-03-23 15:13:33 -04:00
if ( ! container ) {
2010-03-25 23:17:16 -04:00
if ( this . isFloating )
2010-03-23 15:13:33 -04:00
container = b . mTabContainer ;
else
return ;
}
2009-07-21 23:35:54 -04:00
container . removeAttribute ( 'overflow' ) ;
var scrollBox = this . scrollBox ;
window . setTimeout ( function ( ) {
scrollBox = document . getAnonymousElementByAttribute ( scrollBox , 'anonid' , 'scrollbox' ) ;
if ( scrollBox ) scrollBox = document . getAnonymousNodes ( scrollBox ) [ 0 ] ;
if (
scrollBox &&
(
scrollBox . boxObject . width > container . boxObject . width ||
scrollBox . boxObject . height > container . boxObject . height
)
) {
2010-11-29 19:12:22 -05:00
b . mTabContainer . setAttribute ( 'overflow' , true ) ; // Firefox 4.0
2009-07-21 23:35:54 -04:00
container . setAttribute ( 'overflow' , true ) ;
}
else {
2010-11-29 19:12:22 -05:00
b . mTabContainer . removeAttribute ( 'overflow' ) ; // Firefox 4.0
2009-07-21 23:35:54 -04:00
container . removeAttribute ( 'overflow' ) ;
}
} , 100 ) ;
} ,
2009-12-25 04:49:47 -05:00
2010-05-15 10:05:02 -04:00
fireTabbarPositionEvent : function TSTBrowser _fireTabbarPositionEvent ( aChanging , aOldPosition , aNewPosition )
2009-12-25 04:49:47 -05:00
{
2010-05-15 10:05:02 -04:00
if ( aOldPosition == aNewPosition ) return false ;
2009-12-25 04:49:47 -05:00
2010-05-15 10:05:02 -04:00
/* PUBLIC API */
2009-12-25 04:49:47 -05:00
var event = document . createEvent ( 'Events' ) ;
2010-11-30 05:05:00 -05:00
event . initEvent ( aChanging ? this . kEVENT _TYPE _TABBAR _POSITION _CHANGING : this . kEVENT _TYPE _TABBAR _POSITION _CHANGED , true , false ) ;
2009-12-25 04:49:47 -05:00
event . oldPosition = aOldPosition ;
event . newPosition = aNewPosition ;
this . mTabBrowser . dispatchEvent ( event ) ;
2010-05-15 10:05:02 -04:00
return true ;
} ,
fireTabbarStateChangingEvent : function TSTBrowser _fireTabbarStateChangingEvent ( )
{
var b = this . mTabBrowser ;
var orient = this . isVertical ? 'vertical' : 'horizontal' ;
var oldState = {
fixed : this . isFixed ,
2010-11-29 05:24:27 -05:00
maxTreeLevel : this . maxTreeLevel ,
2010-11-29 03:42:06 -05:00
indented : this . maxTreeLevel != 0 ,
2010-09-16 00:19:17 -04:00
canCollapse : b . getAttribute ( this . kALLOW _COLLAPSE ) == 'true'
2010-05-15 10:05:02 -04:00
} ;
2010-09-16 00:19:17 -04:00
if ( ! this . isFloating ) {
oldState . alltabsButton = b . getAttribute ( this . kHIDE _ALLTABS ) != 'true' ;
oldState . allTabsButton = oldState . alltabsButton ;
}
2010-05-15 10:05:02 -04:00
var newState = {
fixed : this . getTreePref ( 'tabbar.fixed.' + orient ) ,
2010-11-29 05:24:27 -05:00
maxTreeLevel : this . getTreePref ( 'maxTreeLevel.' + orient ) ,
2010-11-29 03:42:06 -05:00
indented : this . getTreePref ( 'maxTreeLevel.' + orient ) != 0 ,
2010-09-16 00:19:17 -04:00
canCollapse : this . getTreePref ( 'allowSubtreeCollapseExpand.' + orient )
2010-05-15 10:05:02 -04:00
} ;
2010-09-16 00:19:17 -04:00
if ( ! this . isFloating ) {
newState . alltabsButton = ! this . getTreePref ( 'tabbar.hideAlltabsButton.' + orient ) ;
newState . allTabsButton = newState . alltabsButton ;
}
2010-05-15 10:05:02 -04:00
if ( oldState . fixed == newState . fixed &&
2010-11-29 05:24:27 -05:00
oldState . maxTreeLevel == newState . maxTreeLevel &&
2010-05-15 10:05:02 -04:00
oldState . indented == newState . indented &&
oldState . canCollapse == newState . canCollapse &&
oldState . alltabsButton == newState . alltabsButton )
return false ;
/* PUBLIC API */
var event = document . createEvent ( 'Events' ) ;
2010-11-30 05:05:00 -05:00
event . initEvent ( this . kEVENT _TYPE _TABBAR _STATE _CHANGING , true , false ) ;
2010-05-15 10:05:02 -04:00
event . oldState = oldState ;
event . newState = newState ;
this . mTabBrowser . dispatchEvent ( event ) ;
return true ;
} ,
fireTabbarStateChangedEvent : function TSTBrowser _fireTabbarStateChangedEvent ( )
{
var b = this . mTabBrowser ;
var state = {
fixed : this . isFixed ,
2010-11-29 05:24:27 -05:00
maxTreeLevel : this . maxTreeLevel ,
2010-11-29 03:42:06 -05:00
indented : this . maxTreeLevel != 0 ,
2010-09-16 00:19:17 -04:00
canCollapse : b . getAttribute ( this . kALLOW _COLLAPSE ) == 'true'
2010-05-15 10:05:02 -04:00
} ;
2010-09-16 00:19:17 -04:00
if ( ! this . isFloating ) {
state . alltabsButton = b . getAttribute ( this . kHIDE _ALLTABS ) != 'true' ;
state . allTabsButton = state . alltabsButton ;
}
2010-05-15 10:05:02 -04:00
/* PUBLIC API */
var event = document . createEvent ( 'Events' ) ;
2010-11-30 05:05:00 -05:00
event . initEvent ( this . kEVENT _TYPE _TABBAR _STATE _CHANGED , true , false ) ;
2010-05-15 10:05:02 -04:00
event . state = state ;
this . mTabBrowser . dispatchEvent ( event ) ;
return true ;
2009-12-25 04:49:47 -05:00
} ,
2009-07-21 23:35:54 -04:00
2009-12-25 03:34:52 -05:00
destroy : function TSTBrowser _destroy ( )
2007-11-14 14:34:36 -05:00
{
2010-06-22 14:00:16 -04:00
this . animationManager . removeTask ( this . smoothScrollTask ) ;
2009-09-03 02:24:06 -04:00
this . autoHide . destroy ( ) ;
2009-09-03 03:31:49 -04:00
delete this . _autoHide ;
2007-11-14 14:34:36 -05:00
var b = this . mTabBrowser ;
2010-03-23 13:58:23 -04:00
delete b . tabContainer . treeStyleTab ;
2007-11-14 14:34:36 -05:00
2010-09-14 03:39:17 -04:00
this . getAllTabsArray ( b ) . forEach ( function ( aTab ) {
2010-06-22 14:00:16 -04:00
this . stopTabIndentAnimation ( aTab ) ;
this . stopTabCollapseAnimation ( aTab ) ;
2009-07-08 06:40:51 -04:00
this . destroyTab ( aTab ) ;
} , this ) ;
2007-11-14 14:34:36 -05:00
2010-11-30 05:05:00 -05:00
var tabContainer = b . mTabContainer ;
tabContainer . removeEventListener ( 'TabOpen' , this , true ) ;
tabContainer . removeEventListener ( 'TabClose' , this , true ) ;
tabContainer . removeEventListener ( 'TabMove' , this , true ) ;
tabContainer . removeEventListener ( 'TabShow' , this , true ) ;
tabContainer . removeEventListener ( 'TabHide' , this , true ) ;
tabContainer . removeEventListener ( 'SSTabRestoring' , this , true ) ;
tabContainer . removeEventListener ( 'SSTabRestored' , this , true ) ;
tabContainer . removeEventListener ( 'TabPinned' , this , true ) ;
tabContainer . removeEventListener ( 'TabUnpinned' , this , true ) ;
2010-09-17 12:10:59 -04:00
if ( ! this . isFloating && 'tabutils' in window )
2010-09-16 05:01:52 -04:00
b . mTabContainer . removeEventListener ( 'DOMAttrModified' , this , true ) ; // Tab Utilites
2010-11-30 05:05:00 -05:00
tabContainer . removeEventListener ( 'mouseover' , this , true ) ;
tabContainer . removeEventListener ( 'mouseout' , this , true ) ;
tabContainer . removeEventListener ( 'dblclick' , this , true ) ;
tabContainer . removeEventListener ( 'select' , this , true ) ;
tabContainer . removeEventListener ( 'scroll' , this , true ) ;
tabContainer . removeEventListener ( 'dragleave' , this , false ) ;
tabContainer . removeEventListener ( 'dragover' , this , false ) ;
tabContainer . removeEventListener ( 'drop' , this , true ) ;
tabContainer . removeEventListener ( 'dragdrop' , this , false ) ; // for Firefox 3.5 or older
2010-11-30 19:51:10 -05:00
tabContainer . removeEventListener ( 'MultipleTabHandler:TabsDragStart' , this , true ) ;
2010-11-30 05:05:00 -05:00
var strip = this . tabStrip ;
2010-07-01 23:39:31 -04:00
strip . removeEventListener ( 'dragstart' , this , false ) ;
strip . removeEventListener ( 'dragenter' , this , false ) ;
strip . removeEventListener ( 'dragleave' , this , false ) ;
strip . removeEventListener ( 'dragend' , this , false ) ;
strip . removeEventListener ( 'dragover' , this , false ) ;
strip . removeEventListener ( 'drop' , this , false ) ;
strip . removeEventListener ( 'MozMouseHittest' , this , true ) ;
strip . removeEventListener ( 'mousedown' , this , true ) ;
strip . removeEventListener ( 'click' , this , true ) ;
2009-08-25 03:20:56 -04:00
2010-03-25 23:17:16 -04:00
if ( this . isFloating )
2010-03-23 15:10:53 -04:00
window . removeEventListener ( 'resize' , this , true ) ;
2010-11-30 05:05:00 -05:00
window . removeEventListener ( this . kEVENT _TYPE _PRINT _PREVIEW _ENTERED , this , false ) ;
window . removeEventListener ( this . kEVENT _TYPE _PRINT _PREVIEW _EXITED , this , false ) ;
2010-03-28 14:22:15 -04:00
2009-12-25 22:26:40 -05:00
b . removeEventListener ( 'MultipleTabHandlerTabsClosing' , this , false ) ;
2010-11-29 22:23:08 -05:00
window [ 'piro.sakura.ne.jp' ] . tabsDragUtils . destroyTabBrowser ( b ) ;
2010-03-24 13:20:30 -04:00
TreeStyleTabService . destroyTabDNDObserver ( b ) ;
2009-09-02 21:42:04 -04:00
this . tabbarDNDObserver . destroy ( ) ;
2009-09-02 22:05:25 -04:00
delete this . _tabbarDNDObserver ;
2009-09-02 21:42:04 -04:00
this . panelDNDObserver . destroy ( ) ;
2009-09-02 22:05:25 -04:00
delete this . _panelDNDObserver ;
2007-11-14 14:34:36 -05:00
2009-04-06 14:22:09 -04:00
this . scrollBox . removeEventListener ( 'overflow' , this , true ) ;
this . scrollBox . removeEventListener ( 'underflow' , this , true ) ;
2009-03-08 12:12:19 -04:00
2010-03-25 20:20:51 -04:00
var tabContextMenu = b . tabContextMenu ||
document . getAnonymousElementByAttribute ( b , 'anonid' , 'tabContextMenu' ) ;
2009-05-12 12:56:39 -04:00
tabContextMenu . removeEventListener ( 'popupshowing' , this , false ) ;
2007-11-14 14:34:36 -05:00
2008-03-09 23:51:21 -04:00
if ( this . tabbarCanvas ) {
this . tabbarCanvas . parentNode . removeChild ( this . tabbarCanvas ) ;
this . tabbarCanvas = null ;
}
2010-11-30 19:33:07 -05:00
this . ObserverService . removeObserver ( this , this . kTOPIC _INDENT _MODIFIED ) ;
this . ObserverService . removeObserver ( this , this . kTOPIC _COLLAPSE _EXPAND _ALL ) ;
2010-07-05 09:29:32 -04:00
this . ObserverService . removeObserver ( this , 'private-browsing-change-granted' ) ;
2010-11-30 19:33:07 -05:00
this . ObserverService . removeObserver ( this , this . kTOPIC _CHANGE _TREEVIEW _AVAILABILITY ) ;
2007-11-17 00:20:26 -05:00
this . removePrefListener ( this ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
delete this . mTabBrowser ;
2009-03-16 08:04:05 -04:00
delete this . _scrollBox ;
2007-11-14 14:34:36 -05:00
} ,
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
destroyTab : function TSTBrowser _destroyTab ( aTab )
2007-11-17 00:20:26 -05:00
{
2010-03-03 21:43:12 -05:00
var id = aTab . getAttribute ( this . kID ) ;
2010-03-24 11:38:08 -04:00
if ( id in this . tabsHash )
delete this . tabsHash [ id ] ;
2010-03-03 08:30:49 -05:00
2007-11-17 00:20:26 -05:00
delete aTab . _ _treestyletab _ _linkedTabBrowser ;
} ,
2010-05-08 04:30:39 -04:00
saveCurrentState : function TSTBrowser _saveCurrentState ( )
{
this . autoHide . saveCurrentState ( ) ;
var b = this . mTabBrowser ;
let box = ( this . tabStripPlaceHolder || this . getTabStrip ( b ) ) . boxObject ;
let prefs = {
'tabbar.fixed.horizontal' : b . getAttribute ( this . kFIXED + '-horizontal' ) == 'true' ,
'tabbar.fixed.vertical' : b . getAttribute ( this . kFIXED + '-vertical' ) == 'true' ,
'tabbar.width' : this . isVertical && this . autoHide . expanded && box . width ? box . width : void ( 0 ) ,
'tabbar.shrunkenWidth' : this . isVertical && ! this . autoHide . expanded && box . width ? box . width : void ( 0 ) ,
'tabbar.height' : ! this . isVertical && this . autoHide . expanded && box . height ? box . height : void ( 0 )
} ;
for ( var i in prefs )
{
if ( prefs [ i ] !== void ( 0 ) && this . getTreePref ( i ) != prefs [ i ] )
this . setTreePref ( i , prefs [ i ] ) ;
}
this . currentTabbarPosition = this . currentTabbarPosition ;
} ,
2007-11-17 07:50:36 -05:00
2007-11-17 00:20:26 -05:00
/* nsIObserver */
2008-03-03 04:21:33 -05:00
2009-08-09 22:15:10 -04:00
domains : [
2010-07-28 20:36:00 -04:00
'extensions.treestyletab.' ,
2010-08-07 12:29:40 -04:00
'browser.tabs.autoHide' ,
'browser.tabs.animate'
2009-08-09 22:15:10 -04:00
] ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
observe : function TSTBrowser _observe ( aSubject , aTopic , aData )
2007-11-14 14:34:36 -05:00
{
switch ( aTopic )
{
2010-11-30 19:33:07 -05:00
case this . kTOPIC _INDENT _MODIFIED :
2009-05-13 02:09:17 -04:00
if ( this . indent > - 1 )
2007-11-14 14:34:36 -05:00
this . updateAllTabsIndent ( ) ;
break ;
2010-11-30 19:33:07 -05:00
case this . kTOPIC _COLLAPSE _EXPAND _ALL :
2010-07-05 09:29:32 -04:00
if ( ! aSubject || aSubject == window ) {
2009-07-03 05:58:34 -04:00
aData = String ( aData ) ;
this . collapseExpandAllSubtree (
aData . indexOf ( 'collapse' ) > - 1 ,
aData . indexOf ( 'now' ) > - 1
) ;
}
2007-11-17 00:20:26 -05:00
break ;
2010-07-05 09:29:32 -04:00
case 'private-browsing-change-granted' :
this . collapseExpandAllSubtree ( false , true ) ;
window . setTimeout ( function ( aSelf ) {
aSelf . updateFloatingTabbar ( ) ;
} , 0 , this ) ;
break ;
2010-11-30 19:33:07 -05:00
case this . kTOPIC _CHANGE _TREEVIEW _AVAILABILITY :
2009-12-18 04:05:41 -05:00
this . treeViewEnabled = ( aData != 'false' ) ;
break ;
2007-11-14 14:34:36 -05:00
case 'nsPref:changed' :
2009-05-13 02:09:17 -04:00
this . onPrefChange ( aData ) ;
break ;
2007-11-14 14:34:36 -05:00
2009-05-13 02:09:17 -04:00
default :
break ;
}
} ,
2009-12-25 03:34:52 -05:00
onPrefChange : function TSTBrowser _onPrefChange ( aPrefName )
2009-05-13 02:09:17 -04:00
{
var b = this . mTabBrowser ;
var value = this . getPref ( aPrefName ) ;
var tabContainer = b . mTabContainer ;
2010-09-14 03:39:17 -04:00
var tabs = this . getAllTabsArray ( b ) ;
2009-05-13 02:09:17 -04:00
switch ( aPrefName )
{
case 'extensions.treestyletab.tabbar.position' :
2010-05-08 04:30:39 -04:00
if ( ! this . shouldApplyNewPref ) return ;
2010-05-08 01:37:41 -04:00
var oldPosition = this . currentTabbarPosition ;
2010-05-15 10:05:02 -04:00
if ( oldPosition != value ) {
this . fireTabbarPositionEvent ( true , oldPosition , value ) ;
this . initTabbar ( this . getPositionFlag ( value ) , this . getPositionFlag ( oldPosition ) ) ;
tabs . forEach ( function ( aTab ) {
this . initTabAttributes ( aTab ) ;
} , this ) ;
tabs . forEach ( function ( aTab ) {
this . initTabContents ( aTab ) ;
} , this ) ;
this . fireTabbarPositionEvent ( false , oldPosition , value ) ;
window . setTimeout ( function ( aSelf ) {
aSelf . checkTabsIndentOverflow ( ) ;
} , 0 , this ) ;
}
2009-05-13 02:09:17 -04:00
break ;
2007-11-14 14:34:36 -05:00
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.tabbar.invertTab' :
case 'extensions.treestyletab.tabbar.multirow' :
this . initTabbar ( ) ;
this . updateAllTabsIndent ( ) ;
tabs . forEach ( function ( aTab ) {
this . initTabContents ( aTab ) ;
} , this ) ;
break ;
case 'extensions.treestyletab.tabbar.invertTabContents' :
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kTAB _CONTENTS _INVERTED , value ) ;
2009-05-13 02:09:17 -04:00
tabs . forEach ( function ( aTab ) {
this . initTabContents ( aTab ) ;
} , this ) ;
break ;
2009-04-28 00:11:22 -04:00
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.tabbar.invertClosebox' :
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kCLOSEBOX _INVERTED , value ) ;
2009-05-13 02:09:17 -04:00
tabs . forEach ( function ( aTab ) {
this . initTabContents ( aTab ) ;
} , this ) ;
break ;
2007-11-14 14:34:36 -05:00
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.tabbar.style' :
2010-09-01 11:50:10 -04:00
case 'extensions.treestyletab.tabbar.style.aero' :
this . setTabbarStyle ( this . getTreePref ( 'tabbar.style' ) ) ;
2010-02-03 03:09:07 -05:00
value = this . getTreePref ( 'twisty.style' ) ;
2010-04-01 07:19:31 -04:00
if ( value != 'auto' )
2010-02-03 03:09:07 -05:00
break ;
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.twisty.style' :
2010-04-01 07:19:31 -04:00
this . setTwistyStyle ( value ) ;
2009-05-13 02:09:17 -04:00
break ;
2007-11-14 14:34:36 -05:00
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.showBorderForFirstTab' :
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kFIRSTTAB _BORDER , value ) ;
2009-05-13 02:09:17 -04:00
break ;
2007-11-14 14:34:36 -05:00
2010-05-08 02:22:49 -04:00
case 'extensions.treestyletab.tabbar.fixed.horizontal' :
2010-05-08 04:30:39 -04:00
if ( ! this . shouldApplyNewPref ) return ;
2010-05-08 02:22:49 -04:00
this . setTabbrowserAttribute ( this . kFIXED + '-horizontal' , value ? 'true' : null , b ) ;
2010-11-29 03:42:06 -05:00
case 'extensions.treestyletab.maxTreeLevel.horizontal' :
2009-07-07 20:09:13 -04:00
case 'extensions.treestyletab.allowSubtreeCollapseExpand.horizontal' :
2009-07-21 22:22:00 -04:00
case 'extensions.treestyletab.tabbar.hideAlltabsButton.horizontal' :
2010-05-15 10:05:02 -04:00
if ( ! this . isVertical && this . fireTabbarStateChangingEvent ( ) ) {
this . updateTabbarState ( ) ;
this . fireTabbarStateChangedEvent ( ) ;
}
2009-07-07 21:23:57 -04:00
break ;
2010-05-08 02:22:49 -04:00
case 'extensions.treestyletab.tabbar.fixed.vertical' :
2010-05-08 04:30:39 -04:00
if ( ! this . shouldApplyNewPref ) return ;
2010-05-08 02:22:49 -04:00
this . setTabbrowserAttribute ( this . kFIXED + '-vertical' , value ? 'true' : null , b ) ;
2010-11-29 03:42:06 -05:00
case 'extensions.treestyletab.maxTreeLevel.vertical' :
2009-07-07 20:09:13 -04:00
case 'extensions.treestyletab.allowSubtreeCollapseExpand.vertical' :
2009-07-21 22:22:00 -04:00
case 'extensions.treestyletab.tabbar.hideAlltabsButton.vertical' :
2010-05-15 10:05:02 -04:00
if ( this . isVertical && this . fireTabbarStateChangingEvent ( ) ) {
this . updateTabbarState ( ) ;
this . fireTabbarStateChangedEvent ( ) ;
}
2009-05-13 02:09:17 -04:00
break ;
2008-03-10 00:11:44 -04:00
2009-05-13 02:09:17 -04:00
case 'extensions.treestyletab.tabbar.width' :
case 'extensions.treestyletab.tabbar.shrunkenWidth' :
2010-05-08 04:30:39 -04:00
if ( ! this . shouldApplyNewPref ) return ;
2009-09-03 04:18:41 -04:00
if ( ! this . autoHide . isResizing && this . isVertical ) {
2010-03-25 23:17:16 -04:00
this . removeTabStripAttribute ( 'width' ) ;
2010-09-12 23:54:04 -04:00
if ( this . isFloating ) {
this . setTabStripAttribute ( 'width' , this . autoHide . placeHolderWidthFromMode ) ;
this . updateFloatingTabbar ( ) ;
}
else {
this . setTabStripAttribute ( 'width' , this . autoHide . widthFromMode ) ;
}
2009-05-13 02:09:17 -04:00
}
this . checkTabsIndentOverflow ( ) ;
break ;
2009-04-02 07:17:52 -04:00
2009-07-07 04:30:30 -04:00
case 'extensions.treestyletab.tabbar.height' :
2010-05-08 04:30:39 -04:00
if ( ! this . shouldApplyNewPref ) return ;
2009-07-07 04:30:30 -04:00
this . _horizontalTabMaxIndentBase = 0 ;
this . checkTabsIndentOverflow ( ) ;
break ;
2010-11-29 03:24:45 -05:00
case 'extensions.treestyletab.maxTreeLevel.phisical' :
2010-11-29 03:42:06 -05:00
if ( this . maxTreeLevelPhisical = value )
2010-11-29 03:24:45 -05:00
this . promoteTooDeepLevelTabs ( ) ;
break ;
2010-08-07 12:29:40 -04:00
case 'browser.tabs.animate' :
2010-05-02 00:30:51 -04:00
case 'extensions.treestyletab.animation.enabled' :
2010-08-07 12:29:40 -04:00
this . setTabbrowserAttribute ( this . kANIMATION _ENABLED ,
(
this . getPref ( 'extensions.treestyletab.animation.enabled' ) &&
( this . getPref ( 'browser.tabs.animate' ) !== false )
) ? 'true' : null
) ;
2010-05-02 00:30:51 -04:00
break ;
2010-07-28 20:36:00 -04:00
case 'browser.tabs.autoHide' :
2010-07-28 20:40:11 -04:00
if ( this . getTabsArray ( this . mTabBrowser ) . length == 1 )
this . updateFloatingTabbar ( ) ;
break ;
2010-07-28 20:36:00 -04:00
2007-11-14 14:34:36 -05:00
default :
break ;
}
} ,
2010-04-01 07:19:31 -04:00
setTabbarStyle : function TSTBrowser _setTabbarStyle ( aStyle )
{
2010-09-01 11:43:19 -04:00
if ( /^(default|plain|flat|mixed|vertigo|metal|sidebar)(-aero)?$/ . test ( aStyle ) )
2010-04-01 07:19:31 -04:00
aStyle = aStyle . toLowerCase ( ) ;
2010-09-01 11:43:19 -04:00
if ( aStyle . indexOf ( 'default' ) == 0 ) { // old name (for compatibility)
this . setTreePref ( 'tabbar.style' , aStyle = aStyle . replace ( 'default' , 'plain' ) ) ;
2010-04-01 07:19:31 -04:00
}
else if ( // dropshadow is available only on Firefox 3.5 or later.
2010-09-01 11:43:19 -04:00
aStyle . indexOf ( 'mixed' ) == 0 &&
2010-04-01 07:19:31 -04:00
this . Comparator . compare ( this . XULAppInfo . version , '3.5' ) < 0
) {
2010-09-01 11:43:19 -04:00
this . setTreePref ( 'tabbar.style' , aStyle = aStyle . replace ( 'mixed' , 'flat' ) ) ;
2010-04-01 07:19:31 -04:00
}
if ( aStyle ) {
let additionalValues = [ ] ;
if ( /^(plain|flat|mixed|vertigo)$/ . test ( aStyle ) )
additionalValues . push ( 'square' ) ;
if ( /^(plain|flat|mixed)$/ . test ( aStyle ) )
additionalValues . push ( 'border' ) ;
if ( /^(flat|mixed)$/ . test ( aStyle ) )
additionalValues . push ( 'color' ) ;
if ( /^(plain|mixed)$/ . test ( aStyle ) )
additionalValues . push ( 'shadow' ) ;
2010-09-01 11:50:10 -04:00
if ( this . getTreePref ( 'tabbar.style.aero' ) )
additionalValues . push ( 'aero' ) ;
2010-04-01 07:19:31 -04:00
if ( additionalValues . length )
aStyle = additionalValues . join ( ' ' ) + ' ' + aStyle ;
this . setTabbrowserAttribute ( this . kSTYLE , aStyle ) ;
}
else {
this . removeTabbrowserAttribute ( this . kSTYLE ) ;
}
} ,
setTwistyStyle : function TSTBrowser _setTwistyStyle ( aStyle )
{
2010-07-02 04:39:24 -04:00
if ( aStyle != 'auto' ) {
this . setTabbrowserAttribute ( this . kTWISTY _STYLE , aStyle ) ;
return ;
2010-04-01 07:19:31 -04:00
}
2010-07-02 04:39:24 -04:00
aStyle = 'modern-black' ;
if ( this . getTreePref ( 'tabbar.style' ) == 'sidebar' ) {
aStyle = 'osx' ;
}
else if (
this . getPref ( 'extensions.informationaltab.thumbnail.enabled' ) &&
this . getPref ( 'extensions.informationaltab.thumbnail.position' ) < 100
) {
let self = this ;
2010-07-02 04:56:28 -04:00
this . extensions . isAvailable ( 'informationaltab@piro.sakura.ne.jp' , {
2010-07-02 04:39:24 -04:00
ok : function ( ) {
aStyle = 'retro' ;
self . setTabbrowserAttribute ( self . kTWISTY _STYLE , aStyle ) ;
} ,
ng : function ( ) {
self . setTabbrowserAttribute ( self . kTWISTY _STYLE , aStyle ) ;
}
} ) ;
return ;
}
2010-04-01 07:19:31 -04:00
this . setTabbrowserAttribute ( this . kTWISTY _STYLE , aStyle ) ;
} ,
2008-02-24 02:58:12 -05:00
2007-11-17 00:20:26 -05:00
/* DOM Event Handling */
2008-03-09 23:51:21 -04:00
2009-12-25 03:34:52 -05:00
handleEvent : function TSTBrowser _handleEvent ( aEvent )
2007-11-14 14:34:36 -05:00
{
switch ( aEvent . type )
{
case 'TabOpen' :
2010-03-02 09:40:12 -05:00
return this . onTabAdded ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'TabClose' :
2010-03-02 09:40:12 -05:00
return this . onTabRemoved ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'TabMove' :
2010-03-02 09:40:12 -05:00
return this . onTabMove ( aEvent ) ;
2007-11-14 14:34:36 -05:00
2010-09-16 06:46:15 -04:00
case 'TabShow' :
case 'TabHide' :
return this . onTabVisibilityChanged ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'SSTabRestoring' :
2010-03-02 09:40:12 -05:00
return this . onTabRestoring ( aEvent ) ;
2009-10-25 13:31:47 -04:00
case 'SSTabRestored' :
2010-03-02 09:40:12 -05:00
return this . onTabRestored ( aEvent ) ;
2007-11-14 14:34:36 -05:00
2010-09-16 05:01:52 -04:00
case 'TabPinned' :
return this . onPinTab ( aEvent . originalTarget ) ;
case 'TabUnpinned' :
return this . onUnpinTab ( aEvent . originalTarget ) ;
2010-09-09 05:02:26 -04:00
case 'DOMAttrModified' :
return this . onDOMAttrModified ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'select' :
2010-03-02 09:40:12 -05:00
return this . onTabSelect ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'click' :
2010-03-02 09:40:12 -05:00
return this . onClick ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'dblclick' :
2010-03-02 09:40:12 -05:00
return this . onDblClick ( aEvent ) ;
2007-11-14 14:34:36 -05:00
2010-07-01 23:39:31 -04:00
case 'MozMouseHittest' : // to block default behaviors of the tab bar
return this . onMozMouseHittest ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'mousedown' :
2010-03-02 09:40:12 -05:00
return this . onMouseDown ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'scroll' :
2010-03-02 09:40:12 -05:00
return this . onScroll ( aEvent ) ;
2007-11-14 14:34:36 -05:00
case 'popupshowing' :
2010-03-02 09:40:12 -05:00
return this . onPopupShowing ( aEvent )
2007-11-14 14:34:36 -05:00
2009-08-25 05:27:01 -04:00
2010-06-13 08:21:49 -04:00
case 'dragstart' :
return this . tabbarDNDObserver . onDragStart ( aEvent ) ;
2009-08-25 03:20:56 -04:00
2007-11-17 12:21:33 -05:00
case 'dragenter' :
2010-06-13 08:21:49 -04:00
return this . tabbarDNDObserver . onDragEnter ( aEvent ) ;
case 'dragleave' :
return ( aEvent . currentTarget == this . tabStrip ?
this . tabbarDNDObserver :
this . panelDNDObserver ) . onDragLeave ( aEvent ) ;
2009-08-25 03:20:56 -04:00
case 'dragend' :
2010-03-02 09:40:12 -05:00
return this . tabbarDNDObserver . onDragEnd ( aEvent ) ;
2007-11-17 12:21:33 -05:00
case 'dragover' :
2007-11-17 12:52:51 -05:00
case 'dragdrop' :
2010-06-13 08:21:49 -04:00
case 'drop' :
let ( observer ) {
2010-03-23 09:33:00 -04:00
if ( aEvent . currentTarget == this . tabStrip ) {
2009-08-25 05:27:01 -04:00
observer = this . tabbarDNDObserver ;
}
2010-06-13 08:21:49 -04:00
else {
2009-08-25 05:27:01 -04:00
observer = this . panelDNDObserver ;
2010-06-13 08:21:49 -04:00
if ( 'nsDragAndDrop' in window ) { // for Firefox 3.5 or older
// don't use nsDragAndDrop if it can't be dropped!!
// http://piro.sakura.ne.jp/latest/blosxom/mozilla/xul/2007-02-02_splitbrowser-dragdrop.htm
if ( observer . canDrop ( aEvent ) )
nsDragAndDrop [ aEvent . type == 'dragover' ? 'dragOver' : 'drop' ] ( aEvent , observer ) ;
return ;
}
2010-04-21 09:22:07 -04:00
}
2010-06-13 08:21:49 -04:00
observer [ aEvent . type == 'dragover' ? 'onDragOver' : 'onDrop' ] ( aEvent ) ;
2010-04-21 09:22:07 -04:00
}
return ;
2009-08-25 05:27:01 -04:00
2007-11-30 14:22:34 -05:00
case 'mouseover' :
2009-05-13 02:09:17 -04:00
if ( this . isEventFiredOnTwisty ( aEvent ) )
2007-11-30 14:22:34 -05:00
aEvent . target . setAttribute ( this . kTWISTY _HOVER , true ) ;
return ;
case 'mouseout' :
2009-05-13 02:09:17 -04:00
if ( this . isEventFiredOnTwisty ( aEvent ) )
2007-11-30 14:22:34 -05:00
aEvent . target . removeAttribute ( this . kTWISTY _HOVER ) ;
return ;
2009-03-08 12:12:19 -04:00
case 'overflow' :
case 'underflow' :
2010-03-02 09:40:12 -05:00
return this . onTabbarOverflow ( aEvent ) ;
2009-12-25 22:26:40 -05:00
2010-03-23 15:10:53 -04:00
case 'resize' :
return this . onResize ( aEvent ) ;
2009-12-25 22:26:40 -05:00
2010-11-30 05:05:00 -05:00
case this . kEVENT _TYPE _PRINT _PREVIEW _ENTERED :
2010-03-28 14:22:15 -04:00
return this . onTreeStyleTabPrintPreviewEntered ( aEvent ) ;
2010-11-30 05:05:00 -05:00
case this . kEVENT _TYPE _PRINT _PREVIEW _EXITED :
2010-03-28 14:22:15 -04:00
return this . onTreeStyleTabPrintPreviewExited ( aEvent ) ;
2009-12-25 22:26:40 -05:00
case 'MultipleTabHandlerTabsClosing' :
2009-12-25 23:57:57 -05:00
if ( ! this . onTabsRemoving ( aEvent ) )
aEvent . preventDefault ( ) ;
2009-12-25 22:26:40 -05:00
return ;
2010-11-30 05:05:00 -05:00
// cancel tab dragging by Multiple Tab
2010-11-30 19:51:10 -05:00
case 'MultipleTabHandler:TabsDragStart' :
2010-11-30 05:05:00 -05:00
return aEvent . preventDefault ( ) ;
2007-11-14 14:34:36 -05:00
}
} ,
2008-06-18 20:15:57 -04:00
lastScrollX : - 1 ,
lastScrollY : - 1 ,
2009-05-13 02:09:17 -04:00
2009-12-25 03:34:52 -05:00
updateLastScrollPosition : function TSTBrowser _updateLastScrollPosition ( )
2009-05-13 02:09:17 -04:00
{
if ( ! this . isVertical ) return ;
var x = { } , y = { } ;
var scrollBoxObject = this . scrollBoxObject ;
if ( ! scrollBoxObject ) return ;
scrollBoxObject . getPosition ( x , y ) ;
this . lastScrollX = x . value ;
this . lastScrollY = y . value ;
} ,
2009-12-25 04:15:25 -05:00
onTabAdded : function TSTBrowser _onTabAdded ( aEvent , aTab )
2007-11-14 14:34:36 -05:00
{
2009-12-25 04:15:25 -05:00
var tab = aTab || aEvent . originalTarget ;
2007-11-14 14:34:36 -05:00
var b = this . mTabBrowser ;
2009-12-25 05:09:16 -05:00
if ( this . isTabInitialized ( tab ) )
return false ;
2007-11-14 14:34:36 -05:00
this . initTab ( tab ) ;
2009-07-30 04:57:42 -04:00
var hasStructure = this . treeStructure && this . treeStructure . length ;
2009-12-20 13:46:51 -05:00
var pareintIndexInTree = hasStructure ? this . treeStructure . shift ( ) : 0 ;
2009-07-30 03:56:11 -04:00
2009-09-08 22:57:30 -04:00
if ( this . readiedToAttachNewTab ) {
2009-12-20 13:46:51 -05:00
if ( pareintIndexInTree < 0 ) { // there is no parent, so this is a new parent!
this . parentTab = tab . getAttribute ( this . kID ) ;
}
2009-07-30 03:56:11 -04:00
let parent = this . getTabById ( this . parentTab ) ;
if ( parent ) {
let tabs = [ parent ] . concat ( this . getDescendantTabs ( parent ) ) ;
2009-12-20 13:46:51 -05:00
parent = pareintIndexInTree < tabs . length ? tabs [ pareintIndexInTree ] : parent ;
2009-07-30 03:56:11 -04:00
}
if ( parent ) {
2010-07-29 22:39:51 -04:00
this . attachTabTo ( tab , parent , {
dontExpand : this . shouldExpandAllTree
} ) ;
2009-07-30 03:56:11 -04:00
}
2007-11-14 14:34:36 -05:00
2009-07-30 03:56:11 -04:00
let refTab ;
let newIndex = - 1 ;
2009-07-30 04:57:42 -04:00
if ( hasStructure ) {
}
else if ( this . insertBefore &&
2007-11-14 14:34:36 -05:00
( refTab = this . getTabById ( this . insertBefore ) ) ) {
newIndex = refTab . _tPos ;
}
else if ( parent &&
this . getTreePref ( 'insertNewChildAt' ) == this . kINSERT _FISRT &&
this . multipleCount == 0 ) {
/ * <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̎ q <EFBFBD> ^ <EFBFBD> u <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> C <EFBFBD> Ɋ J <EFBFBD> <EFBFBD> <EFBFBD> ꍇ <EFBFBD> A <EFBFBD> ŏ <EFBFBD> <EFBFBD> Ɋ J <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> q <EFBFBD> ^ <EFBFBD> u <EFBFBD> ̍ ŏ <EFBFBD> <EFBFBD> ̈ ʒu <EFBFBD> ɑ } <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> A <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> ́ u <EFBFBD> ŏ <EFBFBD> <EFBFBD> ̊ J <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> v <EFBFBD> <EFBFBD>
<EFBFBD> u <EFBFBD> <EFBFBD> <EFBFBD> X <EFBFBD> ŏ <EFBFBD> <EFBFBD> ̎ q <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> v <EFBFBD> Ƃ ̊ Ԃɑ } <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ă <EFBFBD> <EFBFBD> <EFBFBD> * /
newIndex = parent . _tPos + 1 ;
if ( refTab = this . getFirstChildTab ( parent ) )
this . insertBefore = refTab . getAttribute ( this . kID ) ;
}
if ( newIndex > - 1 ) {
if ( newIndex > tab . _tPos ) newIndex -- ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount ++ ;
2007-11-14 14:34:36 -05:00
b . moveTabTo ( tab , newIndex ) ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount -- ;
2007-11-14 14:34:36 -05:00
}
2010-07-29 22:39:51 -04:00
if ( this . shouldExpandAllTree )
this . collapseExpandSubtree ( parent , false ) ;
2007-11-14 14:34:36 -05:00
}
2009-09-08 22:57:30 -04:00
if ( ! this . readiedToAttachMultiple ) {
2007-11-14 14:34:36 -05:00
this . stopToOpenChildTab ( b ) ;
}
else {
this . multipleCount ++ ;
}
2008-03-09 01:36:52 -05:00
2010-07-21 10:48:07 -04:00
if ( this . animationEnabled ) {
2009-04-07 14:07:27 -04:00
this . updateTabCollapsed ( tab , true , true ) ;
2010-07-21 10:48:07 -04:00
this . updateTabCollapsed ( tab , false , this . restoringTree ) ;
2009-04-07 14:07:27 -04:00
}
2009-07-08 07:00:45 -04:00
var prev = this . getPreviousSiblingTab ( tab ) ;
2009-09-29 10:31:02 -04:00
if ( prev ) {
this . setTabValue ( tab , this . kINSERT _AFTER , prev . getAttribute ( this . kID ) ) ;
2009-07-08 07:00:45 -04:00
this . setTabValue ( prev , this . kINSERT _BEFORE , tab . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-07-08 07:00:45 -04:00
2009-09-01 22:52:16 -04:00
var next = this . getNextSiblingTab ( tab ) ;
2009-09-29 10:31:02 -04:00
if ( next ) {
this . setTabValue ( tab , this . kINSERT _BEFORE , next . getAttribute ( this . kID ) ) ;
2009-09-01 22:52:16 -04:00
this . setTabValue ( next , this . kINSERT _AFTER , tab . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-12-17 21:21:28 -05:00
2010-01-29 02:54:17 -05:00
if ( ! TreeStyleTabService . restoringTree &&
2009-12-17 21:21:28 -05:00
! this . useTMPSessionAPI &&
! this . _checkRestoringWindowTimerOnTabAdded ) {
this . _checkRestoringWindowTimerOnTabAdded = window . setTimeout ( function ( aSelf ) {
aSelf . _checkRestoringWindowTimerOnTabAdded = null ;
if ( aSelf . getRestoringTabsCount ( ) > 1 )
2010-01-29 02:54:17 -05:00
TreeStyleTabService . restoringTree = true ;
2009-12-17 21:21:28 -05:00
} , 0 , this ) ;
}
2009-12-25 05:09:16 -05:00
2010-07-25 12:13:19 -04:00
if ( this . scrollToNewTabMode > 0 )
this . scrollToTab ( tab , this . scrollToNewTabMode < 2 ) ;
2010-07-25 12:06:03 -04:00
2010-07-28 20:36:00 -04:00
if ( this . getPref ( 'browser.tabs.autoHide' ) )
this . updateFloatingTabbar ( ) ;
2010-11-24 11:14:36 -05:00
if ( this . canStackTabs )
2010-11-24 18:37:26 -05:00
this . updateTabsZIndex ( true ) ;
2010-11-24 11:14:36 -05:00
2009-12-25 05:09:16 -05:00
return true ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-17 21:21:28 -05:00
_checkRestoringWindowTimerOnTabAdded : null ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
onTabRemoved : function TSTBrowser _onTabRemoved ( aEvent )
2007-11-14 14:34:36 -05:00
{
var tab = aEvent . originalTarget ;
var b = this . mTabBrowser ;
2010-08-07 11:46:16 -04:00
tab . setAttribute ( this . kREMOVED , true ) ;
2009-04-07 12:09:17 -04:00
this . stopTabIndentAnimation ( tab ) ;
2009-04-07 13:14:09 -04:00
this . stopTabCollapseAnimation ( tab ) ;
2007-11-14 14:34:36 -05:00
2009-04-05 14:55:06 -04:00
var closeParentBehavior = this . getTreePref ( 'closeParentBehavior' ) ;
2009-06-09 11:03:59 -04:00
var closeRootBehavior = this . getTreePref ( 'closeRootBehavior' ) ;
2009-04-05 14:55:06 -04:00
2009-12-21 00:45:07 -05:00
var collapsed = this . isCollapsed ( tab ) ;
if ( collapsed )
2010-03-02 09:40:12 -05:00
this . stopRendering ( ) ;
2009-12-21 00:45:07 -05:00
2010-11-10 11:49:18 -05:00
var backupAttributes = { } ;
2010-11-10 11:52:02 -05:00
if ( this . hasChildTabs ( tab ) )
backupAttributes [ this . kCHILDREN ] = this . getTabValue ( tab , this . kCHILDREN ) ;
2010-11-10 11:49:18 -05:00
2009-12-21 00:45:07 -05:00
var subtreeCollapsed = this . isSubtreeCollapsed ( tab ) ;
2009-04-05 14:55:06 -04:00
if (
2010-08-13 14:32:43 -04:00
closeParentBehavior == this . CHILDREN _CLOSE ||
2009-12-21 00:45:07 -05:00
subtreeCollapsed
2009-04-05 14:55:06 -04:00
) {
2009-12-25 16:09:52 -05:00
let tabs = this . getDescendantTabs ( tab ) ;
2009-12-25 23:49:58 -05:00
if ( this . fireTabSubtreeClosingEvent ( tab , tabs ) ) {
if ( subtreeCollapsed )
this . stopRendering ( ) ;
2009-12-25 16:09:52 -05:00
2009-12-25 23:49:58 -05:00
this . markAsClosedSet ( [ tab ] . concat ( tabs ) ) ;
2009-12-25 15:06:49 -05:00
2009-12-25 23:49:58 -05:00
tabs . reverse ( ) . forEach ( function ( aTab ) {
2010-08-08 05:42:47 -04:00
b . removeTab ( aTab , { animate : true } ) ;
2009-12-25 23:49:58 -05:00
} , this ) ;
2007-11-14 14:34:36 -05:00
2009-12-25 23:49:58 -05:00
this . fireTabSubtreeClosedEvent ( b , tab , tabs ) ;
2009-12-21 00:33:32 -05:00
2009-12-25 23:49:58 -05:00
if ( subtreeCollapsed )
this . startRendering ( ) ;
}
2007-11-14 14:34:36 -05:00
}
var firstChild = this . getFirstChildTab ( tab ) ;
var parentTab = this . getParentTab ( tab ) ;
var nextFocusedTab = null ;
2009-07-08 07:00:45 -04:00
var prev = this . getPreviousSiblingTab ( tab ) ;
2009-09-01 22:52:16 -04:00
var next = this . getNextSiblingTab ( tab ) ;
2009-07-08 07:00:45 -04:00
if ( prev ) {
2009-09-01 22:52:16 -04:00
this . setTabValue ( tab , this . kINSERT _AFTER , prev . getAttribute ( this . kID ) ) ;
2009-07-08 07:00:45 -04:00
if ( next )
this . setTabValue ( prev , this . kINSERT _BEFORE , next . getAttribute ( this . kID ) ) ;
else
this . deleteTabValue ( prev , this . kINSERT _BEFORE ) ;
}
2009-09-01 22:52:16 -04:00
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 ) ;
}
2009-07-08 07:00:45 -04:00
2009-04-20 09:00:05 -04:00
var indentModifiedTabs = [ ] ;
2007-11-14 14:34:36 -05:00
if ( firstChild ) {
2010-08-13 14:32:43 -04:00
let children = this . getChildTabs ( tab ) ;
let behavior = parentTab ? closeParentBehavior : closeRootBehavior ;
if ( behavior == this . CHILDREN _PROMOTE _FIRST &&
parentTab &&
this . getChildTabs ( parentTab ) . length == 1 )
behavior = this . CHILDREN _PROMOTE _ALL ;
indentModifiedTabs = indentModifiedTabs . concat (
behavior == this . CHILDREN _PROMOTE _FIRST ?
[ children [ 0 ] ] :
children
) ;
this . partAllChildren ( tab , {
behavior : behavior ,
dontUpdateIndent : true
} ) ;
if ( behavior == this . CHILDREN _PROMOTE _ALL ||
behavior == this . CHILDREN _PROMOTE _FIRST )
2007-11-14 14:34:36 -05:00
nextFocusedTab = firstChild ;
}
if ( parentTab ) {
2009-04-20 08:45:27 -04:00
let firstSibling = this . getFirstChildTab ( parentTab ) ;
let lastSibling = this . getLastChildTab ( parentTab ) ;
2009-02-05 03:38:01 -05:00
if ( tab == lastSibling && ! nextFocusedTab ) {
2007-11-14 14:34:36 -05:00
if ( tab == firstSibling ) { // there is only one child
nextFocusedTab = parentTab ;
}
else { // previous sibling tab
nextFocusedTab = this . getPreviousSiblingTab ( tab ) ;
}
}
2007-11-26 14:55:58 -05:00
2009-06-19 14:02:48 -04:00
let ancestors = [ ] ,
ancestor = parentTab ;
2007-11-26 14:55:58 -05:00
do {
2009-06-19 14:02:48 -04:00
ancestors . push ( ancestor . getAttribute ( this . kID ) ) ;
if ( ! next && ( next = this . getNextSiblingTab ( ancestor ) ) )
2009-04-20 08:48:34 -04:00
backupAttributes [ this . kINSERT _BEFORE ] = next . getAttribute ( this . kID ) ;
2007-11-26 14:55:58 -05:00
}
2009-06-19 14:02:48 -04:00
while ( ancestor = this . getParentTab ( ancestor ) ) ;
2009-04-20 08:48:34 -04:00
backupAttributes [ this . kANCESTOR ] = ancestors . join ( '|' ) ;
2007-11-26 14:55:58 -05:00
2009-07-06 21:15:13 -04:00
let shouldCloseParentTab = (
2009-07-06 21:09:50 -04:00
this . isGroupTab ( parentTab ) &&
this . getDescendantTabs ( parentTab ) . length == 1
) ;
if ( shouldCloseParentTab && nextFocusedTab == parentTab )
nextFocusedTab = this . getNextFocusedTab ( parentTab ) ;
2009-07-30 05:56:28 -04:00
this . partTab ( tab , { dontUpdateIndent : true } ) ;
2009-06-19 14:02:48 -04:00
2009-07-06 21:09:50 -04:00
if ( shouldCloseParentTab ) {
2009-07-06 21:34:40 -04:00
window . setTimeout ( function ( ) {
2009-07-06 21:19:31 -04:00
if ( parentTab . parentNode )
2010-08-08 05:42:47 -04:00
b . removeTab ( parentTab , { animate : true } ) ;
2009-07-06 21:34:40 -04:00
parentTab = null ;
b = null ;
} , 0 ) ;
2009-06-19 14:02:48 -04:00
}
2007-11-14 14:34:36 -05:00
}
else if ( ! nextFocusedTab ) {
2009-07-06 21:09:50 -04:00
nextFocusedTab = this . getNextFocusedTab ( tab ) ;
2007-11-14 14:34:36 -05:00
}
2009-12-18 01:35:08 -05:00
if ( indentModifiedTabs . length )
this . updateTabsIndentWithDelay ( indentModifiedTabs ) ;
this . checkTabsIndentOverflow ( ) ;
for ( var i in backupAttributes )
{
this . setTabValue ( tab , i , backupAttributes [ i ] ) ;
}
2009-07-06 21:53:19 -04:00
if ( b . selectedTab == tab ) {
this . _focusChangedByCurrentTabRemove = true ;
if (
nextFocusedTab &&
2010-09-09 06:34:56 -04:00
! nextFocusedTab . hidden &&
2009-07-06 21:53:19 -04:00
this . _tabFocusAllowance . every ( function ( aFunc ) {
2009-12-25 04:49:47 -05:00
try {
return aFunc . call ( this , b ) ;
}
catch ( e ) {
return false ;
}
2009-07-06 21:53:19 -04:00
} , this )
)
b . selectedTab = nextFocusedTab ;
}
2009-12-21 00:45:07 -05:00
2010-03-02 09:40:12 -05:00
this . updateLastScrollPosition ( ) ;
2010-03-03 09:46:24 -05:00
this . destroyTab ( tab ) ;
2010-07-28 20:36:00 -04:00
if ( this . getPref ( 'browser.tabs.autoHide' ) )
this . updateFloatingTabbar ( ) ;
2010-11-24 11:14:36 -05:00
if ( this . canStackTabs )
2010-11-24 18:37:26 -05:00
this . updateTabsZIndex ( true ) ;
2010-11-24 11:14:36 -05:00
2009-12-21 00:45:07 -05:00
if ( collapsed )
this . startRendering ( ) ;
2007-11-14 14:34:36 -05:00
} ,
2010-08-13 14:32:43 -04:00
CHILDREN _PROMOTE _FIRST : 3 ,
CHILDREN _PROMOTE _ALL : 0 ,
CHILDREN _DETACH : 1 ,
CHILDREN _SIMPLY _DETACH : 4 ,
CHILDREN _CLOSE : 2 , // onTabRemoved only
2009-12-25 03:34:52 -05:00
getNextFocusedTab : function TSTBrowser _getNextFocusedTab ( aTab )
2009-07-06 21:09:50 -04:00
{
return this . getNextSiblingTab ( aTab ) ||
this . getPreviousVisibleTab ( aTab ) ;
} ,
2007-11-14 14:34:36 -05:00
2009-12-25 23:57:57 -05:00
onTabsRemoving : function TSTBrowser _onTabsRemoving ( aEvent )
2009-12-25 22:26:40 -05:00
{
2009-12-25 23:57:57 -05:00
var b = this . getTabBrowserFromChild ( aEvent . tabs [ 0 ] ) ;
var trees = this . splitTabsToSubtrees ( aEvent . tabs ) ;
if ( trees . some ( function ( aTabs ) {
return aTabs . length > 1 &&
! this . fireTabSubtreeClosingEvent ( aTabs [ 0 ] , aTabs ) ;
} , this ) )
return false ;
trees . forEach ( function ( aTabs ) {
2009-12-25 23:49:58 -05:00
this . markAsClosedSet ( aTabs ) ;
} , this ) ;
2009-12-25 23:57:57 -05:00
window . setTimeout ( function ( aSelf ) {
trees . forEach ( function ( aTabs ) {
aSelf . fireTabSubtreeClosedEvent ( b , aTabs [ 0 ] , aTabs ) ;
} ) ;
} , 0 , this ) ;
2009-12-26 00:54:55 -05:00
return true ;
2009-12-25 22:26:40 -05:00
} ,
2009-12-25 03:34:52 -05:00
onTabMove : function TSTBrowser _onTabMove ( aEvent )
2007-11-14 14:34:36 -05:00
{
var tab = aEvent . originalTarget ;
var b = this . mTabBrowser ;
2009-12-25 04:15:25 -05:00
// When the tab was moved before TabOpen event is fired, we have to update manually.
2009-12-25 05:09:16 -05:00
var newlyOpened = ! this . isTabInitialized ( tab ) && this . onTabAdded ( null , tab ) ;
2009-12-25 04:15:25 -05:00
// twisty vanished after the tab is moved!!
this . initTabContents ( tab ) ;
2007-11-14 14:34:36 -05:00
2009-09-30 01:42:48 -04:00
if ( this . hasChildTabs ( tab ) && ! this . subTreeMovingCount ) {
2009-12-25 06:19:50 -05:00
this . moveTabSubtreeTo ( tab , tab . _tPos ) ;
2007-11-14 14:34:36 -05:00
}
var parentTab = this . getParentTab ( tab ) ;
2009-09-30 01:42:48 -04:00
if ( parentTab && ! this . subTreeChildrenMovingCount ) {
2007-11-14 14:34:36 -05:00
this . updateChildrenArray ( parentTab ) ;
}
2007-11-15 08:01:07 -05:00
this . updateTabsCount ( tab , true ) ;
2009-09-01 22:52:16 -04:00
var prev = this . getPreviousSiblingTab ( tab ) ;
2009-09-29 10:31:02 -04:00
var next = this . getNextSiblingTab ( tab ) ;
if ( prev ) {
this . setTabValue ( prev , this . kINSERT _BEFORE , tab . getAttribute ( this . kID ) ) ;
2009-09-01 22:52:16 -04:00
this . setTabValue ( tab , this . kINSERT _AFTER , prev . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-09-01 22:52:16 -04:00
else
this . deleteTabValue ( tab , this . kINSERT _AFTER ) ;
2009-09-29 10:31:02 -04:00
if ( next ) {
this . setTabValue ( next , this . kINSERT _AFTER , tab . getAttribute ( this . kID ) ) ;
2009-07-08 07:00:45 -04:00
this . setTabValue ( tab , this . kINSERT _BEFORE , next . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-07-08 07:00:45 -04:00
else
this . deleteTabValue ( tab , this . kINSERT _BEFORE ) ;
var old = aEvent . detail ;
if ( old > tab . _tPos ) old -- ;
2010-11-24 11:14:36 -05:00
var tabs = this . getAllTabsArray ( b ) ;
old = tabs [ old ] ;
2009-09-01 22:52:16 -04:00
prev = this . getPreviousSiblingTab ( old ) ;
2009-09-29 10:31:02 -04:00
next = this . getNextSiblingTab ( old ) ;
if ( prev ) {
this . setTabValue ( prev , this . kINSERT _BEFORE , old . getAttribute ( this . kID ) ) ;
2009-09-01 22:52:16 -04:00
this . setTabValue ( old , this . kINSERT _AFTER , prev . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-09-01 22:52:16 -04:00
else
this . deleteTabValue ( old , this . kINSERT _AFTER ) ;
2009-09-29 10:31:02 -04:00
if ( next ) {
this . setTabValue ( next , this . kINSERT _AFTER , old . getAttribute ( this . kID ) ) ;
2009-07-08 07:00:45 -04:00
this . setTabValue ( old , this . kINSERT _BEFORE , next . getAttribute ( this . kID ) ) ;
2009-09-29 10:31:02 -04:00
}
2009-07-08 07:00:45 -04:00
else
this . deleteTabValue ( old , this . kINSERT _BEFORE ) ;
2010-11-24 11:14:36 -05:00
if ( this . canStackTabs )
2010-11-24 18:37:26 -05:00
this . updateTabsZIndex ( true ) ;
2010-11-24 11:14:36 -05:00
2007-11-14 14:34:36 -05:00
if (
2009-09-30 01:42:48 -04:00
this . subTreeMovingCount ||
2009-12-25 05:09:16 -05:00
this . internallyTabMovingCount ||
// We don't have to fixup tree structure for a NEW TAB
// which has already been structured.
( newlyOpened && this . getParentTab ( tab ) )
2007-11-14 14:34:36 -05:00
)
return ;
2009-09-01 10:39:01 -04:00
this . attachTabFromPosition ( tab , aEvent . detail ) ;
2007-11-26 14:55:58 -05:00
} ,
2009-12-25 03:34:52 -05:00
attachTabFromPosition : function TSTBrowser _attachTabFromPosition ( aTab , aOldPosition )
2007-11-26 14:55:58 -05:00
{
2007-11-26 17:43:50 -05:00
var parent = this . getParentTab ( aTab ) ;
2009-09-01 10:39:01 -04:00
if ( aOldPosition === void ( 0 ) ) aOldPosition = aTab . _tPos ;
var pos = this . getChildIndex ( aTab , parent ) ;
2010-09-14 03:39:17 -04:00
var oldPos = this . getChildIndex ( this . getAllTabsArray ( this . mTabBrowser ) [ aOldPosition ] , parent ) ;
2009-09-01 10:39:01 -04:00
var delta ;
if ( pos == oldPos ) { // no move?
return ;
}
else if ( pos < 0 || oldPos < 0 ) {
delta = 2 ;
}
else {
delta = Math . abs ( pos - oldPos ) ;
}
2009-01-24 00:39:22 -05:00
var prevTab = this . getPreviousTab ( aTab ) ;
var nextTab = this . getNextTab ( aTab ) ;
2007-11-26 21:42:02 -05:00
var tabs = this . getDescendantTabs ( aTab ) ;
if ( tabs . length ) {
2009-01-24 00:39:22 -05:00
nextTab = this . getNextTab ( tabs [ tabs . length - 1 ] ) ;
2007-11-26 21:42:02 -05:00
}
var prevParent = this . getParentTab ( prevTab ) ;
var nextParent = this . getParentTab ( nextTab ) ;
var prevLevel = prevTab ? Number ( prevTab . getAttribute ( this . kNEST ) ) : - 1 ;
var nextLevel = nextTab ? Number ( nextTab . getAttribute ( this . kNEST ) ) : - 1 ;
var newParent ;
2007-11-26 17:43:50 -05:00
2009-09-01 10:39:01 -04:00
if ( ! prevTab ) { // moved to topmost position
2007-11-26 21:42:02 -05:00
newParent = null ;
2007-11-26 17:43:50 -05:00
}
2009-09-01 10:39:01 -04:00
else if ( ! nextTab ) { // moved to last position
newParent = ( delta > 1 ) ? prevParent : parent ;
2007-11-26 17:43:50 -05:00
}
2009-09-01 10:39:01 -04:00
else if ( prevParent == nextParent ) { // moved into existing tree
2007-11-26 17:43:50 -05:00
newParent = prevParent ;
}
2009-09-01 10:39:01 -04:00
else if ( prevLevel > nextLevel ) { // moved to end of existing tree
2009-09-01 22:03:58 -04:00
if ( this . mTabBrowser . selectedTab != aTab ) { // maybe newly opened tab
newParent = prevParent ;
}
else { // maybe drag and drop
var realDelta = Math . abs ( aTab . _tPos - aOldPosition ) ;
newParent = realDelta < 2 ? prevParent : ( parent || nextParent ) ;
}
2007-11-26 14:55:58 -05:00
}
2009-09-01 10:39:01 -04:00
else if ( prevLevel < nextLevel ) { // moved to first child position of existing tree
2009-09-01 06:30:21 -04:00
newParent = parent || nextParent ;
2007-11-26 17:43:50 -05:00
}
if ( newParent != parent ) {
2010-09-16 06:46:15 -04:00
if ( newParent ) {
if ( newParent . hidden == aTab . hidden )
this . attachTabTo ( aTab , newParent , { insertBefore : nextTab } ) ;
}
else {
2007-11-26 14:55:58 -05:00
this . partTab ( aTab ) ;
2010-09-16 06:46:15 -04:00
}
2007-11-14 14:34:36 -05:00
}
} ,
2007-11-26 14:55:58 -05:00
2009-12-25 03:34:52 -05:00
updateChildrenArray : function TSTBrowser _updateChildrenArray ( aTab )
2007-11-14 14:34:36 -05:00
{
var children = this . getChildTabs ( aTab ) ;
2009-12-22 03:05:16 -05:00
children . sort ( this . sortTabsByOrder ) ;
2008-10-17 08:35:55 -04:00
this . setTabValue (
aTab ,
this . kCHILDREN ,
children
. map ( function ( aItem ) {
return aItem . getAttribute ( this . kID ) ;
} , this )
. join ( '|' )
) ;
2007-11-14 14:34:36 -05:00
} ,
2010-09-16 06:46:15 -04:00
onTabVisibilityChanged : function TSTBrowser _onTabVisibilityChanged ( aEvent )
{
if ( this . tabVisibilityChangedTimer ) {
window . clearTimeout ( this . tabVisibilityChangedTimer ) ;
this . tabVisibilityChangedTimer = null ;
}
this . tabVisibilityChangedTabs . push ( aEvent . originalTarget ) ;
this . tabVisibilityChangedTimer = window . setTimeout ( function ( aSelf ) {
aSelf . tabVisibilityChangedTimer = null ;
var tabs = aSelf . tabVisibilityChangedTabs ;
aSelf . tabVisibilityChangedTabs = [ ] ;
aSelf . updateTreeByTabVisibility ( tabs ) ;
} , 0 , this ) ;
} ,
tabVisibilityChangedTimer : null ,
tabVisibilityChangedTabs : [ ] ,
updateTreeByTabVisibility : function TSTBrowser _updateTreeByTabVisibility ( aChangedTabs )
{
2010-09-16 09:37:41 -04:00
this . internallyTabMovingCount ++ ;
2010-09-16 06:46:15 -04:00
var tabs = this . getAllTabsArray ( this . mTabBrowser ) ;
2010-09-16 09:37:41 -04:00
aChangedTabs = aChangedTabs || tabs ;
2010-10-13 11:06:41 -04:00
var lastVisibleTab = this . getLastVisibleTab ( this . mTabBrowser ) ;
2010-09-16 06:46:15 -04:00
tabs . reverse ( ) . forEach ( function ( aTab ) {
var parent = this . getParentTab ( aTab ) ;
2010-09-16 09:37:41 -04:00
var attached = false ;
2010-09-16 06:46:15 -04:00
if ( parent && aTab . hidden != parent . hidden ) {
2010-09-16 09:37:41 -04:00
var ancestor = parent ;
var lastNextTab = null ;
while ( ancestor = this . getParentTab ( ancestor ) )
{
if ( ancestor . hidden == aTab . hidden ) {
this . attachTabTo ( aTab , ancestor , {
dontMove : true ,
insertBefore : lastNextTab
} ) ;
attached = true ;
break ;
}
lastNextTab = this . getNextSiblingTab ( ancestor ) ;
}
if ( ! attached ) {
this . collapseExpandTab ( aTab , false , true ) ;
this . partTab ( aTab ) ;
}
2010-09-16 06:46:15 -04:00
}
2010-10-13 11:06:41 -04:00
2010-09-16 09:37:41 -04:00
if (
! aTab . hidden &&
! attached &&
! parent &&
aChangedTabs . indexOf ( aTab ) > - 1
)
2010-09-16 06:46:15 -04:00
this . attachTabFromPosition ( aTab , tabs . length - 1 ) ;
2010-10-13 11:06:41 -04:00
// Hidden tabs have to be moved below visible tabs, because
// sometimes hidden tabs between visible tabs break tree
// structure.
if ( aTab . hidden ) {
let newPos = lastVisibleTab . _tPos ;
if ( aTab . tPos < lastVisibleTab . _tPos ) newPos -- ;
this . mTabBrowser . moveTabTo ( aTab , newPos ) ;
}
2010-09-16 06:46:15 -04:00
} , this ) ;
2010-09-16 09:37:41 -04:00
this . internallyTabMovingCount -- ;
2010-09-16 06:46:15 -04:00
} ,
2009-12-25 03:34:52 -05:00
onTabRestoring : function TSTBrowser _onTabRestoring ( aEvent )
2007-11-14 14:34:36 -05:00
{
2009-10-25 13:31:47 -04:00
this . restoreStructure ( aEvent . originalTarget ) ;
2008-11-09 23:48:11 -05:00
} ,
2009-12-25 15:48:14 -05:00
restoreStructure : function TSTBrowser _restoreStructure ( aTab )
2008-11-09 23:48:11 -05:00
{
2009-10-25 13:58:26 -04:00
/ *
<EFBFBD> E <EFBFBD> B <EFBFBD> <EFBFBD> <EFBFBD> h <EFBFBD> E <EFBFBD> ̕ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ł ͈ ȉ <EFBFBD> <EFBFBD> ̏ <EFBFBD> <EFBFBD> ɏ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> B
nsSessionStore : : restoreWindow ( )
nsSessionStore : : restoreHistoryPrecursor ( )
< <EFBFBD> ^ <EFBFBD> u <EFBFBD> ̕ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> J <EFBFBD> n >
nsSessionStore : : restoreHistory ( ) // <20> <> <EFBFBD> ݂̃^<5E> u<EFBFBD> ̕<EFBFBD> <CC95> <EFBFBD>
( SSTabRestoring DOMEvent fired )
( sessionstore - windows - restored nsIObserver notification )
nsSessionStore : : restoreHistory ( ) // 0<> Ԗڂ̃^<5E> u<EFBFBD> ̕<EFBFBD> <CC95> <EFBFBD>
( SSTabRestoring DOMEvent fired )
...
nsSessionStore : : restoreHistory ( ) // <20> Ō<EFBFBD> <C58C> ̃^<5E> u<EFBFBD> ̕<EFBFBD> <CC95> <EFBFBD>
( SSTabRestoring DOMEvent fired )
< <EFBFBD> ^ <EFBFBD> u <EFBFBD> ̕ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> I <EFBFBD> <EFBFBD> >
nsSessionStore : : restoreDocument _proxy ( ) // <20> ŏ<EFBFBD> <C58F> ̃^<5E> u<EFBFBD> ̕<EFBFBD> <CC95> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
( SSTabRestored DOMEvent fired )
...
nsSessionStore : : restoreDocument _proxy ( ) // <20> Ō<EFBFBD> <C58C> ̃^<5E> u<EFBFBD> ̕<EFBFBD> <CC95> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
( SSTabRestored DOMEvent fired )
< <EFBFBD> ^ <EFBFBD> u <EFBFBD> ̕ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> >
<EFBFBD> <EFBFBD> <EFBFBD> ̎ <EFBFBD> <EFBFBD> AnsSessionStore : : restoreHistoryPrecursor ( ) <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
nsSessionStore : : restoreHistory ( ) <EFBFBD> <EFBFBD> <EFBFBD> Ă <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> O <EFBFBD> Ɂ A
<EFBFBD> <EFBFBD> <EFBFBD> ꂩ <EFBFBD> 畜 <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 邷 <EFBFBD> ׂ Ă ̃ ^ <EFBFBD> u <EFBFBD> ɂ <EFBFBD> <EFBFBD> <EFBFBD>
2010-01-28 11:33:00 -05:00
tab . linkedBrowser . _ _SS _data . _tabStillLoading ( Firefox 3.6 - )
<EFBFBD> ܂ <EFBFBD> <EFBFBD> <EFBFBD>
tab . linkedBrowser . parentNode . _ _SS _data . _tabStillLoading ( - Firefox 3.5 )
2009-10-25 13:58:26 -04:00
<EFBFBD> <EFBFBD> true <EFBFBD> ɃZ <EFBFBD> b <EFBFBD> g <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> B
<EFBFBD> <EFBFBD> <EFBFBD> ̃ ^ <EFBFBD> u <EFBFBD> ̓ ǂݍ <EFBFBD> <EFBFBD> ݂ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> A
2010-01-28 11:33:00 -05:00
tab . linkedBrowser . _ _SS _data ( Firefox 3.6 - )
<EFBFBD> ܂ <EFBFBD> <EFBFBD> <EFBFBD>
tab . linkedBrowser . parentNode . _ _SS _data ( - Firefox 3.5 )
2009-10-25 13:58:26 -04:00
<EFBFBD> <EFBFBD> delete <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> B
<EFBFBD> ȏ <EFBFBD> <EFBFBD> ̂ <EFBFBD> <EFBFBD> Ƃ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Asessionstore - windows - restored <EFBFBD> <EFBFBD> <EFBFBD> ʒm <EFBFBD> <EFBFBD> <EFBFBD> ꂽ <EFBFBD> i <EFBFBD> K <EFBFBD> <EFBFBD>
_tabStillLoading <EFBFBD> <EFBFBD> true <EFBFBD> ł <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> <EFBFBD> <EFBFBD> E <EFBFBD> B <EFBFBD> <EFBFBD> <EFBFBD> h <EFBFBD> E <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 2 <EFBFBD> ȏ㑶 <EFBFBD> ݂ <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> A <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ́ A <EFBFBD> <EFBFBD> <EFBFBD> ̃ E <EFBFBD> B <EFBFBD> <EFBFBD> <EFBFBD> h <EFBFBD> E <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ł <EFBFBD> <EFBFBD> 邱 <EFBFBD> Ƃ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ؋ <EFBFBD> <EFBFBD> ƂȂ <EFBFBD> <EFBFBD> B
2010-01-29 02:54:17 -05:00
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> āArestoringTree <EFBFBD> <EFBFBD> true <EFBFBD> ɐݒ肷 <EFBFBD> <EFBFBD> <EFBFBD> B
2009-10-25 13:58:26 -04:00
2010-01-29 02:54:17 -05:00
restoringTree <EFBFBD> <EFBFBD> true <EFBFBD> ł <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ꍇ <EFBFBD> ́ ASSTabRestored <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> s <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> x <EFBFBD> <EFBFBD>
2009-10-25 13:58:26 -04:00
_tabStillLoading <EFBFBD> <EFBFBD> true <EFBFBD> ł <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ^ <EFBFBD> u <EFBFBD> ̐ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> m <EFBFBD> F <EFBFBD> <EFBFBD> <EFBFBD> A <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> 1 <EFBFBD> ȉ <EFBFBD> <EFBFBD> ł <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2010-01-29 02:54:17 -05:00
restoringTree <EFBFBD> <EFBFBD> false <EFBFBD> ɂ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> B
2009-10-25 13:58:26 -04:00
2010-01-29 02:54:17 -05:00
restoringTree <EFBFBD> ́ A <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> sessionstore - windows - restored <EFBFBD> <EFBFBD> <EFBFBD> ʒm <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
2009-10-25 13:58:26 -04:00
<EFBFBD> ܂ ł <EFBFBD> true <EFBFBD> ɂȂ邱 <EFBFBD> Ƃ ͂ Ȃ <EFBFBD> <EFBFBD> B <EFBFBD> <EFBFBD> <EFBFBD> ̂ <EFBFBD> <EFBFBD> ߁A <EFBFBD> 蓮 <EFBFBD> ŘA <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ă ^ <EFBFBD> u <EFBFBD> <EFBFBD>
<EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> Ƃ <EFBFBD> <EFBFBD> Ă <EFBFBD> <EFBFBD> A <EFBFBD> <EFBFBD> <EFBFBD> ꂪ <EFBFBD> E <EFBFBD> B <EFBFBD> <EFBFBD> <EFBFBD> h <EFBFBD> E <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ̃ ^ <EFBFBD> u <EFBFBD> ̕ <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ƌ <EFBFBD> <EFBFBD> F <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD>
<EFBFBD> S <EFBFBD> z <EFBFBD> ͂ Ȃ <EFBFBD> <EFBFBD> B
* /
2010-01-29 02:54:17 -05:00
var restoringMultipleTabs = TreeStyleTabService . restoringTree ;
2009-10-25 13:31:47 -04:00
2008-11-09 23:48:11 -05:00
var tab = aTab ;
2007-11-14 14:34:36 -05:00
var b = this . mTabBrowser ;
2009-09-29 10:31:02 -04:00
var id = this . getTabValue ( tab , this . kID ) ;
2009-09-29 11:05:08 -04:00
var mayBeDuplicated = false ;
2007-11-17 07:50:36 -05:00
2009-09-29 19:54:57 -04:00
tab . setAttribute ( this . kID _RESTORING , id ) ;
if ( this . isTabDuplicated ( tab ) ) {
2009-09-29 11:05:08 -04:00
mayBeDuplicated = true ;
2008-11-10 00:21:34 -05:00
id = this . redirectId ( id ) ;
2007-11-17 07:50:36 -05:00
}
2009-09-29 19:54:57 -04:00
tab . removeAttribute ( this . kID _RESTORING ) ;
2007-11-17 07:50:36 -05:00
2009-10-26 12:13:24 -04:00
var children = this . getTabValue ( tab , this . kCHILDREN ) ;
if ( ! mayBeDuplicated || tab . hasAttribute ( this . kCHILDREN ) ) {
// for safety
2009-12-16 12:52:25 -05:00
this . partAllChildren ( tab , {
dontUpdateIndent : true ,
dontAnimate : restoringMultipleTabs
} ) ;
2009-10-26 12:13:24 -04:00
}
2009-12-25 15:48:14 -05:00
var closeSetId = null ;
2009-09-29 11:05:08 -04:00
if ( ! mayBeDuplicated ) {
2009-12-25 15:48:14 -05:00
closeSetId = this . getTabValue ( tab , this . kCLOSED _SET _ID ) ;
2007-11-23 16:34:43 -05:00
/ * I f i t h a s a p a r e n t , i t i s w r o n g l y a t t a c c h e d b y t a b m o v i n g
on restoring . Restoring the old ID ( the next statement )
breaks the children list of the temporary parent and causes
many problems . So , to prevent these problems , I part the tab
2010-09-09 04:26:32 -04:00
from the temporary parent manually .
If the ID stored in the session equals to the value of the
attribute stored in the element itself , then don ' t reset the
tab , because the restoring session is got from the tab itself .
( like SS . setTabState ( tab , SS . getTabState ( tab ) ) )
* /
if ( id != tab . getAttribute ( this . kID ) )
this . resetTab ( tab , false ) ;
2007-11-23 16:34:43 -05:00
}
2009-12-25 15:48:14 -05:00
this . deleteTabValue ( tab , this . kCLOSED _SET _ID ) ;
2007-11-15 08:11:26 -05:00
2009-09-29 13:07:02 -04:00
this . setTabValue ( tab , this . kID , id ) ;
2010-03-24 11:38:08 -04:00
this . tabsHash [ id ] = tab ;
2007-11-14 14:34:36 -05:00
2009-12-25 15:48:14 -05:00
if ( closeSetId )
this . restoreClosedSet ( closeSetId , tab ) ;
2009-12-25 06:19:50 -05:00
var isSubtreeCollapsed = restoringMultipleTabs && ( this . getTabValue ( tab , this . kSUBTREE _COLLAPSED ) == 'true' ) ;
this . setTabValue ( tab , this . kSUBTREE _COLLAPSED , isSubtreeCollapsed ) ;
2007-11-14 14:34:36 -05:00
2007-11-15 08:01:07 -05:00
var tabs = [ ] ;
2007-11-14 14:34:36 -05:00
if ( children ) {
2008-02-23 21:01:50 -05:00
tab . removeAttribute ( this . kCHILDREN ) ;
2007-11-14 14:34:36 -05:00
children = children . split ( '|' ) ;
2009-09-29 13:07:02 -04:00
if ( mayBeDuplicated )
2008-02-23 20:06:19 -05:00
children = children . map ( function ( aChild ) {
2008-11-10 00:21:34 -05:00
return this . redirectId ( aChild ) ;
2008-10-17 08:35:55 -04:00
} , this ) ;
2009-04-20 07:25:14 -04:00
children . forEach ( function ( aTab ) {
if ( aTab && ( aTab = this . getTabById ( aTab ) ) ) {
2009-08-26 05:33:54 -04:00
this . attachTabTo ( aTab , tab , {
2009-10-25 13:31:47 -04:00
dontExpand : restoringMultipleTabs ,
2009-08-26 05:33:54 -04:00
dontUpdateIndent : true ,
2009-10-25 13:31:47 -04:00
dontAnimate : restoringMultipleTabs
2009-08-26 05:33:54 -04:00
} ) ;
2009-04-20 07:25:14 -04:00
tabs . push ( aTab ) ;
2007-11-14 14:34:36 -05:00
}
2009-04-20 07:25:14 -04:00
} , this ) ;
2009-09-29 19:54:57 -04:00
children = children . join ( '|' ) ;
if ( tab . getAttribute ( this . kCHILDREN ) == children )
tab . removeAttribute ( this . kCHILDREN _RESTORING ) ;
else
tab . setAttribute ( this . kCHILDREN _RESTORING , children ) ;
2007-11-14 14:34:36 -05:00
}
2008-04-29 14:17:44 -04:00
var nextTab = this . getTabValue ( tab , this . kINSERT _BEFORE ) ;
2009-09-29 13:07:02 -04:00
if ( nextTab && mayBeDuplicated ) nextTab = this . redirectId ( nextTab ) ;
2009-07-08 06:40:51 -04:00
nextTab = this . getTabById ( nextTab ) ;
2007-11-17 07:50:36 -05:00
2009-09-01 22:52:16 -04:00
if ( ! nextTab ) {
2009-09-29 19:54:57 -04:00
let prevTab = this . getTabValue ( tab , this . kINSERT _AFTER ) ;
2009-09-29 13:07:02 -04:00
if ( prevTab && mayBeDuplicated ) prevTab = this . redirectId ( prevTab ) ;
2009-09-29 19:54:57 -04:00
prevTab = this . getTabById ( prevTab ) ;
nextTab = this . getNextSiblingTab ( prevTab ) ;
2009-09-01 22:52:16 -04:00
}
2009-03-16 09:43:06 -04:00
var ancestors = ( this . getTabValue ( tab , this . kANCESTOR ) || this . getTabValue ( tab , this . kPARENT ) ) . split ( '|' ) ;
2007-11-26 14:55:58 -05:00
var parent = null ;
for ( var i in ancestors )
{
2009-09-29 13:07:02 -04:00
if ( mayBeDuplicated ) ancestors [ i ] = this . redirectId ( ancestors [ i ] ) ;
2007-11-26 14:55:58 -05:00
parent = this . getTabById ( ancestors [ i ] ) ;
if ( parent ) {
parent = ancestors [ i ] ;
break ;
}
}
2007-11-26 16:17:46 -05:00
this . deleteTabValue ( tab , this . kANCESTOR ) ;
2007-11-26 14:55:58 -05:00
2007-11-14 14:34:36 -05:00
if ( parent ) {
2008-02-23 21:01:50 -05:00
tab . removeAttribute ( this . kPARENT ) ;
2007-11-14 14:34:36 -05:00
parent = this . getTabById ( parent ) ;
if ( parent ) {
this . attachTabTo ( tab , parent , {
2009-10-25 13:31:47 -04:00
dontExpand : restoringMultipleTabs ,
2009-09-30 20:10:58 -04:00
insertBefore : nextTab ,
2009-08-26 05:33:54 -04:00
dontUpdateIndent : true ,
2009-10-25 13:31:47 -04:00
dontAnimate : restoringMultipleTabs
2007-11-14 14:34:36 -05:00
} ) ;
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( [ tab ] , undefined , restoringMultipleTabs ) ;
2007-11-14 14:34:36 -05:00
this . checkTabsIndentOverflow ( ) ;
2009-09-29 19:54:57 -04:00
2009-09-30 01:36:08 -04:00
if ( parent . getAttribute ( this . kCHILDREN _RESTORING ) )
this . correctChildTabsOrderWithDelay ( parent ) ;
2010-11-19 00:07:19 -05:00
2007-11-14 14:34:36 -05:00
}
else {
this . deleteTabValue ( tab , this . kPARENT ) ;
}
}
else if ( children ) {
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( tabs , undefined , restoringMultipleTabs ) ;
2007-11-14 14:34:36 -05:00
this . checkTabsIndentOverflow ( ) ;
}
2008-04-29 14:17:44 -04:00
if ( ! parent ) {
2009-09-30 20:10:58 -04:00
if ( ! nextTab ) nextTab = this . getNextTab ( tab ) ;
2009-09-29 20:26:29 -04:00
let parentOfNext = this . getParentTab ( nextTab ) ;
let newPos = - 1 ;
2008-04-29 14:17:44 -04:00
if ( parentOfNext ) {
2009-09-29 20:26:29 -04:00
let descendants = this . getDescendantTabs ( parentOfNext ) ;
2008-04-29 14:17:44 -04:00
newPos = descendants [ descendants . length - 1 ] . _tPos ;
}
else if ( nextTab ) {
2009-09-29 20:26:29 -04:00
newPos = nextTab . _tPos ;
2008-04-29 14:17:44 -04:00
if ( newPos > tab . _tPos ) newPos -- ;
}
if ( newPos > - 1 )
b . moveTabTo ( tab , newPos ) ;
2007-11-14 14:34:36 -05:00
}
2009-12-25 15:48:14 -05:00
if ( isSubtreeCollapsed )
2009-12-25 06:19:50 -05:00
this . collapseExpandSubtree ( tab , isSubtreeCollapsed , restoringMultipleTabs ) ;
2008-02-22 16:52:44 -05:00
2009-12-25 15:48:14 -05:00
if ( mayBeDuplicated )
this . clearRedirectionTable ( ) ;
2008-02-23 20:06:19 -05:00
} ,
2009-12-25 15:48:14 -05:00
correctChildTabsOrderWithDelay : function TSTBrowser _correctChildTabsOrderWithDelay ( aTab )
2009-09-30 01:36:08 -04:00
{
if ( aTab . correctChildTabsOrderWithDelayTimer )
window . clearTimeout ( aTab . correctChildTabsOrderWithDelayTimer ) ;
aTab . correctChildTabsOrderWithDelayTimer = window . setTimeout ( function ( aSelf ) {
aSelf . correctChildTabsOrder ( aTab ) ;
2009-09-30 04:14:54 -04:00
} , 10 , this ) ;
2009-09-30 01:36:08 -04:00
} ,
2009-12-25 15:48:14 -05:00
correctChildTabsOrder : function TSTBrowser _correctChildTabsOrder ( aTab )
2009-09-30 01:36:08 -04:00
{
var restoringChildren = aTab . getAttribute ( this . kCHILDREN _RESTORING ) ;
if ( ! restoringChildren ) return ;
var children = aTab . getAttribute ( this . kCHILDREN ) ;
if ( restoringChildren != children ) {
var restoringChildrenIDs = restoringChildren . split ( '|' ) ;
restoringChildrenIDs . reverse ( ) . forEach ( function ( aChild , aIndex ) {
aChild = this . getTabById ( aChild ) ;
if ( ! aChild ) return ;
let nextTab = aIndex > 0 ?
this . getTabById ( restoringChildrenIDs [ aIndex - 1 ] ) :
this . getNextSiblingTab ( aTab ) ;
if ( nextTab == this . getNextSiblingTab ( aChild ) ) return ;
2009-09-30 20:18:03 -04:00
let newPos = - 1 ;
2009-09-30 01:36:08 -04:00
if ( nextTab ) {
newPos = nextTab . _tPos ;
if ( newPos > aChild . _tPos ) newPos -- ;
}
2009-09-30 20:18:03 -04:00
if ( newPos > - 1 )
2009-12-25 06:19:50 -05:00
this . moveTabSubtreeTo ( aChild , newPos ) ;
2009-09-30 01:36:08 -04:00
} , this ) ;
children = aTab . getAttribute ( this . kCHILDREN ) ;
}
if ( restoringChildren == children )
aTab . removeAttribute ( this . kCHILDREN _RESTORING ) ;
aTab . correctChildTabsOrderWithDelayTimer = null ;
} ,
2009-12-25 15:48:14 -05:00
2009-12-25 03:34:52 -05:00
redirectId : function TSTBrowser _redirectId ( aId )
2008-02-23 20:06:19 -05:00
{
2008-11-10 00:21:34 -05:00
if ( ! ( aId in this . _redirectionTable ) )
this . _redirectionTable [ aId ] = this . makeNewId ( ) ;
return this . _redirectionTable [ aId ] ;
2008-02-23 20:06:19 -05:00
} ,
2008-11-10 00:21:34 -05:00
_redirectionTable : { } ,
2008-02-24 02:58:12 -05:00
2009-12-25 03:34:52 -05:00
clearRedirectionTable : function TSTBrowser _clearRedirectionTable ( )
2008-02-23 20:06:19 -05:00
{
2008-11-10 00:21:34 -05:00
if ( this . _clearRedirectionTableTimer ) {
window . clearTimeout ( this . _clearRedirectionTableTimer ) ;
this . _clearRedirectionTableTimer = null ;
2008-02-23 20:06:19 -05:00
}
2008-11-10 00:21:34 -05:00
this . _clearRedirectionTableTimer = window . setTimeout ( function ( aSelf ) {
aSelf . _redirectionTable = { } ;
2008-02-23 20:06:19 -05:00
} , 1000 , this ) ;
} ,
2008-11-10 00:21:34 -05:00
_clearRedirectionTableTimer : null ,
2009-12-25 15:48:14 -05:00
2010-03-03 08:30:49 -05:00
restoreClosedSet : function TSTBrowser _restoreClosedSet ( aId , aRestoredTab )
2009-12-25 15:48:14 -05:00
{
2010-11-10 11:14:04 -05:00
var behavior = this . undoCloseTabSetBehavior ;
2009-12-25 15:48:14 -05:00
if (
2010-01-14 03:50:10 -05:00
aRestoredTab . _ _treestyletab _ _restoredByUndoCloseTab ||
! this . browser . _ _treestyletab _ _readyToUndoCloseTab ||
2009-12-25 15:48:14 -05:00
this . useTMPSessionAPI ||
this . _restoringClosedSet ||
2009-12-26 23:56:16 -05:00
! ( behavior & this . kUNDO _CLOSE _SET || behavior & this . kUNDO _ASK )
2009-12-25 15:48:14 -05:00
)
return ;
var items = this . evalInSandbox ( '(' + this . SessionStore . getClosedTabData ( window ) + ')' ) ;
var indexes = [ ] ;
items . forEach ( function ( aItem , aIndex ) {
if ( aItem . state . extData &&
aItem . state . extData [ this . kCLOSED _SET _ID ] &&
aItem . state . extData [ this . kCLOSED _SET _ID ] == aId )
indexes . push ( aIndex ) ;
} , this ) ;
2009-12-25 16:10:25 -05:00
var count = parseInt ( aId . split ( '::' ) [ 1 ] ) ;
2009-12-25 16:09:52 -05:00
if (
! indexes . length ||
(
indexes . length + 1 < count &&
2009-12-26 23:56:16 -05:00
behavior & this . kUNDO _CLOSE _FULL _SET
2010-11-10 11:14:04 -05:00
)
2009-12-25 16:09:52 -05:00
)
2010-11-10 09:02:53 -05:00
return ;
2010-11-10 12:13:18 -05:00
if ( behavior & this . kUNDO _ASK ) {
let self = this ;
aRestoredTab . addEventListener ( 'SSTabRestored' , function ( aEvent ) {
aRestoredTab . removeEventListener ( aEvent . type , arguments . callee , false ) ;
self . askUndoCloseTabSetBehavior ( aRestoredTab , indexes . length )
. next ( function ( aBehavior ) {
if ( aBehavior & self . kUNDO _CLOSE _SET )
self . doRestoreClosedSet ( aRestoredTab , indexes ) ;
} ) ;
} , false ) ;
}
else if ( behavior & this . kUNDO _CLOSE _SET ) {
this . doRestoreClosedSet ( aRestoredTab , indexes ) ;
}
2010-11-10 09:02:53 -05:00
} ,
doRestoreClosedSet : function TSTBrowser _doRestoreClosedSet ( aRestoredTab , aIndexes )
2010-11-10 11:14:04 -05:00
{
2010-11-10 09:02:53 -05:00
if (
'_confirmOpenInTabs' in PlacesUIUtils &&
PlacesUIUtils . _confirmOpenInTabs &&
! PlacesUIUtils . _confirmOpenInTabs ( aIndexes . length )
2009-12-25 16:09:52 -05:00
)
return ;
2009-12-25 15:48:14 -05:00
this . _restoringClosedSet = true ;
this . stopRendering ( ) ;
2010-01-29 02:54:17 -05:00
TreeStyleTabService . restoringTree = true ;
2009-12-25 15:48:14 -05:00
var offset = 0 ;
2010-11-10 09:02:53 -05:00
aIndexes . forEach ( function ( aIndex ) {
2009-12-25 15:48:14 -05:00
undoCloseTab ( aIndex - ( offset ++ ) ) ;
} ) ;
2009-12-25 22:34:13 -05:00
window . setTimeout ( function ( aSelf , aNextFocused ) {
aSelf . mTabBrowser . selectedTab = aNextFocused ;
} , 0 , this , aRestoredTab || aSelf . mTabBrowser . selectedTab ) ;
2009-12-25 15:48:14 -05:00
this . startRendering ( ) ;
this . _restoringClosedSet = false ;
} ,
_restoringClosedSet : false ,
2008-03-03 04:21:33 -05:00
2009-12-25 03:34:52 -05:00
onTabRestored : function TSTBrowser _onTabRestored ( aEvent )
2009-10-25 13:31:47 -04:00
{
2010-01-14 03:50:10 -05:00
delete aEvent . originalTarget . _ _treestyletab _ _restoredByUndoCloseTab ;
2009-10-25 13:31:47 -04:00
// update the status for the next restoring
2010-01-29 02:54:17 -05:00
if ( ! this . useTMPSessionAPI && TreeStyleTabService . restoringTree )
TreeStyleTabService . restoringTree = TreeStyleTabService . getRestoringTabsCount ( ) > 0 ;
2009-10-25 13:31:47 -04:00
} ,
2010-09-09 05:02:26 -04:00
onDOMAttrModified : function TSTBrowser _onDOMAttrModified ( aEvent )
{
switch ( aEvent . attrName )
{
case 'pinned' :
let ( tab = aEvent . originalTarget ) {
if ( tab . localName != 'tab' )
return ;
if ( aEvent . newValue == 'true' )
this . onPinTab ( tab ) ;
else
this . onUnpinTab ( tab ) ;
}
return ;
default :
return ;
}
} ,
2009-12-25 03:34:52 -05:00
onTabSelect : function TSTBrowser _onTabSelect ( aEvent )
2007-11-14 14:34:36 -05:00
{
var b = this . mTabBrowser ;
var tab = b . selectedTab
2010-04-06 10:28:51 -04:00
/ * < t a b b r o w s e r > . p r e v i e w T a b ( ) f o c u s e s t o t h e t a b i n t e r n a l l y ,
so we should ignore this event if it is fired from previewTab ( ) . * /
if ( b . _previewMode )
return ;
2009-10-25 22:36:42 -04:00
if ( this . isCollapsed ( tab ) ) {
2009-12-25 06:27:23 -05:00
if ( this . getTreePref ( 'autoExpandSubtreeOnCollapsedChildFocused' ) ) {
2009-07-09 01:03:07 -04:00
var parentTab = tab ;
while ( parentTab = this . getParentTab ( parentTab ) )
{
this . collapseExpandSubtree ( parentTab , false ) ;
}
2009-08-14 02:16:40 -04:00
this . collapseExpandTreesIntelligentlyWithDelayFor ( tab ) ;
2009-07-09 01:03:07 -04:00
}
else {
b . selectedTab = this . getRootTab ( tab ) ;
2007-11-14 14:34:36 -05:00
}
}
2009-08-14 02:12:08 -04:00
else if (
2009-12-25 06:27:23 -05:00
this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect' ) &&
2009-08-14 02:12:08 -04:00
(
! this . _focusChangedByCurrentTabRemove ||
2009-12-25 06:27:23 -05:00
this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect.onCurrentTabRemove' )
2009-08-14 02:12:08 -04:00
)
) {
2009-10-25 22:36:42 -04:00
if ( ! this . hasChildTabs ( tab ) || ! this . isSubtreeCollapsed ( tab ) )
2009-08-14 02:12:08 -04:00
tab = null ;
if (
this . _focusChangedByShortcut &&
this . accelKeyPressed &&
2009-12-25 06:27:23 -05:00
! this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect.whileFocusMovingByShortcut' )
2009-08-14 02:12:08 -04:00
) {
TreeStyleTabService . expandTreeAfterKeyReleased ( tab ) ;
}
else {
2009-07-06 21:53:19 -04:00
this . collapseExpandTreesIntelligentlyWithDelayFor ( tab ) ;
2009-08-14 02:12:08 -04:00
}
2007-11-14 14:34:36 -05:00
}
2009-07-06 21:53:19 -04:00
this . _focusChangedByCurrentTabRemove = false ;
2009-08-14 02:12:08 -04:00
this . _focusChangedByShortcut = false ;
2009-07-06 21:53:19 -04:00
2008-03-03 04:21:33 -05:00
this . updateInvertedTabContentsOrder ( ) ;
2007-11-14 14:34:36 -05:00
} ,
2010-03-02 09:40:12 -05:00
onTabClick : function TSTBrowser _onTabClick ( aEvent , aTab )
2007-11-14 14:34:36 -05:00
{
2010-03-02 09:40:12 -05:00
aTab = aTab || this . getTabFromEvent ( aEvent ) ;
2009-12-18 00:56:41 -05:00
if ( aEvent . button == 1 ) {
2010-03-02 09:40:12 -05:00
if ( ! this . warnAboutClosingTabSubtreeOf ( aTab ) ) {
2009-12-18 00:56:41 -05:00
aEvent . preventDefault ( ) ;
aEvent . stopPropagation ( ) ;
}
return ;
}
if ( aEvent . button != 0 )
return ;
2007-11-14 14:34:36 -05:00
2008-12-03 07:48:42 -05:00
if ( this . isEventFiredOnTwisty ( aEvent ) ) {
2010-11-29 03:24:45 -05:00
if ( this . hasChildTabs ( aTab ) && this . canCollapseSubtree ( aTab ) ) {
2010-03-02 09:40:12 -05:00
this . collapseExpandSubtree ( aTab , aTab . getAttribute ( this . kSUBTREE _COLLAPSED ) != 'true' ) ;
2009-04-26 22:18:17 -04:00
aEvent . preventDefault ( ) ;
aEvent . stopPropagation ( ) ;
}
2009-12-18 00:46:20 -05:00
return ;
}
if ( this . isEventFiredOnClosebox ( aEvent ) ) {
2010-03-02 09:40:12 -05:00
if ( ! this . warnAboutClosingTabSubtreeOf ( aTab ) ) {
2009-12-18 00:52:47 -05:00
aEvent . preventDefault ( ) ;
aEvent . stopPropagation ( ) ;
2009-12-18 00:46:20 -05:00
}
return ;
2008-12-03 07:48:42 -05:00
}
2007-11-14 14:34:36 -05:00
} ,
2009-12-25 03:34:52 -05:00
getTabFromTabbarEvent : function TSTBrowser _getTabFromTabbarEvent ( aEvent )
2008-12-03 08:05:01 -05:00
{
2009-03-24 13:44:30 -04:00
if (
! this . shouldDetectClickOnIndentSpaces ||
2010-09-12 23:54:04 -04:00
this . isEventFiredOnClickable ( aEvent ) ||
this . getSplitterFromEvent ( aEvent )
2009-03-24 13:44:30 -04:00
)
2008-12-14 21:59:51 -05:00
return null ;
2008-12-03 08:17:40 -05:00
2008-12-03 08:05:01 -05:00
var tab = null ;
var clickedPoint = aEvent [ this . positionProp ] ;
2009-01-24 00:39:22 -05:00
this . getTabsArray ( this . mTabBrowser ) . some ( function ( aTab ) {
2008-12-03 08:05:01 -05:00
var box = aTab . boxObject ;
if ( box [ this . positionProp ] > clickedPoint ||
box [ this . positionProp ] + box [ this . sizeProp ] < clickedPoint ) {
return false ;
}
tab = aTab ;
return true ;
} , this ) ;
return tab ;
} ,
2007-11-14 14:34:36 -05:00
2010-03-02 09:40:12 -05:00
onClick : function TSTBrowser _onClick ( aEvent )
{
2010-04-08 19:24:02 -04:00
if (
2010-04-08 19:45:09 -04:00
aEvent . target . ownerDocument != document ||
2010-04-08 19:24:02 -04:00
aEvent . button != 0 ||
this . isAccelKeyPressed ( aEvent )
)
2010-03-02 09:40:12 -05:00
return ;
var tab = this . getTabFromEvent ( aEvent ) ;
if ( tab ) {
this . onTabClick ( aEvent , tab ) ;
}
else {
// click on indented space on the tab bar
tab = this . getTabFromTabbarEvent ( aEvent ) ;
if ( tab ) this . mTabBrowser . selectedTab = tab ;
}
} ,
2009-12-25 03:34:52 -05:00
onDblClick : function TSTBrowser _onDblClick ( aEvent )
2009-05-13 02:09:17 -04:00
{
2010-09-12 23:54:04 -04:00
let tab = this . getTabFromEvent ( aEvent ) ;
if ( tab &&
this . hasChildTabs ( tab ) &&
this . getTreePref ( 'collapseExpandSubtree.dblclick' ) ) {
this . collapseExpandSubtree ( tab , tab . getAttribute ( this . kSUBTREE _COLLAPSED ) != 'true' ) ;
aEvent . preventDefault ( ) ;
aEvent . stopPropagation ( ) ;
2009-05-13 02:09:17 -04:00
}
} ,
2010-07-01 23:39:31 -04:00
onMozMouseHittest : function TSTBrowser _onMozMouseHittest ( aEvent )
2007-11-14 14:34:36 -05:00
{
2010-07-01 23:39:31 -04:00
// block default behaviors of the tab bar (dragging => window move, etc.)
2010-06-25 13:43:30 -04:00
if (
2010-09-14 22:58:36 -04:00
! this . getTabFromEvent ( aEvent ) &&
! this . isEventFiredOnClickable ( aEvent ) &&
(
this . currentTabbarPosition != 'top' ||
aEvent . shiftKey ||
this . tabbarDNDObserver . canDragTabbar ( aEvent )
)
2010-09-14 20:34:28 -04:00
)
2010-06-25 13:43:30 -04:00
aEvent . stopPropagation ( ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-05-13 02:09:17 -04:00
2010-07-01 23:39:31 -04:00
onMouseDown : function TSTBrowser _onMouseDown ( aEvent )
{
if (
aEvent . button == 0 &&
this . isEventFiredOnTwisty ( aEvent )
) {
this . getTabFromEvent ( aEvent ) . _ _treestyletab _ _preventSelect = true ;
}
else {
this . onMozMouseHittest ( aEvent ) ;
}
} ,
2009-12-25 03:34:52 -05:00
onScroll : function TSTBrowser _onScroll ( aEvent )
2009-05-13 02:09:17 -04:00
{
2009-09-03 03:45:06 -04:00
if ( this . lastScrollX < 0 || this . lastScrollY < 0 ) return ;
var x = { } , y = { } ;
var scrollBoxObject = this . scrollBoxObject ;
scrollBoxObject . getPosition ( x , y ) ;
if ( x . value != this . lastScrollX || y . value != this . lastScrollY )
scrollBoxObject . scrollTo ( this . lastScrollX , this . lastScrollY ) ;
this . lastScrollX = - 1 ;
this . lastScrollY = - 1 ;
2009-05-13 02:09:17 -04:00
} ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
onTabbarOverflow : function TSTBrowser _onTabbarOverflow ( aEvent )
2009-03-24 13:44:30 -04:00
{
var tabs = this . mTabBrowser . mTabContainer ;
var horizontal = tabs . orient == 'horizontal' ;
if ( horizontal ) return ;
aEvent . stopPropagation ( ) ;
if ( aEvent . detail == 1 ) return ;
if ( aEvent . type == 'overflow' ) {
tabs . setAttribute ( 'overflow' , 'true' ) ;
2009-04-28 00:55:59 -04:00
this . scrollBoxObject . ensureElementIsVisible ( tabs . selectedItem ) ;
2009-03-24 13:44:30 -04:00
}
else {
tabs . removeAttribute ( 'overflow' ) ;
}
} ,
2010-03-23 15:10:53 -04:00
onResize : function TSTBrowser _onResize ( aEvent )
{
if (
! aEvent . originalTarget ||
2010-03-24 11:45:57 -04:00
! ( aEvent . originalTarget instanceof Ci . nsIDOMWindow )
2010-03-23 15:10:53 -04:00
)
return ;
2010-03-25 06:04:47 -04:00
this . updateFloatingTabbar ( ) ;
2010-03-23 15:10:53 -04:00
} ,
2009-12-25 03:34:52 -05:00
onPopupShowing : function TSTBrowser _onPopupShowing ( aEvent )
2009-03-24 13:44:30 -04:00
{
2010-04-30 00:49:00 -04:00
if ( aEvent . target == aEvent . currentTarget )
this . initTabContextMenu ( aEvent ) ;
2009-03-24 13:44:30 -04:00
} ,
2009-12-25 03:34:52 -05:00
initTabContextMenu : function TSTBrowser _initTabContextMenu ( aEvent )
2007-11-14 14:34:36 -05:00
{
var b = this . mTabBrowser ;
2009-07-06 05:21:06 -04:00
var sep , items = { } ;
[
this . kMENUITEM _RELOADSUBTREE ,
this . kMENUITEM _RELOADCHILDREN ,
this . kMENUITEM _REMOVESUBTREE ,
this . kMENUITEM _REMOVECHILDREN ,
this . kMENUITEM _COLLAPSE ,
this . kMENUITEM _EXPAND ,
this . kMENUITEM _AUTOHIDE ,
this . kMENUITEM _FIXED ,
this . kMENUITEM _BOOKMARKSUBTREE
] . forEach ( function ( aID ) {
let item = this . evaluateXPath (
'descendant::xul:*[starts-with(@id, "' + aID + '")]' ,
aEvent . currentTarget ,
XPathResult . FIRST _ORDERED _NODE _TYPE
) . singleNodeValue ;
items [ aID ] = item ;
if ( this . getTreePref ( 'show.' + aID ) )
item . removeAttribute ( 'hidden' ) ;
else
item . setAttribute ( 'hidden' , true ) ;
2009-07-07 04:31:00 -04:00
switch ( aID )
{
case this . kMENUITEM _RELOADSUBTREE :
case this . kMENUITEM _RELOADCHILDREN :
case this . kMENUITEM _REMOVESUBTREE :
case this . kMENUITEM _REMOVECHILDREN :
case this . kMENUITEM _COLLAPSE :
case this . kMENUITEM _EXPAND :
case this . kMENUITEM _BOOKMARKSUBTREE :
2009-12-25 06:19:50 -05:00
this . showHideSubtreeMenuItem ( item , [ b . mContextTab ] ) ;
2009-07-07 04:31:00 -04:00
break ;
default :
break ;
}
2009-07-06 05:21:06 -04:00
} , this ) ;
2007-11-26 10:07:10 -05:00
2007-11-17 01:05:23 -05:00
// collapse/expand all
sep = this . evaluateXPath (
'descendant::xul:menuseparator[starts-with(@id, "' + this . kMENUITEM _COLLAPSEEXPAND _SEPARATOR + '")]' ,
aEvent . currentTarget ,
XPathResult . FIRST _ORDERED _NODE _TYPE
) . singleNodeValue ;
2009-07-07 11:34:14 -04:00
let collapseItem = items [ this . kMENUITEM _COLLAPSE ] ;
let expanndItem = items [ this . kMENUITEM _EXPAND ] ;
2009-10-25 22:47:38 -04:00
if ( this . canCollapseSubtree ( b ) &&
2009-10-25 22:36:42 -04:00
this . evaluateXPath (
2007-11-17 01:05:23 -05:00
'child::xul:tab[@' + this . kCHILDREN + ']' ,
b . mTabContainer
) . snapshotLength ) {
2009-07-06 05:21:06 -04:00
if ( this . evaluateXPath (
'child::xul:tab[@' + this . kCHILDREN + ' and not(@' + this . kSUBTREE _COLLAPSED + '="true")]' ,
b . mTabContainer
) . snapshotLength )
collapseItem . removeAttribute ( 'disabled' ) ;
else
collapseItem . setAttribute ( 'disabled' , true ) ;
2007-11-17 01:05:23 -05:00
2009-07-06 05:21:06 -04:00
if ( this . evaluateXPath (
'child::xul:tab[@' + this . kCHILDREN + ' and @' + this . kSUBTREE _COLLAPSED + '="true"]' ,
b . mTabContainer
) . snapshotLength )
expanndItem . removeAttribute ( 'disabled' ) ;
else
expanndItem . setAttribute ( 'disabled' , true ) ;
2007-11-17 01:05:23 -05:00
}
else {
collapseItem . setAttribute ( 'hidden' , true ) ;
expanndItem . setAttribute ( 'hidden' , true ) ;
}
if ( collapseItem . getAttribute ( 'hidden' ) == 'true' &&
expanndItem . getAttribute ( 'hidden' ) == 'true' ) {
sep . setAttribute ( 'hidden' , true ) ;
}
else {
sep . removeAttribute ( 'hidden' ) ;
}
// auto hide
2009-07-07 11:34:14 -04:00
let autohide = items [ this . kMENUITEM _AUTOHIDE ] ;
2009-09-03 04:18:41 -04:00
this . autoHide . updateMenuItem ( autohide ) ;
2008-02-22 12:55:35 -05:00
// fix
2009-07-07 11:34:14 -04:00
let fixedPref ;
let fixedLabel ;
if ( this . isVertical ) {
2010-05-08 02:22:49 -04:00
fixedPref = b . getAttribute ( this . kFIXED + '-vertical' ) == 'true' ;
2009-07-07 11:34:14 -04:00
fixedLabel = 'label-vertical' ;
}
else {
2010-05-08 02:22:49 -04:00
fixedPref = b . getAttribute ( this . kFIXED + '-horizontal' ) == 'true' ;
2009-07-07 11:34:14 -04:00
fixedLabel = 'label-horizontal' ;
}
let fixed = items [ this . kMENUITEM _FIXED ] ;
fixed . setAttribute ( 'label' , fixed . getAttribute ( fixedLabel ) ) ;
2010-05-08 02:22:49 -04:00
if ( fixedPref )
2009-07-07 04:42:17 -04:00
fixed . setAttribute ( 'checked' , true ) ;
else
fixed . removeAttribute ( 'checked' ) ;
2008-02-22 12:55:35 -05:00
2007-11-17 01:05:23 -05:00
sep = this . evaluateXPath (
'descendant::xul:menuseparator[starts-with(@id, "' + this . kMENUITEM _AUTOHIDE _SEPARATOR + '")]' ,
2007-11-14 14:34:36 -05:00
aEvent . currentTarget ,
XPathResult . FIRST _ORDERED _NODE _TYPE
) . singleNodeValue ;
2008-02-22 12:55:35 -05:00
if ( autohide . getAttribute ( 'hidden' ) != 'true' ||
2009-08-25 12:48:10 -04:00
fixed . getAttribute ( 'hidden' ) != 'true' ) {
2007-11-14 14:34:36 -05:00
sep . removeAttribute ( 'hidden' ) ;
}
else {
sep . setAttribute ( 'hidden' , true ) ;
}
} ,
2010-11-29 19:42:22 -05:00
2010-03-28 14:22:15 -04:00
onTreeStyleTabPrintPreviewEntered : function TSTBrowser _onTreeStyleTabPrintPreviewEntered ( aEvent )
{
this . setTabbrowserAttribute ( this . kPRINT _PREVIEW , true ) ;
} ,
onTreeStyleTabPrintPreviewExited : function TSTBrowser _onTreeStyleTabPrintPreviewExited ( aEvent )
{
this . removeTabbrowserAttribute ( this . kPRINT _PREVIEW ) ;
} ,
2007-11-17 00:20:26 -05:00
/* drag and drop */
2008-12-01 03:30:36 -05:00
2009-09-02 21:26:38 -04:00
get tabbarDNDObserver ( )
2009-08-25 03:20:56 -04:00
{
2009-09-02 22:05:25 -04:00
return this . _tabbarDNDObserver || ( this . _tabbarDNDObserver = new TreeStyleTabBrowserTabbarDNDObserver ( this ) ) ;
2007-11-17 12:21:33 -05:00
} ,
2009-09-02 21:26:38 -04:00
get panelDNDObserver ( )
2009-08-25 03:20:56 -04:00
{
2009-09-02 22:05:25 -04:00
return this . _panelDNDObserver || ( this . _panelDNDObserver = new TreeStyleTabBrowserTabpanelDNDObserver ( this ) ) ;
2009-08-25 03:20:56 -04:00
} ,
2009-12-25 03:34:52 -05:00
getCurrentDragSession : function TSTBrowser _getCurrentDragSession ( )
2008-10-01 21:32:31 -04:00
{
return Components
. classes [ '@mozilla.org/widget/dragservice;1' ]
. getService ( Components . interfaces . nsIDragService )
. getCurrentSession ( ) ;
} ,
2009-12-25 03:34:52 -05:00
getDropAction : function TSTBrowser _getDropAction ( aEvent , aDragSession )
2007-11-14 14:34:36 -05:00
{
2008-10-01 21:32:31 -04:00
if ( ! aDragSession )
aDragSession = this . getCurrentDragSession ( ) ;
2008-10-17 08:35:55 -04:00
var tab = aDragSession ? this . getTabFromChild ( aDragSession . sourceNode ) : null ;
2009-03-31 14:25:49 -04:00
this . ensureTabInitialized ( tab ) ;
2008-10-17 08:35:55 -04:00
var info = this . getDropActionInternal ( aEvent , tab ) ;
2007-11-14 14:34:36 -05:00
info . canDrop = true ;
2008-12-03 13:41:58 -05:00
info . source = tab ;
2008-10-17 08:35:55 -04:00
if ( tab ) {
2010-04-06 22:13:58 -04:00
var isCopy = this . isCopyAction ( aEvent ) ;
2008-10-17 08:35:55 -04:00
if ( isCopy && 'duplicateTab' in this . mTabBrowser ) {
2008-10-17 13:16:16 -04:00
info . action |= this . kACTION _DUPLICATE ;
2008-10-17 08:35:55 -04:00
}
2008-02-24 03:11:17 -05:00
if (
2008-10-17 08:35:55 -04:00
! isCopy &&
2008-10-17 13:16:16 -04:00
this . getTabBrowserFromChild ( tab ) != this . mTabBrowser &&
2008-02-24 03:11:17 -05:00
(
2008-10-17 08:35:55 -04:00
( 'duplicateTab' in this . mTabBrowser ) ||
( 'swapBrowsersAndCloseOther' in this . mTabBrowser )
2008-02-24 03:11:17 -05:00
)
) {
2008-10-17 13:16:16 -04:00
info . action |= this . kACTION _IMPORT ;
}
if ( info . action & this . kACTIONS _FOR _DESTINATION ) {
if ( info . action & this . kACTION _MOVE ) info . action ^= this . kACTION _MOVE ;
if ( info . action & this . kACTION _STAY ) info . action ^= this . kACTION _STAY ;
2008-02-24 03:11:17 -05:00
}
2008-02-22 18:31:22 -05:00
if ( info . action & this . kACTION _ATTACH ) {
2008-10-17 13:16:16 -04:00
if ( info . parent == tab ) {
2007-11-14 14:34:36 -05:00
info . canDrop = false ;
2008-02-22 18:31:22 -05:00
}
else {
2008-10-17 13:16:16 -04:00
var orig = tab ;
tab = info . target ;
2008-02-22 18:31:22 -05:00
while ( tab = this . getParentTab ( tab ) )
{
if ( tab != orig ) continue ;
info . canDrop = false ;
break ;
}
2007-11-14 14:34:36 -05:00
}
}
}
return info ;
} ,
2008-10-17 13:16:16 -04:00
2009-12-25 03:34:52 -05:00
getDropActionInternal : function TSTBrowser _getDropActionInternal ( aEvent , aSourceTab )
2007-11-14 14:34:36 -05:00
{
var tab = aEvent . target ;
var b = this . mTabBrowser ;
2009-01-24 00:39:22 -05:00
var tabs = this . getTabsArray ( b ) ;
2010-06-25 11:59:59 -04:00
var firstTab = this . getFirstNormalTab ( b ) ;
2009-04-07 10:36:31 -04:00
var lastTabIndex = tabs . length - 1 ;
2007-11-14 14:43:54 -05:00
var isInverted = this . isVertical ? false : window . getComputedStyle ( b . parentNode , null ) . direction == 'rtl' ;
2007-11-14 14:34:36 -05:00
var info = {
target : null ,
position : null ,
action : null ,
parent : null ,
2010-11-28 22:04:38 -05:00
insertBefore : null ,
event : aEvent
2007-11-14 14:34:36 -05:00
} ;
2008-10-17 08:35:55 -04:00
var isTabMoveFromOtherWindow = aSourceTab && aSourceTab . ownerDocument != document ;
2008-11-30 19:01:12 -05:00
var isNewTabAction = ! aSourceTab || aSourceTab . ownerDocument != document ;
2008-10-17 08:35:55 -04:00
2007-11-14 14:34:36 -05:00
if ( tab . localName != 'tab' ) {
2008-10-17 13:16:16 -04:00
var action = isTabMoveFromOtherWindow ? this . kACTION _STAY : ( this . kACTION _MOVE | this . kACTION _PART ) ;
2008-11-30 19:01:12 -05:00
if ( isNewTabAction ) action |= this . kACTION _NEWTAB ;
2010-06-25 11:59:59 -04:00
if ( aEvent [ this . positionProp ] < firstTab . boxObject [ this . positionProp ] ) {
info . target = info . parent = info . insertBefore = firstTab ;
2007-11-14 14:34:36 -05:00
info . position = isInverted ? this . kDROP _AFTER : this . kDROP _BEFORE ;
2008-10-17 08:35:55 -04:00
info . action = action ;
2007-11-14 14:34:36 -05:00
return info ;
}
2009-04-07 10:36:31 -04:00
else if ( aEvent [ this . positionProp ] > tabs [ lastTabIndex ] . boxObject [ this . positionProp ] + tabs [ lastTabIndex ] . boxObject [ this . sizeProp ] ) {
info . target = info . parent = tabs [ lastTabIndex ] ;
2007-11-14 14:34:36 -05:00
info . position = isInverted ? this . kDROP _BEFORE : this . kDROP _AFTER ;
2008-10-17 08:35:55 -04:00
info . action = action ;
2007-11-14 14:34:36 -05:00
return info ;
}
else {
2010-03-24 13:20:30 -04:00
let index = b . getNewIndex ?
b . getNewIndex ( aEvent ) :
b . tabContainer . _getDropIndex ( aEvent ) ;
info . target = tabs [ Math . min ( index , lastTabIndex ) ] ;
2007-11-14 14:34:36 -05:00
}
}
else {
2009-03-31 14:25:49 -04:00
this . ensureTabInitialized ( tab ) ;
2007-11-14 14:34:36 -05:00
info . target = tab ;
}
2010-09-09 05:38:48 -04:00
var positionProp = this . isVertical && tab . getAttribute ( 'pinned' ) == 'true' ? this . invertedPositionProp : this . positionProp ;
var sizeProp = this . isVertical && tab . getAttribute ( 'pinned' ) == 'true' ? this . invertedSizeProp : this . sizeProp ;
2010-06-26 14:16:59 -04:00
var boxPos = tab . boxObject [ positionProp ] ;
var boxUnit = Math . round ( tab . boxObject [ sizeProp ] / 3 ) ;
if ( aEvent [ positionProp ] < boxPos + boxUnit ) {
2007-11-14 14:34:36 -05:00
info . position = isInverted ? this . kDROP _AFTER : this . kDROP _BEFORE ;
}
2010-06-26 14:16:59 -04:00
else if ( aEvent [ positionProp ] > boxPos + boxUnit + boxUnit ) {
2007-11-14 14:34:36 -05:00
info . position = isInverted ? this . kDROP _BEFORE : this . kDROP _AFTER ;
}
else {
info . position = this . kDROP _ON ;
}
switch ( info . position )
{
case this . kDROP _ON :
2009-03-16 10:35:30 -04:00
info . action = this . kACTION _STAY | this . kACTION _ATTACH ;
2007-11-14 14:34:36 -05:00
info . parent = tab ;
2009-03-16 10:35:30 -04:00
var visible = this . getNextVisibleTab ( tab ) ;
info . insertBefore = this . getTreePref ( 'insertNewChildAt' ) == this . kINSERT _FISRT ?
( this . getFirstChildTab ( tab ) || visible ) :
( this . getNextSiblingTab ( tab ) || this . getNextTab ( this . getLastDescendantTab ( tab ) ) || visible ) ;
2007-11-14 14:34:36 -05:00
break ;
case this . kDROP _BEFORE :
/ *
[ TARGET ] <EFBFBD> <EFBFBD> part from parent , and move
[ ]
[ TARGET ] <EFBFBD> <EFBFBD> attach to the parent of the target , and move
[ ]
[ TARGET ] <EFBFBD> <EFBFBD> attach to the parent of the target , and move
[ ]
[ TARGET ] <EFBFBD> <EFBFBD> attach to the parent of the target ( previous tab ) , and move
* /
var prevTab = this . getPreviousVisibleTab ( tab ) ;
if ( ! prevTab ) {
info . action = this . kACTION _MOVE | this . kACTION _PART ;
2010-06-25 11:59:59 -04:00
info . insertBefore = firstTab ;
2007-11-14 14:34:36 -05:00
}
else {
2007-11-26 17:43:50 -05:00
var prevLevel = Number ( prevTab . getAttribute ( this . kNEST ) ) ;
2007-11-14 14:34:36 -05:00
var targetNest = Number ( tab . getAttribute ( this . kNEST ) ) ;
2007-11-26 17:43:50 -05:00
info . parent = ( prevLevel < targetNest ) ? prevTab : this . getParentTab ( tab ) ;
2007-11-14 14:34:36 -05:00
info . action = this . kACTION _MOVE | ( info . parent ? this . kACTION _ATTACH : this . kACTION _PART ) ;
info . insertBefore = tab ;
}
break ;
case this . kDROP _AFTER :
/ *
[ TARGET ] <EFBFBD> <EFBFBD> if the target has a parent , attach to it and and move
[ TARGET ] <EFBFBD> <EFBFBD> attach to the parent of the target , and move
[ ]
[ TARGET ] <EFBFBD> <EFBFBD> attach to the parent of the target , and move
[ ]
[ TARGET ] <EFBFBD> <EFBFBD> attach to the target , and move
[ ]
* /
var nextTab = this . getNextVisibleTab ( tab ) ;
if ( ! nextTab ) {
info . action = this . kACTION _MOVE | this . kACTION _ATTACH ;
info . parent = this . getParentTab ( tab ) ;
}
else {
var targetNest = Number ( tab . getAttribute ( this . kNEST ) ) ;
2007-11-26 17:43:50 -05:00
var nextLevel = Number ( nextTab . getAttribute ( this . kNEST ) ) ;
info . parent = ( targetNest < nextLevel ) ? tab : this . getParentTab ( tab ) ;
2007-11-14 14:34:36 -05:00
info . action = this . kACTION _MOVE | ( info . parent ? this . kACTION _ATTACH : this . kACTION _PART ) ;
info . insertBefore = nextTab ;
2009-03-04 22:13:56 -05:00
/ *
[ TARGET ] <EFBFBD> <EFBFBD> attach dragged tab to the parent of the target as its next sibling
[ DRAGGED ]
* /
if ( aSourceTab == nextTab && this . getDescendantTabs ( info . parent ) . length == 1 ) {
info . action = this . kACTION _MOVE | this . kACTION _ATTACH ;
info . parent = this . getParentTab ( tab ) ;
info . insertBefore = this . getNextTab ( nextTab ) ;
}
2007-11-14 14:34:36 -05:00
}
break ;
}
2008-11-30 19:01:12 -05:00
if ( isNewTabAction ) action |= this . kACTION _NEWTAB ;
2007-11-14 14:34:36 -05:00
return info ;
} ,
2009-12-25 03:34:52 -05:00
performDrop : function TSTBrowser _performDrop ( aInfo , aDraggedTab )
2007-11-14 14:34:36 -05:00
{
2008-12-01 03:30:36 -05:00
var tabsInfo = this . getDraggedTabsInfoFromOneTab ( aInfo , aDraggedTab ) ;
2009-10-25 22:55:05 -04:00
if ( ! tabsInfo . draggedTab ) return false ;
2008-12-01 03:30:36 -05:00
aDraggedTab = tabsInfo . draggedTab ;
var draggedTabs = tabsInfo . draggedTabs ;
var draggedRoots = tabsInfo . draggedRoots ;
2008-10-17 08:35:55 -04:00
2010-11-30 19:51:10 -05:00
2008-10-17 08:35:55 -04:00
var targetBrowser = this . mTabBrowser ;
2009-01-24 00:39:22 -05:00
var tabs = this . getTabsArray ( targetBrowser ) ;
2008-02-22 18:31:22 -05:00
2008-10-17 08:35:55 -04:00
var sourceWindow = aDraggedTab . ownerDocument . defaultView ;
var sourceBrowser = this . getTabBrowserFromChild ( aDraggedTab ) ;
2008-02-24 03:34:45 -05:00
2009-08-10 10:31:48 -04:00
var draggedWholeTree = [ ] . concat ( draggedRoots ) ;
draggedRoots . forEach ( function ( aRoot ) {
draggedWholeTree = draggedWholeTree . concat ( this . getDescendantTabs ( aRoot ) ) ;
} , this ) ;
while ( aInfo . insertBefore && draggedWholeTree . indexOf ( aInfo . insertBefore ) > - 1 )
2009-08-10 10:09:38 -04:00
{
aInfo . insertBefore = this . getNextTab ( aInfo . insertBefore ) ;
}
2008-10-17 13:16:16 -04:00
if ( aInfo . action & this . kACTIONS _FOR _SOURCE ) {
if ( aInfo . action & this . kACTION _PART ) {
2008-02-22 20:42:42 -05:00
this . partTabsOnDrop ( draggedRoots ) ;
2008-10-17 13:16:16 -04:00
}
else if ( aInfo . action & this . kACTION _ATTACH ) {
2008-02-22 20:42:42 -05:00
this . attachTabsOnDrop ( draggedRoots , aInfo . parent ) ;
2008-10-17 13:16:16 -04:00
}
else {
return false ;
}
if ( // if this move will cause no change...
sourceBrowser == targetBrowser &&
2009-08-10 10:09:38 -04:00
sourceBrowser . treeStyleTab . getNextVisibleTab ( draggedTabs [ draggedTabs . length - 1 ] ) == aInfo . insertBefore
2008-10-17 13:16:16 -04:00
) {
// then, do nothing
return true ;
}
2007-11-14 14:34:36 -05:00
}
2008-02-22 19:41:15 -05:00
2008-10-17 13:16:16 -04:00
// prevent Multiple Tab Handler feature
targetBrowser . duplicatingSelectedTabs = true ;
targetBrowser . movingSelectedTabs = true ;
2008-10-17 08:35:55 -04:00
2008-02-22 18:31:22 -05:00
2008-10-17 13:16:16 -04:00
var newRoots = [ ] ;
var shouldClose = (
aInfo . action & this . kACTION _IMPORT &&
2010-09-14 03:39:17 -04:00
this . getAllTabsArray ( sourceBrowser ) . length == draggedTabs . length
2008-10-17 13:16:16 -04:00
) ;
var oldTabs = [ ] ;
var newTabs = [ ] ;
var treeStructure = draggedTabs . map ( function ( aTab ) {
var parent = sourceBrowser . treeStyleTab . getParentTab ( aTab ) ;
return parent ? draggedTabs . indexOf ( parent ) : - 1 ;
} ) ;
2008-02-22 18:31:22 -05:00
2009-03-25 09:19:53 -04:00
var parentTabsArray = draggedTabs . map ( function ( aTab ) {
return ( aInfo . action & this . kACTIONS _FOR _DESTINATION ) ?
sourceBrowser . treeStyleTab . getParentTab ( aTab ) : null ;
} , this ) ;
2009-08-19 01:48:41 -04:00
// Firefox fails to "move" collapsed tabs. So, expand them first
// and collapse them after they are moved.
2009-08-19 01:47:18 -04:00
var collapseExpandState = [ ] ;
if ( aInfo . action & this . kACTION _IMPORT &&
'swapBrowsersAndCloseOther' in targetBrowser ) {
draggedWholeTree . forEach ( function ( aTab ) {
collapseExpandState . push ( this . getTabValue ( aTab , this . kSUBTREE _COLLAPSED ) == 'true' ) ;
this . collapseExpandSubtree ( aTab , false , true ) ;
this . collapseExpandTab ( aTab , false , true ) ;
} , this ) ;
}
2009-04-07 10:36:31 -04:00
var lastTabIndex = tabs . length - 1 ;
2009-03-25 09:19:53 -04:00
draggedTabs . forEach ( function ( aTab , aIndex ) {
2008-10-17 13:16:16 -04:00
var tab = aTab ;
if ( aInfo . action & this . kACTIONS _FOR _DESTINATION ) {
2009-03-25 09:19:53 -04:00
var parent = parentTabsArray [ aIndex ] ;
2010-11-28 22:04:38 -05:00
if ( tabsInfo . isMultipleMove && 'MultipleTabService' in sourceWindow )
2008-10-17 13:16:16 -04:00
sourceWindow . MultipleTabService . setSelection ( aTab , false ) ;
if ( aInfo . action & this . kACTION _IMPORT &&
'swapBrowsersAndCloseOther' in targetBrowser ) {
tab = targetBrowser . addTab ( ) ;
tab . linkedBrowser . stop ( ) ;
tab . linkedBrowser . docShell ;
targetBrowser . swapBrowsersAndCloseOther ( tab , aTab ) ;
targetBrowser . setTabTitle ( tab ) ;
}
else {
tab = targetBrowser . duplicateTab ( aTab ) ;
this . deleteTabValue ( tab , this . kCHILDREN ) ;
this . deleteTabValue ( tab , this . kPARENT ) ;
if ( aInfo . action & this . kACTION _IMPORT )
oldTabs . push ( aTab ) ;
}
newTabs . push ( tab ) ;
2010-11-28 22:04:38 -05:00
if ( tabsInfo . isMultipleMove && 'MultipleTabService' in window )
2008-10-17 13:16:16 -04:00
MultipleTabService . setSelection ( tab , true ) ;
if ( ! parent || draggedTabs . indexOf ( parent ) < 0 )
newRoots . push ( tab ) ;
2009-04-07 10:36:31 -04:00
lastTabIndex ++ ;
2008-10-17 13:16:16 -04:00
}
2008-02-24 03:11:17 -05:00
2009-04-07 10:36:31 -04:00
var newIndex = aInfo . insertBefore ? aInfo . insertBefore . _tPos : lastTabIndex ;
2008-10-17 13:16:16 -04:00
if ( aInfo . insertBefore && newIndex > tab . _tPos ) newIndex -- ;
2008-10-17 08:35:55 -04:00
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount ++ ;
2008-10-17 13:16:16 -04:00
targetBrowser . moveTabTo ( tab , newIndex ) ;
2009-08-19 01:47:18 -04:00
this . collapseExpandTab ( tab , false , true ) ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount -- ;
2008-02-22 19:41:15 -05:00
2008-10-17 13:16:16 -04:00
} , this ) ;
2008-02-24 05:01:10 -05:00
2008-10-17 13:16:16 -04:00
// close imported tabs from the source browser
oldTabs . forEach ( function ( aTab ) {
2010-08-08 05:42:47 -04:00
sourceBrowser . removeTab ( aTab , { animate : true } ) ;
2008-10-17 13:16:16 -04:00
} ) ;
if ( shouldClose ) this . closeOwner ( sourceBrowser ) ;
2008-02-22 19:41:15 -05:00
2008-10-17 13:16:16 -04:00
// restore tree structure for newly opened tabs
newTabs . forEach ( function ( aTab , aIndex ) {
var index = treeStructure [ aIndex ] ;
if ( index < 0 ) return ;
targetBrowser . treeStyleTab . attachTabTo ( aTab , newTabs [ index ] ) ;
} ) ;
2009-08-19 01:47:18 -04:00
newTabs . reverse ( ) ;
collapseExpandState . reverse ( ) ;
collapseExpandState . forEach ( function ( aCollapsed , aIndex ) {
this . collapseExpandSubtree ( newTabs [ aIndex ] , aCollapsed , true ) ;
} , this ) ;
2008-02-24 03:11:17 -05:00
2008-10-17 13:16:16 -04:00
if ( aInfo . action & this . kACTIONS _FOR _DESTINATION &&
aInfo . action & this . kACTION _ATTACH )
this . attachTabsOnDrop ( newRoots , aInfo . parent ) ;
// Multiple Tab Handler
targetBrowser . movingSelectedTabs = false ;
targetBrowser . duplicatingSelectedTabs = false ;
2008-02-22 19:41:15 -05:00
2007-11-14 14:34:36 -05:00
return true ;
} ,
2008-10-17 13:16:16 -04:00
2009-12-25 03:34:52 -05:00
getDraggedTabsInfoFromOneTab : function TSTBrowser _getDraggedTabsInfoFromOneTab ( aInfo , aTab )
2008-12-01 03:30:36 -05:00
{
aTab = this . getTabFromChild ( aTab ) ;
2009-10-25 22:55:05 -04:00
if ( ! aTab )
return {
2010-11-28 22:04:38 -05:00
draggedTab : null ,
draggedTabs : [ ] ,
draggedRoots : [ ] ,
isMultipleMove : false
2009-10-25 22:55:05 -04:00
} ;
2008-12-01 03:30:36 -05:00
var targetBrowser = this . mTabBrowser ;
2009-01-24 00:39:22 -05:00
var tabs = this . getTabsArray ( targetBrowser ) ;
2008-12-01 03:30:36 -05:00
var draggedTabs = [ aTab ] ;
var draggedRoots = [ aTab ] ;
var sourceWindow = aTab . ownerDocument . defaultView ;
var sourceBrowser = this . getTabBrowserFromChild ( aTab ) ;
2010-11-28 22:04:38 -05:00
var dt = aInfo . event && aInfo . event . dataTransfer ;
2010-11-29 22:23:08 -05:00
var isMultipleDragEvent = window [ 'piro.sakura.ne.jp' ] . tabsDragUtils . isTabsDragging ( aInfo . event ) ;
2010-11-28 22:04:38 -05:00
var isMultipleMove = (
isMultipleDragEvent ||
(
'MultipleTabService' in sourceWindow &&
sourceWindow . MultipleTabService . isSelected ( aTab ) &&
MultipleTabService . allowMoveMultipleTabs
)
2008-12-01 03:30:36 -05:00
) ;
2010-11-28 22:04:38 -05:00
if ( isMultipleMove ) {
draggedTabs = isMultipleDragEvent ?
2010-11-29 22:23:08 -05:00
window [ 'piro.sakura.ne.jp' ] . tabsDragUtils . getDraggedTabs ( aInfo . event ) :
2010-11-28 22:04:38 -05:00
sourceWindow . MultipleTabService . getSelectedTabs ( sourceBrowser ) ;
2008-12-01 03:30:36 -05:00
if ( ! ( aInfo . action & this . kACTIONS _FOR _DESTINATION ) ) {
draggedRoots = [ ] ;
draggedTabs . forEach ( function ( aTab ) {
var parent = aTab ,
current ;
do {
current = parent ;
parent = sourceBrowser . treeStyleTab . getParentTab ( parent )
2010-11-28 22:04:38 -05:00
if ( parent && draggedTabs . indexOf ( parent ) > - 1 ) continue ;
2008-12-01 03:30:36 -05:00
draggedRoots . push ( current ) ;
return ;
}
while ( parent ) ;
} , this ) ;
}
}
else if ( aInfo . action & this . kACTIONS _FOR _DESTINATION ) {
draggedTabs = draggedTabs . concat ( sourceBrowser . treeStyleTab . getDescendantTabs ( aTab ) ) ;
}
return {
2010-11-28 22:04:38 -05:00
draggedTab : aTab ,
draggedTabs : draggedTabs ,
draggedRoots : draggedRoots ,
isMultipleMove : isMultipleMove
2008-12-01 03:30:36 -05:00
} ;
} ,
2009-12-25 03:34:52 -05:00
attachTabsOnDrop : function TSTBrowser _attachTabsOnDrop ( aTabs , aParent )
2008-02-22 19:41:15 -05:00
{
this . mTabBrowser . movingSelectedTabs = true ; // Multiple Tab Handler
aTabs . forEach ( function ( aTab ) {
2009-05-06 22:19:10 -04:00
if ( ! aTab . parentNode ) return ; // ignore removed tabs
2008-02-22 19:41:15 -05:00
if ( aParent )
2008-10-17 08:35:55 -04:00
this . attachTabTo ( aTab , aParent ) ;
2008-02-22 19:41:15 -05:00
else
2008-10-17 08:35:55 -04:00
this . partTab ( aTab ) ;
this . collapseExpandTab ( aTab , false ) ;
} , this ) ;
2008-02-22 19:41:15 -05:00
this . mTabBrowser . movingSelectedTabs = false ; // Multiple Tab Handler
} ,
2008-10-17 13:16:16 -04:00
2009-12-25 03:34:52 -05:00
partTabsOnDrop : function TSTBrowser _partTabsOnDrop ( aTabs )
2008-02-22 19:41:15 -05:00
{
this . mTabBrowser . movingSelectedTabs = true ; // Multiple Tab Handler
aTabs . forEach ( function ( aTab ) {
2009-05-06 22:19:10 -04:00
if ( ! aTab . parentNode ) return ; // ignore removed tabs
2008-10-17 08:35:55 -04:00
this . partTab ( aTab ) ;
this . collapseExpandTab ( aTab , false ) ;
} , this ) ;
2008-02-22 19:41:15 -05:00
this . mTabBrowser . movingSelectedTabs = false ; // Multiple Tab Handler
} ,
2008-10-17 13:16:16 -04:00
2009-12-25 03:34:52 -05:00
closeOwner : function TSTBrowser _closeOwner ( aTabOwner )
2008-10-17 08:35:55 -04:00
{
var w = aTabOwner . ownerDocument . defaultView ;
2008-10-17 13:30:10 -04:00
if ( ! w ) return ;
2009-04-29 23:53:38 -04:00
if ( 'SplitBrowser' in w ) {
if ( 'getSubBrowserFromChild' in w . SplitBrowser ) {
var subbrowser = w . SplitBrowser . getSubBrowserFromChild ( aTabOwner ) ;
if ( subbrowser ) {
subbrowser . close ( ) ;
return ;
}
2008-10-17 08:35:55 -04:00
}
2009-04-29 23:53:38 -04:00
if ( w . SplitBrowser . browsers . length ) return ;
2008-10-17 08:35:55 -04:00
}
w . close ( ) ;
} ,
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
clearDropPosition : function TSTBrowser _clearDropPosition ( )
2007-11-14 14:34:36 -05:00
{
var b = this . mTabBrowser ;
var xpathResult = this . evaluateXPath (
'child::xul:tab[@' + this . kDROP _POSITION + ']' ,
b . mTabContainer
) ;
for ( var i = 0 , maxi = xpathResult . snapshotLength ; i < maxi ; i ++ )
{
xpathResult . snapshotItem ( i ) . removeAttribute ( this . kDROP _POSITION ) ;
}
} ,
2008-12-01 04:14:05 -05:00
2010-09-14 03:39:17 -04:00
isDraggingAllTabs : function TSTBrowser _isDraggingAllTabs ( aTab , aTabs )
2008-12-01 04:14:05 -05:00
{
var actionInfo = {
action : this . kACTIONS _FOR _DESTINATION | this . kACTION _IMPORT
} ;
var tabsInfo = this . getDraggedTabsInfoFromOneTab ( actionInfo , aTab ) ;
2010-09-14 03:39:17 -04:00
return tabsInfo . draggedTabs . length == ( aTabs || this . getAllTabsArray ( this . mTabBrowser ) ) . length ;
} ,
isDraggingAllCurrentTabs : function TSTBrowser _isDraggingAllCurrentTabs ( aTab )
{
return this . isDraggingAllTabs ( aTab , this . getTabsArray ( this . mTabBrowser ) ) ;
2008-12-01 04:14:05 -05:00
} ,
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
/* commands */
2007-11-14 14:34:36 -05:00
2009-12-16 12:52:25 -05:00
/* reset */
2009-12-25 03:34:52 -05:00
resetTab : function TSTBrowser _resetTab ( aTab , aPartChildren )
2009-12-16 12:52:25 -05:00
{
if ( aPartChildren )
this . partAllChildren ( aTab , {
dontUpdateIndent : true ,
dontAnimate : true
} ) ;
this . partTab ( aTab , {
dontUpdateIndent : true ,
dontAnimate : true
} ) ;
/* reset attributes before restoring */
aTab . removeAttribute ( this . kID ) ;
aTab . removeAttribute ( this . kPARENT ) ;
aTab . removeAttribute ( this . kCHILDREN ) ;
aTab . removeAttribute ( this . kSUBTREE _COLLAPSED ) ;
aTab . removeAttribute ( this . kCOLLAPSED ) ;
aTab . removeAttribute ( this . kCOLLAPSED _DONE ) ;
aTab . removeAttribute ( this . kNEST ) ;
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( [ aTab ] , undefined , true ) ;
2009-12-16 12:52:25 -05:00
} ,
2009-12-25 03:34:52 -05:00
resetAllTabs : function TSTBrowser _resetAllTabs ( aPartChildren )
2009-12-16 12:52:25 -05:00
{
2010-09-14 03:39:17 -04:00
this . getAllTabsArray ( this . mTabBrowser ) . forEach ( function ( aTab ) {
2009-12-16 12:52:25 -05:00
this . resetTab ( aTab , aPartChildren ) ;
} , this ) ;
} ,
2009-12-18 04:05:41 -05:00
get treeViewEnabled ( ) /* PUBLIC API */
{
return this . _treeViewEnabled ;
} ,
set treeViewEnabled ( aValue )
{
this . _treeViewEnabled = aValue ? true : false ;
if ( this . _treeViewEnabled ) {
2010-11-19 00:07:19 -05:00
if ( this . allowSubtreeCollapseExpand )
2010-03-28 14:22:15 -04:00
this . setTabbrowserAttribute ( this . kALLOW _COLLAPSE , true ) ;
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( this . rootTabs , undefined , true ) ;
2009-12-18 04:05:41 -05:00
}
else {
2010-03-28 14:22:15 -04:00
this . removeTabbrowserAttribute ( this . kALLOW _COLLAPSE ) ;
2010-09-14 03:39:17 -04:00
this . getAllTabsArray ( this . browser ) . forEach ( function ( aTab ) {
2010-08-13 13:14:46 -04:00
this . updateTabIndent ( aTab , 0 , true ) ;
2009-12-18 04:05:41 -05:00
} , this ) ;
}
return aValue ;
} ,
// _treeViewEnabled : true,
2009-12-16 12:52:25 -05:00
2007-11-17 00:20:26 -05:00
/* attach/part */
2009-12-25 03:34:52 -05:00
attachTabTo : function TSTBrowser _attachTabTo ( aChild , aParent , aInfo ) /* PUBLIC API */
2007-11-14 14:34:36 -05:00
{
2010-11-29 03:24:45 -05:00
aInfo = aInfo || { } ;
if ( aParent && this . maxTreeLevelPhisical && this . maxTreeLevel > - 1 ) {
let level = parseInt ( aParent . getAttribute ( this . kNEST ) || 0 ) + 1 ;
while ( aParent && level > this . maxTreeLevel )
{
level -- ;
aParent = this . getParentTab ( aParent ) ;
}
}
2009-04-07 12:09:17 -04:00
var currentParent ;
2007-11-17 00:20:26 -05:00
if (
! aChild ||
! aParent ||
aChild == aParent ||
2010-06-25 12:28:01 -04:00
( currentParent = this . getParentTab ( aChild ) ) == aParent ||
2010-09-09 05:38:48 -04:00
aChild . getAttribute ( 'pinned' ) == 'true' ||
aParent . getAttribute ( 'pinned' ) == 'true'
2008-02-28 02:45:39 -05:00
) {
2009-12-25 23:49:58 -05:00
this . fireAttachedEvent ( aChild , aParent ) ;
2007-11-17 00:20:26 -05:00
return ;
2008-02-28 02:45:39 -05:00
}
2007-11-14 14:34:36 -05:00
2010-06-26 13:36:08 -04:00
currentParent = aParent ;
do {
if ( currentParent != aChild ) continue ;
// this.fireAttachedEvent(aChild, aParent);
return ;
}
while ( currentParent = this . getParentTab ( currentParent ) ) ;
2009-04-07 12:09:17 -04:00
shouldInheritIndent = (
! currentParent ||
( currentParent . getAttribute ( this . kNEST ) == aParent . getAttribute ( this . kNEST ) )
) ;
2009-03-31 14:25:49 -04:00
this . ensureTabInitialized ( aChild ) ;
this . ensureTabInitialized ( aParent ) ;
2007-11-17 00:20:26 -05:00
if ( ! aInfo ) aInfo = { } ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var id = aChild . getAttribute ( this . kID ) ;
2007-11-14 14:34:36 -05:00
2009-07-30 05:56:28 -04:00
this . partTab ( aChild , {
dontUpdateIndent : true
} ) ;
2007-11-17 00:20:26 -05:00
2009-04-20 08:03:38 -04:00
var children = aParent . getAttribute ( this . kCHILDREN )
. split ( '|' ) . filter ( function ( aId ) {
return this . getTabById ( aId ) ;
} , this ) ;
2007-11-17 00:20:26 -05:00
var newIndex ;
2009-04-20 08:03:38 -04:00
var oldIndex = children . indexOf ( id ) ;
2009-04-20 09:22:34 -04:00
if ( oldIndex > - 1 ) children . splice ( oldIndex , 1 ) ;
2007-11-17 00:20:26 -05:00
2009-08-03 17:53:08 -04:00
var insertBefore = aInfo . insertBefore ||
( aInfo . dontMove ? this . getNextTab ( aChild ) : null ) ;
2007-11-17 00:20:26 -05:00
var beforeTab = insertBefore ? insertBefore . getAttribute ( this . kID ) : null ;
2009-04-20 08:03:38 -04:00
var beforeIndex ;
if ( beforeTab && ( beforeIndex = children . indexOf ( beforeTab ) ) > - 1 ) {
children . splice ( beforeIndex , 0 , id ) ;
2007-11-17 00:20:26 -05:00
newIndex = insertBefore . _tPos ;
}
else {
2009-04-20 08:03:38 -04:00
children . push ( id ) ;
2009-12-22 03:05:16 -05:00
if ( aInfo . dontMove && children . length > 1 ) {
children = children
. map ( this . getTabById , this )
. sort ( this . sortTabsByOrder )
. map ( function ( aTab ) {
return aTab . getAttribute ( this . kID ) ;
} , this ) ;
}
2009-07-30 05:56:28 -04:00
let refTab = aParent ;
let descendant = this . getDescendantTabs ( aParent ) ;
2007-11-17 00:20:26 -05:00
if ( descendant . length ) refTab = descendant [ descendant . length - 1 ] ;
newIndex = refTab . _tPos + 1 ;
}
2009-04-20 08:03:38 -04:00
this . setTabValue ( aParent , this . kCHILDREN , children . join ( '|' ) ) ;
2007-11-17 00:20:26 -05:00
this . setTabValue ( aChild , this . kPARENT , aParent . getAttribute ( this . kID ) ) ;
2010-03-03 08:30:49 -05:00
2007-11-17 00:20:26 -05:00
this . updateTabsCount ( aParent ) ;
2009-06-26 20:37:39 -04:00
if ( shouldInheritIndent && ! aInfo . dontUpdateIndent )
this . inheritTabIndent ( aChild , aParent ) ;
2007-11-17 00:20:26 -05:00
2009-07-30 05:56:28 -04:00
if ( ! aInfo . dontMove ) {
if ( newIndex > aChild . _tPos ) newIndex -- ;
2009-12-25 06:19:50 -05:00
this . moveTabSubtreeTo ( aChild , newIndex ) ;
2009-07-30 05:56:28 -04:00
}
2007-11-17 00:20:26 -05:00
if ( ! aInfo . dontExpand ) {
2009-12-25 06:27:23 -05:00
if ( this . getTreePref ( 'autoCollapseExpandSubtreeOnSelect' ) ) {
2009-09-29 09:34:36 -04:00
if ( this . shouldTabAutoExpanded ( aParent ) )
2009-09-29 09:18:36 -04:00
this . collapseExpandTreesIntelligentlyFor ( aParent ) ;
2007-11-17 00:20:26 -05:00
var p = aParent ;
do {
2009-09-29 09:34:36 -04:00
if ( this . shouldTabAutoExpanded ( p ) )
2009-09-29 09:18:36 -04:00
this . collapseExpandSubtree ( p , false , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
}
while ( p = this . getParentTab ( p ) ) ;
}
2009-09-29 09:34:36 -04:00
else if ( this . shouldTabAutoExpanded ( aParent ) ) {
2009-12-25 06:27:23 -05:00
if ( this . getTreePref ( 'autoExpandSubtreeOnAppendChild' ) ) {
2007-11-17 00:20:26 -05:00
var p = aParent ;
do {
2009-09-29 09:34:36 -04:00
if ( this . shouldTabAutoExpanded ( p ) )
2009-09-29 09:18:36 -04:00
this . collapseExpandSubtree ( p , false , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
}
while ( p = this . getParentTab ( p ) ) ;
}
else
2009-08-26 05:33:54 -04:00
this . collapseExpandTab ( aChild , true , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
}
2009-10-25 22:36:42 -04:00
if ( this . isCollapsed ( aParent ) )
2009-08-26 05:33:54 -04:00
this . collapseExpandTab ( aChild , true , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
}
2009-09-29 09:34:36 -04:00
else if ( this . shouldTabAutoExpanded ( aParent ) ||
2009-10-25 22:36:42 -04:00
this . isCollapsed ( aParent ) ) {
2009-08-26 05:33:54 -04:00
this . collapseExpandTab ( aChild , true , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
}
if ( ! aInfo . dontUpdateIndent ) {
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( [ aChild ] , undefined , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
this . checkTabsIndentOverflow ( ) ;
}
2008-02-28 02:45:39 -05:00
2010-11-29 03:24:45 -05:00
this . promoteTooDeepLevelTabs ( aChild ) ;
2009-12-25 23:49:58 -05:00
this . fireAttachedEvent ( aChild , aParent ) ;
} ,
fireAttachedEvent : function TSTBrowser _fireAttachedEvent ( aChild , aParent )
{
2009-05-15 13:17:57 -04:00
/* PUBLIC API */
2009-05-15 13:11:01 -04:00
var event = document . createEvent ( 'Events' ) ;
2010-12-01 03:16:26 -05:00
event . initEvent ( this . kEVENT _TYPE _ATTACHED , true , false ) ;
2009-05-15 13:11:01 -04:00
event . parentTab = aParent ;
aChild . dispatchEvent ( event ) ;
2008-02-28 02:45:39 -05:00
} ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
shouldTabAutoExpanded : function TSTBrowser _shouldTabAutoExpanded ( aTab )
2009-09-29 09:34:36 -04:00
{
return this . hasChildTabs ( aTab ) &&
2009-10-25 22:36:42 -04:00
this . isSubtreeCollapsed ( aTab ) ;
2009-09-29 09:34:36 -04:00
} ,
2009-12-25 03:34:52 -05:00
partTab : function TSTBrowser _partTab ( aChild , aInfo ) /* PUBLIC API */
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
if ( ! aChild ) return ;
2009-07-30 05:56:28 -04:00
if ( ! aInfo ) aInfo = { } ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var parentTab = this . getParentTab ( aChild ) ;
if ( ! parentTab ) return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var id = aChild . getAttribute ( this . kID ) ;
2010-03-03 08:30:49 -05:00
2010-03-03 21:50:28 -05:00
this . setTabValue (
parentTab ,
this . kCHILDREN ,
parentTab . getAttribute ( this . kCHILDREN )
. split ( '|' )
. filter ( function ( aId ) {
return this . getTabById ( aId ) && aId != id ;
} , this ) . join ( '|' )
) ;
2010-03-25 11:52:11 -04:00
this . deleteTabValue ( aChild , this . kPARENT ) ;
2010-03-03 08:30:49 -05:00
2009-09-29 09:34:36 -04:00
if ( ! this . hasChildTabs ( parentTab ) )
this . setTabValue ( parentTab , this . kSUBTREE _COLLAPSED , true ) ;
2010-03-03 08:30:49 -05:00
2007-11-17 00:20:26 -05:00
this . updateTabsCount ( parentTab ) ;
2007-11-14 14:34:36 -05:00
2009-07-30 05:56:28 -04:00
if ( ! aInfo . dontUpdateIndent ) {
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( [ aChild ] , undefined , aInfo . dontAnimate ) ;
2007-11-17 00:20:26 -05:00
this . checkTabsIndentOverflow ( ) ;
}
2008-02-28 02:45:39 -05:00
2009-05-15 13:17:57 -04:00
/* PUBLIC API */
var event = document . createEvent ( 'Events' ) ;
2010-12-01 03:16:26 -05:00
event . initEvent ( this . kEVENT _TYPE _DETACHED , true , false ) ;
2009-12-25 23:49:58 -05:00
event . parentTab = parentTab ;
2009-05-15 13:17:57 -04:00
aChild . dispatchEvent ( event ) ;
2009-07-23 12:26:33 -04:00
2009-07-23 12:28:31 -04:00
if ( this . isGroupTab ( parentTab ) && ! this . hasChildTabs ( parentTab ) ) {
2009-07-23 12:59:35 -04:00
window . setTimeout ( function ( aTabBrowser ) {
if ( parentTab . parentNode )
2010-08-08 05:42:47 -04:00
aTabBrowser . removeTab ( parentTab , { animate : true } ) ;
2009-07-23 12:59:35 -04:00
parentTab = null ;
} , 0 , this . getTabBrowserFromChild ( parentTab ) ) ;
2009-07-23 12:26:33 -04:00
}
} ,
2009-12-25 03:34:52 -05:00
detachTab : function TSTBrowser _detachTab ( aChild , aInfo ) // alias (unstable API!)
2009-07-23 12:26:33 -04:00
{
2009-07-30 05:56:28 -04:00
return this . partTab ( aChild , aInfo ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-16 12:52:25 -05:00
2009-12-25 03:34:52 -05:00
partAllChildren : function TSTBrowser _partAllChildren ( aTab , aInfo )
2009-12-16 12:52:25 -05:00
{
2010-08-13 14:32:43 -04:00
aInfo = aInfo || { } ;
if ( ! ( 'behavior' in aInfo ) )
aInfo . behavior = this . CHILDREN _SIMPLY _DETACH ;
if ( aInfo . behavior == this . CHILDREN _CLOSE )
aInfo . behavior = this . CHILDREN _PROMOTE _FIRST ;
var dontUpdateIndent = aInfo . dontUpdateIndent ;
var b = this . mTabBrowser ;
var parentTab = this . getParentTab ( aTab ) ;
var children = this . getChildTabs ( aTab ) ;
2010-09-18 12:13:07 -04:00
var insertBefore = null ;
if ( aInfo . behavior == this . CHILDREN _DETACH &&
! this . getTreePref ( 'closeParentBehavior.moveDetachedTabsToBottom' ) ) {
insertBefore = this . getNextSiblingTab ( this . getRootTab ( aTab ) ) ;
}
2010-08-13 14:32:43 -04:00
children . forEach ( (
aInfo . behavior == this . CHILDREN _DETACH ?
function ( aTab ) {
this . partTab ( aTab , aInfo ) ;
2010-09-18 12:13:07 -04:00
this . moveTabSubtreeTo ( aTab , insertBefore ? insertBefore . _tPos - 1 : this . getLastTab ( b ) . _tPos ) ;
2010-08-13 14:32:43 -04:00
} :
aInfo . behavior == this . CHILDREN _PROMOTE _FIRST ?
function ( aTab , aIndex ) {
this . partTab ( aTab , aInfo ) ;
if ( aIndex == 0 ) {
if ( parentTab ) {
this . attachTabTo ( aTab , parentTab , {
_ _proto _ _ : aInfo ,
dontExpand : true ,
dontMove : true
} ) ;
}
this . collapseExpandSubtree ( aTab , false ) ;
this . deleteTabValue ( aTab , this . kSUBTREE _COLLAPSED ) ;
}
else {
this . attachTabTo ( aTab , children [ 0 ] , {
_ _proto _ _ : aInfo ,
dontExpand : true ,
dontMove : true
} ) ;
}
} :
aInfo . behavior == this . CHILDREN _PROMOTE _ALL && parentTab ?
function ( aTab ) {
this . attachTabTo ( aTab , parentTab , {
_ _proto _ _ : aInfo ,
dontExpand : true ,
dontMove : true
} ) ;
} :
// aInfo.behavior == this.CHILDREN_SIMPLY_DETACH ?
function ( aTab ) {
this . partTab ( aTab , aInfo ) ;
}
) , this ) ;
2009-12-16 12:52:25 -05:00
} ,
2010-08-13 13:14:46 -04:00
updateTabsIndent : function TSTBrowser _updateTabsIndent ( aTabs , aLevel , aJustNow )
2007-11-14 14:34:36 -05:00
{
2009-12-18 04:05:41 -05:00
if ( ! aTabs || ! aTabs . length || ! this . _treeViewEnabled ) return ;
2007-11-17 00:20:26 -05:00
2010-12-01 03:40:18 -05:00
if ( aLevel === void ( 0 ) )
aLevel = this . getAncestorTabs ( aTabs [ 0 ] ) . length ;
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
2009-04-07 13:14:09 -04:00
var margin = this . indent < 0 ? this . baseIndent : this . indent ;
2010-11-29 03:24:45 -05:00
var indent = ( this . maxTreeLevel < 0 ? aLevel : Math . min ( aLevel , this . maxTreeLevel ) ) * margin ;
2007-11-17 00:20:26 -05:00
2009-12-18 07:57:21 -05:00
var multirow = this . isMultiRow ( ) ;
if ( multirow ) {
let maxIndent = parseInt ( aTabs [ 0 ] . boxObject . height / 2 ) ;
indent = Math . min ( aLevel * 3 , maxIndent ) ;
}
2009-04-20 07:38:58 -04:00
Array . slice ( aTabs ) . forEach ( function ( aTab ) {
2009-05-06 22:19:10 -04:00
if ( ! aTab . parentNode ) return ; // ignore removed tabs
2010-08-13 13:14:46 -04:00
this . updateTabIndent ( aTab , indent , aJustNow ) ;
2009-04-20 07:38:58 -04:00
aTab . setAttribute ( this . kNEST , aLevel ) ;
2010-12-01 03:40:18 -05:00
this . updateCanCollapseSubtree ( aTab , aLevel ) ;
2010-08-13 13:14:46 -04:00
this . updateTabsIndent ( this . getChildTabs ( aTab ) , aLevel + 1 , aJustNow ) ;
2009-04-20 07:38:58 -04:00
} , this ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-25 03:34:52 -05:00
updateTabsIndentWithDelay : function TSTBrowser _updateTabsIndentWithDelay ( aTabs )
2009-04-20 09:00:05 -04:00
{
if ( this . updateTabsIndentWithDelayTimer )
window . clearTimeout ( this . updateTabsIndentWithDelayTimer ) ;
2009-04-20 10:10:58 -04:00
this . updateTabsIndentWithDelayTabs = this . updateTabsIndentWithDelayTabs . concat ( aTabs ) ;
2009-04-20 09:00:05 -04:00
this . updateTabsIndentWithDelayTimer = window . setTimeout ( function ( aSelf ) {
2009-04-20 10:10:58 -04:00
var tabs = [ ] ;
aSelf . updateTabsIndentWithDelayTabs . forEach ( function ( aTab ) {
2009-05-06 22:19:10 -04:00
if ( tabs . indexOf ( aTab ) < 0 && aTab . parentNode ) tabs . push ( aTab ) ;
2009-04-20 10:10:58 -04:00
} ) ;
2009-04-22 07:32:39 -04:00
aSelf . updateTabsIndentWithDelayTabs = [ ] ;
2009-04-20 10:10:58 -04:00
aSelf . updateTabsIndent ( tabs ) ;
2009-04-20 09:00:05 -04:00
window . clearTimeout ( aSelf . updateTabsIndentWithDelayTimer ) ;
aSelf . updateTabsIndentWithDelayTimer = null ;
2009-05-13 02:09:17 -04:00
tabs = null ;
2009-04-20 09:00:05 -04:00
} , 0 , this ) ;
} ,
2009-04-20 10:10:58 -04:00
updateTabsIndentWithDelayTabs : [ ] ,
2009-04-20 09:00:05 -04:00
updateTabsIndentWithDelayTimer : null ,
2009-04-07 12:09:17 -04:00
2010-08-13 13:14:46 -04:00
updateTabIndent : function TSTBrowser _updateTabIndent ( aTab , aIndent , aJustNow )
2009-04-07 12:09:17 -04:00
{
this . stopTabIndentAnimation ( aTab ) ;
2010-11-18 23:00:42 -05:00
if ( ! this . enableSubtreeIndent )
aIndent = 0 ;
2009-12-18 04:05:41 -05:00
if ( this . isMultiRow ( ) ) {
2010-08-13 13:14:46 -04:00
let colors = '-moz-border-' + this . indentTarget + '-colors:' + ( function ( ) {
2009-12-18 04:05:41 -05:00
var retVal = [ ] ;
2009-12-18 07:57:21 -05:00
for ( var i = 1 ; i < aIndent ; i ++ )
2009-12-18 04:05:41 -05:00
{
retVal . push ( 'transparent' ) ;
}
retVal . push ( 'ThreeDShadow' ) ;
return retVal . length == 1 ? 'none' : retVal . join ( ' ' ) ;
2009-12-18 07:57:21 -05:00
} ) ( ) + ' !important;' ;
2009-12-18 04:05:41 -05:00
Array . slice ( document . getAnonymousNodes ( aTab ) ) . forEach ( function ( aBox ) {
if ( aBox . nodeType != Node . ELEMENT _NODE ) return ;
aBox . setAttribute (
'style' ,
aBox . getAttribute ( 'style' ) . replace ( /(-moz-)?border-(top|bottom)(-[^:]*)?.*:[^;]+;?/g , '' ) +
2010-08-13 13:14:46 -04:00
'; border-' + this . indentTarget + ': solid transparent ' + aIndent + 'px !important;' + colors
2009-12-18 04:05:41 -05:00
) ;
} , this ) ;
2009-12-18 07:57:21 -05:00
return ;
}
2009-12-18 04:05:41 -05:00
2009-04-07 12:09:17 -04:00
if (
! this . animationEnabled ||
2009-04-07 13:58:58 -04:00
aJustNow ||
2009-04-09 21:32:03 -04:00
this . indentDuration < 1 ||
2009-10-25 22:36:42 -04:00
this . isCollapsed ( aTab )
2009-04-07 12:09:17 -04:00
) {
2010-08-13 13:14:46 -04:00
aTab . style . setProperty ( this . indentCSSProp , aIndent + 'px' , 'important' ) ;
2009-04-07 12:09:17 -04:00
return ;
}
2010-08-13 13:14:46 -04:00
var self = this ;
2010-08-08 08:46:33 -04:00
var CSSTransitionEnabled = ( 'Transition' in aTab . style || 'MozTransition' in aTab . style ) ;
if ( CSSTransitionEnabled ) {
aTab . _ _treestyletab _ _updateTabIndentTask = function ( aTime , aBeginning , aChange , aDuration ) {
2010-08-13 13:14:46 -04:00
aTab . style . setProperty ( self . indentCSSProp , aIndent + 'px' , 'important' ) ;
2010-08-08 08:46:33 -04:00
return true ;
} ;
this . animationManager . addTask (
aTab . _ _treestyletab _ _updateTabIndentTask ,
2010-09-01 04:34:30 -04:00
0 , 0 , 1 , window
2010-08-08 08:46:33 -04:00
) ;
return ;
}
2010-08-13 13:14:46 -04:00
var startIndent = this . getPropertyPixelValue ( aTab , this . indentCSSProp ) ;
2009-04-07 12:09:17 -04:00
var delta = aIndent - startIndent ;
2009-04-08 09:43:44 -04:00
var radian = 90 * Math . PI / 180 ;
2009-04-09 21:32:03 -04:00
aTab . _ _treestyletab _ _updateTabIndentTask = function ( aTime , aBeginning , aChange , aDuration ) {
2009-04-08 09:43:44 -04:00
var indent , finished ;
2009-04-09 21:32:03 -04:00
if ( aTime >= aDuration ) {
2009-04-08 05:16:39 -04:00
delete aTab . _ _treestyletab _ _updateTabIndentTask ;
2009-04-08 09:43:44 -04:00
indent = aIndent ;
finished = true ;
2009-04-08 05:16:39 -04:00
}
else {
2009-04-09 21:32:03 -04:00
indent = startIndent + ( delta * Math . sin ( aTime / aDuration * radian ) ) ;
2009-04-08 09:43:44 -04:00
finished = false ;
2009-04-08 05:16:39 -04:00
}
2010-08-13 13:14:46 -04:00
aTab . style . setProperty ( self . indentCSSProp , indent + 'px' , 'important' ) ;
2009-05-13 02:09:17 -04:00
if ( finished ) {
startIndent = null ;
delta = null ;
radian = null ;
self = null ;
aTab = null ;
}
2009-04-08 09:43:44 -04:00
return finished ;
2009-04-08 05:16:39 -04:00
} ;
2010-06-22 14:00:16 -04:00
this . animationManager . addTask (
2009-04-08 05:44:44 -04:00
aTab . _ _treestyletab _ _updateTabIndentTask ,
2010-09-01 04:34:30 -04:00
0 , 0 , this . indentDuration , window
2009-04-08 05:44:44 -04:00
) ;
2009-04-07 12:09:17 -04:00
} ,
2009-12-25 03:34:52 -05:00
stopTabIndentAnimation : function TSTBrowser _stopTabIndentAnimation ( aTab )
2009-04-07 10:44:39 -04:00
{
2010-06-22 14:00:16 -04:00
this . animationManager . removeTask (
2009-04-08 05:44:44 -04:00
aTab . _ _treestyletab _ _updateTabIndentTask
) ;
2009-04-07 12:09:17 -04:00
} ,
2009-12-25 03:34:52 -05:00
inheritTabIndent : function TSTBrowser _inheritTabIndent ( aNewTab , aExistingTab )
2009-04-07 12:09:17 -04:00
{
2010-08-13 13:14:46 -04:00
var indent = this . getPropertyPixelValue ( aExistingTab , this . indentCSSProp ) ;
if ( indent )
aNewTab . style . setProperty ( this . indentCSSProp , indent + 'px' , 'important' ) ;
else
aNewTab . style . removeProperty ( this . indentCSSProp ) ;
2009-04-07 10:44:39 -04:00
} ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
updateAllTabsIndent : function TSTBrowser _updateAllTabsIndent ( )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
this . updateTabsIndent ( this . rootTabs , 0 ) ;
// this.checkTabsIndentOverflow();
2007-11-14 14:34:36 -05:00
} ,
2007-11-17 00:20:26 -05:00
2009-12-25 03:34:52 -05:00
checkTabsIndentOverflow : function TSTBrowser _checkTabsIndentOverflow ( )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
if ( this . checkTabsIndentOverflowTimer ) {
window . clearTimeout ( this . checkTabsIndentOverflowTimer ) ;
this . checkTabsIndentOverflowTimer = null ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
this . checkTabsIndentOverflowTimer = window . setTimeout ( function ( aSelf ) {
aSelf . checkTabsIndentOverflowCallback ( ) ;
} , 100 , this ) ;
2007-11-14 14:34:36 -05:00
} ,
2007-11-17 00:20:26 -05:00
checkTabsIndentOverflowTimer : null ,
2009-12-25 03:34:52 -05:00
checkTabsIndentOverflowCallback : function TSTBrowser _checkTabsIndentOverflowCallback ( )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
var tabs = this . getArrayFromXPathResult ( this . evaluateXPath (
'child::xul:tab[@' + this . kNEST + ' and not(@' + this . kNEST + '="0" or @' + this . kNEST + '="")]' ,
b . mTabContainer
) ) ;
if ( ! tabs . length ) return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var self = this ;
tabs . sort ( function ( aA , aB ) { return Number ( aA . getAttribute ( self . kNEST ) ) - Number ( aB . getAttribute ( self . kNEST ) ) ; } ) ;
2008-10-17 08:35:55 -04:00
var nest = tabs [ tabs . length - 1 ] . getAttribute ( this . kNEST ) ;
2010-11-29 03:24:45 -05:00
if ( this . maxTreeLevel > - 1 )
nest = Math . min ( nest , this . maxTreeLevel ) ;
if ( ! nest )
return ;
2007-11-14 14:34:36 -05:00
2009-04-07 13:14:09 -04:00
var oldIndent = this . indent ;
var indent = ( oldIndent < 0 ? this . baseIndent : oldIndent ) * nest ;
2009-07-07 04:30:30 -04:00
var maxIndentBase = Math . min (
2010-06-25 11:59:59 -04:00
this . getFirstNormalTab ( b ) . boxObject [ this . invertedSizeProp ] ,
2009-05-12 15:09:13 -04:00
b . mTabContainer . boxObject [ this . invertedSizeProp ]
) ;
if ( ! this . isVertical ) {
if ( this . _horizontalTabMaxIndentBase )
maxIndentBase = this . _horizontalTabMaxIndentBase ;
else
this . _horizontalTabMaxIndentBase = maxIndentBase ;
}
var maxIndent = maxIndentBase * ( this . isVertical ? 0.33 : 0.5 ) ;
2007-11-14 14:34:36 -05:00
2009-04-07 13:14:09 -04:00
var indentUnit = Math . max ( Math . floor ( maxIndent / nest ) , 1 ) ;
2007-11-17 00:20:26 -05:00
if ( indent > maxIndent ) {
2009-04-07 13:14:09 -04:00
this . indent = indentUnit ;
2007-11-17 00:20:26 -05:00
}
else {
2009-04-07 13:14:09 -04:00
this . indent = - 1 ;
if ( ( this . baseIndent * nest ) > maxIndent )
this . indent = indentUnit ;
2007-11-17 00:20:26 -05:00
}
2007-11-14 14:34:36 -05:00
2009-04-07 13:14:09 -04:00
if ( oldIndent != this . indent ) {
2007-11-17 00:20:26 -05:00
this . updateAllTabsIndent ( ) ;
}
} ,
2009-05-12 15:09:13 -04:00
_horizontalTabMaxIndentBase : 0 ,
2007-11-17 00:20:26 -05:00
2010-12-01 03:40:18 -05:00
updateCanCollapseSubtree : function TSTBrowser _updateCanCollapseSubtree ( aTab , aLevel )
{
if (
! aLevel ||
this . maxTreeLevel < 0 ||
this . maxTreeLevel > aLevel
) {
aTab . setAttribute ( this . kALLOW _COLLAPSE , true ) ;
this . collapseExpandSubtree ( aTab , this . isSubtreeCollapsed ( aTab ) ) ;
}
else {
this . collapseExpandSubtree ( aTab , false ) ;
aTab . removeAttribute ( this . kALLOW _COLLAPSE ) ;
}
} ,
2009-12-25 03:34:52 -05:00
updateTabsCount : function TSTBrowser _updateTabsCount ( aTab , aDontUpdateAncestor )
2007-11-17 00:20:26 -05:00
{
var count = document . getAnonymousElementByAttribute ( aTab , 'class' , this . kCOUNTER ) ;
if ( count ) {
2010-01-31 23:06:09 -05:00
count . setAttribute ( 'value' , this . getDescendantTabs ( aTab ) . length ) ;
2007-11-17 00:20:26 -05:00
}
var parent = this . getParentTab ( aTab ) ;
if ( parent && ! aDontUpdateAncestor )
this . updateTabsCount ( parent ) ;
} ,
2010-11-29 03:24:45 -05:00
promoteTooDeepLevelTabs : function TSTBrowser _promoteTooDeepLevelTabs ( aParent )
{
if ( this . maxTreeLevel < 0 || ! this . maxTreeLevelPhisical )
return ;
var tabs = aParent ? this . getDescendantTabs ( aParent ) : this . getAllTabsArray ( this . mTabBrowser ) ;
tabs . forEach ( function ( aTab ) {
var level = parseInt ( aTab . getAttribute ( this . kNEST ) || 0 ) ;
if ( level <= this . maxTreeLevel )
return ;
var parent = this . getParentTab ( aTab ) ;
var newParent = this . getParentTab ( parent ) ;
if ( this . maxTreeLevel == 0 || ! newParent ) {
this . partTab ( aTab ) ;
}
else {
let nextSibling = this . getNextTab ( aTab ) ;
this . attachTabTo ( aTab , newParent , {
dontMove : true ,
insertBefore : nextSibling
} ) ;
}
} , this ) ;
} ,
2007-11-17 00:20:26 -05:00
/* move */
2009-12-25 06:19:50 -05:00
moveTabSubtreeTo : function TSTBrowser _moveTabSubtreeTo ( aTab , aIndex )
2007-11-17 00:20:26 -05:00
{
if ( ! aTab ) return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
2009-09-30 01:42:48 -04:00
this . subTreeMovingCount ++ ;
2007-11-14 14:34:36 -05:00
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount ++ ;
2007-11-17 00:20:26 -05:00
b . moveTabTo ( aTab , aIndex ) ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount -- ;
2007-11-14 14:34:36 -05:00
2009-09-30 01:42:48 -04:00
this . subTreeChildrenMovingCount ++ ;
this . internallyTabMovingCount ++ ;
2009-04-20 09:30:54 -04:00
this . getDescendantTabs ( aTab ) . forEach ( function ( aDescendantTab , aIndex ) {
b . moveTabTo ( aDescendantTab , aTab . _tPos + aIndex + ( aTab . _tPos < aDescendantTab . _tPos ? 1 : 0 ) ) ;
2009-04-20 07:38:58 -04:00
} , this ) ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount -- ;
this . subTreeChildrenMovingCount -- ;
2007-11-14 14:34:36 -05:00
2009-09-30 01:42:48 -04:00
this . subTreeMovingCount -- ;
2007-11-17 00:20:26 -05:00
} ,
2009-12-25 06:36:22 -05:00
moveTabSubTreeTo : function ( ) { return this . moveTabSubtreeTo . apply ( this , arguments ) ; } , // obsolete, for backward compatibility
2007-11-17 00:20:26 -05:00
2009-12-25 03:34:52 -05:00
moveTabLevel : function TSTBrowser _moveTabLevel ( aEvent )
2007-11-17 00:20:26 -05:00
{
var b = this . mTabBrowser ;
var parentTab = this . getParentTab ( b . mCurrentTab ) ;
if ( aEvent . keyCode == KeyEvent . DOM _VK _RIGHT ) {
var prevTab = this . getPreviousSiblingTab ( b . mCurrentTab ) ;
if ( ( ! parentTab && prevTab ) ||
( parentTab && b . mCurrentTab != this . getFirstChildTab ( parentTab ) ) ) {
this . attachTabTo ( b . mCurrentTab , prevTab ) ;
b . mCurrentTab . focus ( ) ;
return true ;
}
}
else if ( aEvent . keyCode == KeyEvent . DOM _VK _LEFT && parentTab ) {
var grandParent = this . getParentTab ( parentTab ) ;
if ( grandParent ) {
this . attachTabTo ( b . mCurrentTab , grandParent , {
insertBefore : this . getNextSiblingTab ( parentTab )
} ) ;
b . mCurrentTab . focus ( ) ;
return true ;
}
else {
var nextTab = this . getNextSiblingTab ( parentTab ) ;
this . partTab ( b . mCurrentTab ) ;
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount ++ ;
2007-11-17 00:20:26 -05:00
if ( nextTab ) {
b . moveTabTo ( b . mCurrentTab , nextTab . _tPos - 1 ) ;
}
else {
2009-01-26 01:37:29 -05:00
b . moveTabTo ( b . mCurrentTab , this . getLastTab ( b ) . _tPos ) ;
2007-11-17 00:20:26 -05:00
}
2009-09-30 01:42:48 -04:00
this . internallyTabMovingCount -- ;
2007-11-17 00:20:26 -05:00
b . mCurrentTab . focus ( ) ;
return true ;
}
}
return false ;
} ,
/* collapse/expand */
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
collapseExpandSubtree : function TSTBrowser _collapseExpandSubtree ( aTab , aCollapse , aJustNow ) /* PUBLIC API */
2007-11-17 00:20:26 -05:00
{
if ( ! aTab ) return ;
2007-11-14 14:34:36 -05:00
2009-10-25 22:36:42 -04:00
if ( this . isSubtreeCollapsed ( aTab ) == aCollapse ) return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
this . doingCollapseExpand = true ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
this . setTabValue ( aTab , this . kSUBTREE _COLLAPSED , aCollapse ) ;
2007-11-14 14:34:36 -05:00
2009-04-20 07:38:58 -04:00
this . getChildTabs ( aTab ) . forEach ( function ( aTab ) {
this . collapseExpandTab ( aTab , aCollapse , aJustNow ) ;
} , this ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
if ( ! aCollapse )
2009-12-25 06:19:50 -05:00
this . scrollToTabSubtree ( aTab ) ;
2007-11-17 00:20:26 -05:00
this . doingCollapseExpand = false ;
2007-11-14 14:34:36 -05:00
} ,
2007-11-17 00:20:26 -05:00
2009-12-25 03:34:52 -05:00
collapseExpandTab : function TSTBrowser _collapseExpandTab ( aTab , aCollapse , aJustNow )
2007-11-14 14:34:36 -05:00
{
2007-11-23 15:45:38 -05:00
if ( ! aTab || ! this . getParentTab ( aTab ) ) return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
this . setTabValue ( aTab , this . kCOLLAPSED , aCollapse ) ;
2009-04-07 13:58:58 -04:00
this . updateTabCollapsed ( aTab , aCollapse , aJustNow ) ;
2007-11-14 14:34:36 -05:00
2009-05-15 11:51:12 -04:00
/* PUBLIC API */
2009-03-25 09:26:41 -04:00
var event = document . createEvent ( 'Events' ) ;
2010-11-30 05:05:00 -05:00
event . initEvent ( this . kEVENT _TYPE _TAB _COLLAPSED _STATE _CHANGED , true , false ) ;
2009-03-25 09:26:41 -04:00
event . collapsed = aCollapse ;
aTab . dispatchEvent ( event ) ;
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
2008-07-30 14:03:44 -04:00
var parent ;
if ( aCollapse && aTab == b . selectedTab && ( parent = this . getParentTab ( aTab ) ) ) {
var newSelection = parent ;
2009-10-25 22:36:42 -04:00
while ( this . isCollapsed ( parent ) )
2008-07-30 14:03:44 -04:00
{
parent = this . getParentTab ( parent ) ;
if ( ! parent ) break ;
newSelection = parent ;
}
b . selectedTab = newSelection ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
2009-10-25 22:36:42 -04:00
if ( ! this . isSubtreeCollapsed ( aTab ) ) {
2009-04-20 07:38:58 -04:00
this . getChildTabs ( aTab ) . forEach ( function ( aTab ) {
this . collapseExpandTab ( aTab , aCollapse , aJustNow ) ;
} , this ) ;
2007-11-14 14:34:36 -05:00
}
} ,
2009-12-25 03:34:52 -05:00
updateTabCollapsed : function TSTBrowser _updateTabCollapsed ( aTab , aCollapsed , aJustNow )
2009-04-07 13:14:09 -04:00
{
this . stopTabCollapseAnimation ( aTab ) ;
2009-04-08 11:00:21 -04:00
aTab . removeAttribute ( this . kX _OFFSET ) ;
aTab . removeAttribute ( this . kY _OFFSET ) ;
2010-05-02 00:30:51 -04:00
aTab . setAttribute ( this . kCOLLAPSING _PHASE , aCollapsed ? this . kCOLLAPSING _PHASE _TO _BE _COLLAPSED : this . kCOLLAPSING _PHASE _TO _BE _EXPANDED ) ;
2010-05-06 13:39:10 -04:00
var CSSTransitionEnabled = ( 'Transition' in aTab . style || 'MozTransition' in aTab . style ) ;
2009-04-07 13:14:09 -04:00
2009-04-08 11:00:21 -04:00
var maxMargin ;
var offsetAttr ;
2010-05-06 13:39:10 -04:00
var collapseProp = 'margin-' + this . collapseTarget ;
2010-08-13 13:14:46 -04:00
let ( firstTab = this . getFirstNormalTab ( this . mTabBrowser ) ) {
2009-05-13 02:47:06 -04:00
if ( this . isVertical ) {
maxMargin = firstTab . boxObject . height ;
offsetAttr = this . kY _OFFSET ;
if ( firstTab . style . height )
aTab . style . height = firstTab . style . height ;
}
else {
maxMargin = firstTab . boxObject . width ;
offsetAttr = this . kX _OFFSET ;
if ( firstTab . style . width )
aTab . style . width = firstTab . style . width ;
}
2009-04-08 11:00:21 -04:00
}
2009-04-08 09:43:44 -04:00
var startMargin , endMargin , startOpacity , endOpacity ;
if ( aCollapsed ) {
startMargin = 0 ;
2009-04-08 11:00:21 -04:00
endMargin = maxMargin ;
2009-04-08 09:43:44 -04:00
startOpacity = 1 ;
endOpacity = 0 ;
2010-11-24 11:14:36 -05:00
if ( this . canStackTabs && this . getParentTab ( aTab ) ) {
endOpacity = 1 ;
endMargin = this . kSTACKED _TAB _MARGIN ;
}
2009-04-08 09:43:44 -04:00
}
else {
2009-04-08 11:00:21 -04:00
startMargin = maxMargin ;
2009-04-08 09:43:44 -04:00
endMargin = 0 ;
startOpacity = 0 ;
endOpacity = 1 ;
2010-11-24 11:14:36 -05:00
if ( this . canStackTabs && this . getParentTab ( aTab ) ) {
startOpacity = 1 ;
startMargin = this . kSTACKED _TAB _MARGIN ;
}
2009-04-08 09:43:44 -04:00
}
2010-05-06 13:39:10 -04:00
if (
! this . animationEnabled ||
aJustNow ||
this . collapseDuration < 1 ||
// !this.isVertical ||
2010-11-29 03:24:45 -05:00
! this . canCollapseSubtree ( this . getParentTab ( aTab ) )
2010-05-06 13:39:10 -04:00
) {
2010-05-06 13:41:25 -04:00
if ( aCollapsed )
aTab . setAttribute ( this . kCOLLAPSED _DONE , true ) ;
else
aTab . removeAttribute ( this . kCOLLAPSED _DONE ) ;
2010-08-13 13:14:46 -04:00
if ( CSSTransitionEnabled ) {
2010-11-24 19:49:26 -05:00
aTab . style . setProperty ( this . collapseCSSProp , endMargin ? '-' + endMargin + 'px' : '' , 'important' ) ;
2010-08-13 13:14:46 -04:00
if ( endOpacity == 0 )
2010-11-24 19:49:26 -05:00
aTab . style . setProperty ( 'opacity' , endOpacity == 1 ? '' : endOpacity , 'important' ) ;
2010-08-13 13:14:46 -04:00
else
aTab . style . removeProperty ( 'opacity' ) ;
}
else {
aTab . style . removeProperty ( this . collapseCSSProp ) ;
aTab . style . removeProperty ( 'opacity' ) ;
}
2010-05-06 13:39:10 -04:00
return ;
}
2009-04-07 13:14:09 -04:00
var deltaMargin = endMargin - startMargin ;
var deltaOpacity = endOpacity - startOpacity ;
2010-11-24 19:49:26 -05:00
aTab . style . setProperty ( this . collapseCSSProp , startMargin ? '-' + startMargin + 'px' : '' , 'important' ) ;
aTab . style . setProperty ( 'opacity' , startOpacity == 1 ? '' : startOpacity , 'important' ) ;
2009-04-08 11:00:21 -04:00
2010-05-06 13:39:10 -04:00
if ( ! aCollapsed ) {
aTab . setAttribute ( offsetAttr , maxMargin ) ;
aTab . removeAttribute ( this . kCOLLAPSED _DONE ) ;
}
2009-04-07 13:14:09 -04:00
2009-04-08 09:43:44 -04:00
var radian = 90 * Math . PI / 180 ;
var self = this ;
2010-08-07 12:11:08 -04:00
var firstFrame = true ;
2009-04-09 21:32:03 -04:00
aTab . _ _treestyletab _ _updateTabCollapsedTask = function ( aTime , aBeginning , aChange , aDuration ) {
2010-08-07 12:11:08 -04:00
if ( firstFrame && CSSTransitionEnabled ) {
2010-11-24 19:49:26 -05:00
aTab . style . setProperty ( self . collapseCSSProp , endMargin ? '-' + endMargin + 'px' : '' , 'important' ) ;
aTab . style . setProperty ( 'opacity' , endOpacity == 1 ? '' : endOpacity , 'important' ) ;
2010-08-07 12:11:08 -04:00
}
firstFrame = false ;
2009-05-12 13:35:06 -04:00
// If this is the last tab, negative scroll happens.
// Then, we shouldn't do animation.
var stopAnimation = false ;
var scrollBox = self . scrollBox ;
if ( scrollBox ) {
if ( scrollBox . _scrollbox ) scrollBox = scrollBox . _scrollbox ;
if ( 'scrollTop' in scrollBox &&
( scrollBox . scrollTop < 0 || scrollBox . scrollLeft < 0 ) ) {
scrollBox . scrollTop = 0 ;
scrollBox . scrollLeft = 0 ;
stopAnimation = true ;
}
}
if ( aTime >= aDuration || stopAnimation ) {
2009-04-08 09:43:44 -04:00
delete aTab . _ _treestyletab _ _updateTabCollapsedTask ;
2009-04-08 11:00:21 -04:00
if ( aCollapsed ) aTab . setAttribute ( self . kCOLLAPSED _DONE , true ) ;
2010-08-13 13:14:46 -04:00
if ( ! CSSTransitionEnabled )
aTab . style . removeProperty ( self . collapseCSSProp ) ;
aTab . style . removeProperty ( 'opacity' ) ;
2009-04-08 11:00:21 -04:00
aTab . removeAttribute ( offsetAttr ) ;
2009-05-13 02:09:17 -04:00
maxMargin = null ;
offsetAttr = null ;
startMargin = null ;
endMargin = null ;
startOpacity = null ;
endOpacity = null ;
deltaMargin = null ;
deltaOpacity = null ;
collapseProp = null ;
radian = null ;
self = null ;
aTab = null ;
2009-04-08 05:16:39 -04:00
return true ;
2009-04-07 13:14:09 -04:00
}
2009-04-08 05:16:39 -04:00
else {
2010-05-02 00:30:51 -04:00
if ( ! CSSTransitionEnabled ) {
let power = Math . sin ( aTime / aDuration * radian ) ;
let margin = startMargin + ( deltaMargin * power ) ;
let opacity = startOpacity + ( deltaOpacity * power ) ;
2010-11-24 19:49:26 -05:00
aTab . style . setProperty ( self . collapseCSSProp , margin ? '-' + margin + 'px' : '' , 'important' ) ;
aTab . style . setProperty ( 'opacity' , opacity == 1 ? '' : opacity , 'important' ) ;
2010-05-02 00:30:51 -04:00
}
2009-04-08 11:16:34 -04:00
aTab . setAttribute ( offsetAttr , maxMargin ) ;
2009-04-08 05:16:39 -04:00
return false ;
}
} ;
2010-06-22 14:00:16 -04:00
this . animationManager . addTask (
2009-04-08 05:44:44 -04:00
aTab . _ _treestyletab _ _updateTabCollapsedTask ,
2010-09-01 04:34:30 -04:00
0 , 0 , this . collapseDuration , window
2009-04-08 05:44:44 -04:00
) ;
2009-04-07 13:14:09 -04:00
} ,
kOPACITY _RULE _REGEXP : /opacity\s*:[^;]+;?/ ,
2010-11-24 11:14:36 -05:00
kSTACKED _TAB _MARGIN : 15 ,
2009-12-25 03:34:52 -05:00
stopTabCollapseAnimation : function TSTBrowser _stopTabCollapseAnimation ( aTab )
2009-04-07 13:14:09 -04:00
{
2010-06-22 14:00:16 -04:00
this . animationManager . removeTask (
2009-04-08 05:44:44 -04:00
aTab . _ _treestyletab _ _updateTabCollapsedTask
) ;
2009-04-07 13:14:09 -04:00
} ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
collapseExpandTreesIntelligentlyFor : function TSTBrowser _collapseExpandTreesIntelligentlyFor ( aTab , aJustNow )
2007-11-14 14:34:36 -05:00
{
2009-10-25 22:47:38 -04:00
if ( ! aTab ||
this . doingCollapseExpand ||
2010-11-29 03:24:45 -05:00
! this . canCollapseSubtree ( aTab ) )
2009-10-25 22:47:38 -04:00
return ;
2007-11-14 14:34:36 -05:00
2009-08-14 02:12:08 -04:00
var b = this . mTabBrowser ;
2007-11-17 00:20:26 -05:00
var sameParentTab = this . getParentTab ( aTab ) ;
var expandedParentTabs = [
aTab . getAttribute ( this . kID )
] ;
var parentTab = aTab ;
while ( parentTab = this . getParentTab ( parentTab ) )
{
expandedParentTabs . push ( parentTab . getAttribute ( this . kID ) ) ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
expandedParentTabs = expandedParentTabs . join ( '|' ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var xpathResult = this . evaluateXPath (
'child::xul:tab[@' + this . kCHILDREN + ' and not(@' + this . kCOLLAPSED + '="true") and not(@' + this . kSUBTREE _COLLAPSED + '="true") and @' + this . kID + ' and not(contains("' + expandedParentTabs + '", @' + this . kID + '))]' ,
b . mTabContainer
) ;
var collapseTab ;
var dontCollapse ;
for ( var i = 0 , maxi = xpathResult . snapshotLength ; i < maxi ; i ++ )
{
dontCollapse = false ;
collapseTab = xpathResult . snapshotItem ( i ) ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
parentTab = this . getParentTab ( collapseTab ) ;
if ( parentTab ) {
dontCollapse = true ;
2009-10-25 22:36:42 -04:00
if ( ! this . isSubtreeCollapsed ( parentTab ) ) {
2007-11-17 00:20:26 -05:00
do {
if ( expandedParentTabs . indexOf ( parentTab . getAttribute ( this . kID ) ) < 0 )
continue ;
dontCollapse = false ;
break ;
}
while ( parentTab = this . getParentTab ( parentTab ) ) ;
}
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
if ( ! dontCollapse )
2009-04-07 13:58:58 -04:00
this . collapseExpandSubtree ( collapseTab , true , aJustNow ) ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
2009-04-07 13:58:58 -04:00
this . collapseExpandSubtree ( aTab , false , aJustNow ) ;
2007-11-14 14:34:36 -05:00
} ,
2009-12-25 03:34:52 -05:00
collapseExpandTreesIntelligentlyWithDelayFor : function TSTBrowser _collapseExpandTreesIntelligentlyWithDelayFor ( aTab )
2009-04-20 10:10:58 -04:00
{
2009-04-25 02:20:09 -04:00
if ( this . doingCollapseExpand ) return ;
2009-04-20 10:10:58 -04:00
if ( this . cETIWDFTimer )
window . clearTimeout ( this . cETIWDFTimer ) ;
this . cETIWDFTimer = window . setTimeout ( function ( aSelf ) {
window . clearTimeout ( aSelf . cETIWDFTimer ) ;
aSelf . cETIWDFTimer = null ;
aSelf . collapseExpandTreesIntelligentlyFor ( aTab ) ;
} , 0 , this ) ;
} ,
cETIWDFTimer : null ,
2007-11-14 14:34:36 -05:00
2009-12-25 03:34:52 -05:00
collapseExpandAllSubtree : function TSTBrowser _collapseExpandAllSubtree ( aCollapse , aJustNow )
2007-11-14 14:34:36 -05:00
{
2007-11-17 00:20:26 -05:00
var xpathResult = this . evaluateXPath (
'child::xul:tab[@' + this . kID + ' and @' + this . kCHILDREN +
(
aCollapse ?
' and not(@' + this . kSUBTREE _COLLAPSED + '="true")' :
' and @' + this . kSUBTREE _COLLAPSED + '="true"'
) +
']' ,
this . mTabBrowser . mTabContainer
) ;
for ( var i = 0 , maxi = xpathResult . snapshotLength ; i < maxi ; i ++ )
2007-11-14 14:34:36 -05:00
{
2009-07-03 05:58:34 -04:00
this . collapseExpandSubtree ( xpathResult . snapshotItem ( i ) , aCollapse , aJustNow ) ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
} ,
/* scroll */
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
scrollTo : function TSTBrowser _scrollTo ( aEndX , aEndY )
2007-11-17 00:20:26 -05:00
{
2009-04-08 12:00:51 -04:00
if ( this . animationEnabled || this . smoothScrollEnabled ) {
2007-11-17 00:20:26 -05:00
this . smoothScrollTo ( aEndX , aEndY ) ;
2007-11-14 14:34:36 -05:00
}
else {
2007-11-17 00:20:26 -05:00
try {
2008-06-20 01:57:38 -04:00
this . scrollBoxObject . scrollTo ( aEndX , aEndY ) ;
2007-11-17 00:20:26 -05:00
}
catch ( e ) {
2007-11-14 14:34:36 -05:00
}
}
} ,
2008-12-01 03:30:36 -05:00
2009-12-25 03:34:52 -05:00
smoothScrollTo : function TSTBrowser _smoothScrollTo ( aEndX , aEndY )
2007-11-14 14:34:36 -05:00
{
var b = this . mTabBrowser ;
2010-06-22 14:00:16 -04:00
this . animationManager . removeTask ( this . smoothScrollTask ) ;
2007-11-14 14:34:36 -05:00
2008-06-20 01:57:38 -04:00
var scrollBoxObject = this . scrollBoxObject ;
2007-11-17 00:20:26 -05:00
var x = { } , y = { } ;
scrollBoxObject . getPosition ( x , y ) ;
2009-04-08 06:03:17 -04:00
var startX = x . value ;
var startY = y . value ;
var deltaX = aEndX - startX ;
var deltaY = aEndY - startY ;
2007-11-14 14:34:36 -05:00
2010-08-26 05:40:58 -04:00
var arrowscrollbox = scrollBoxObject . element . parentNode ;
if (
arrowscrollbox &&
(
arrowscrollbox . localName != 'arrowscrollbox' ||
! ( '_isScrolling' in arrowscrollbox )
)
)
arrowscrollbox = null ;
2009-04-08 09:43:44 -04:00
var radian = 90 * Math . PI / 180 ;
2009-04-08 06:03:17 -04:00
var self = this ;
2009-04-09 21:32:03 -04:00
this . smoothScrollTask = function ( aTime , aBeginning , aChange , aDuration ) {
2009-04-08 06:03:17 -04:00
var scrollBoxObject = self . scrollBoxObject ;
2010-09-06 07:15:24 -04:00
if ( aTime >= aDuration ) {
2009-04-08 06:03:17 -04:00
scrollBoxObject . scrollTo ( aEndX , aEndY ) ;
2009-05-13 02:09:17 -04:00
b = null ;
scrollBoxObject = null ;
x = null ;
y = null ;
startX = null ;
startY = null ;
radian = null ;
self = null ;
2009-04-08 06:03:17 -04:00
return true ;
}
2007-11-14 14:34:36 -05:00
2009-04-09 21:32:03 -04:00
var power = Math . sin ( aTime / aDuration * radian ) ;
2009-04-08 09:43:44 -04:00
var newX = startX + parseInt ( deltaX * power ) ;
var newY = startY + parseInt ( deltaY * power ) ;
2007-11-14 14:34:36 -05:00
2009-04-08 06:03:17 -04:00
var x = { } , y = { } ;
scrollBoxObject . getPosition ( x , y ) ;
2007-11-14 14:34:36 -05:00
2009-04-08 06:03:17 -04:00
var w = { } , h = { } ;
scrollBoxObject . getScrolledSize ( w , h ) ;
var maxX = Math . max ( 0 , w . value - scrollBoxObject . width ) ;
var maxY = Math . max ( 0 , h . value - scrollBoxObject . height ) ;
scrollBoxObject . scrollTo ( newX , newY ) ;
return false ;
} ;
2010-06-22 14:00:16 -04:00
this . animationManager . addTask (
2009-04-08 06:03:17 -04:00
this . smoothScrollTask ,
2010-09-01 04:34:30 -04:00
0 , 0 , this . smoothScrollDuration , window
2009-04-08 06:03:17 -04:00
) ;
2007-11-17 00:20:26 -05:00
} ,
2009-04-08 06:03:17 -04:00
smoothScrollTask : null ,
2007-11-17 00:20:26 -05:00
2010-07-25 12:06:03 -04:00
scrollToTab : function TSTBrowser _scrollToTab ( aTab , aOnlyWhenCurrentTabIsInViewport )
2007-11-17 00:20:26 -05:00
{
2010-03-25 11:52:11 -04:00
if ( ! aTab || ! aTab . parentNode || this . isTabInViewport ( aTab ) )
return ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
var b = this . mTabBrowser ;
2007-11-14 14:34:36 -05:00
2008-06-20 01:57:38 -04:00
var scrollBoxObject = this . scrollBoxObject ;
2007-11-17 00:20:26 -05:00
var w = { } , h = { } ;
try {
scrollBoxObject . getScrolledSize ( w , h ) ;
}
2009-12-15 03:33:03 -05:00
catch ( e ) { // Tab Mix Plus (or others)
2007-11-17 00:20:26 -05:00
return ;
2007-11-14 14:34:36 -05:00
}
2007-11-17 00:20:26 -05:00
var targetTabBox = aTab . boxObject ;
2010-06-25 11:59:59 -04:00
var baseTabBox = this . getFirstNormalTab ( b ) . boxObject ;
2007-11-14 14:34:36 -05:00
2009-04-08 11:16:34 -04:00
var xOffset = this . getXOffsetOfTab ( aTab ) ;
var yOffset = this . getYOffsetOfTab ( aTab ) ;
2007-11-17 00:20:26 -05:00
2009-04-08 11:16:34 -04:00
var targetX = ( aTab . boxObject . screenX + xOffset < scrollBoxObject . screenX ) ?
( targetTabBox . screenX + xOffset - baseTabBox . screenX ) - ( targetTabBox . width * 0.5 ) :
( targetTabBox . screenX + xOffset - baseTabBox . screenX ) - scrollBoxObject . width + ( targetTabBox . width * 1.5 ) ;
var targetY = ( aTab . boxObject . screenY + yOffset < scrollBoxObject . screenY ) ?
( targetTabBox . screenY + yOffset - baseTabBox . screenY ) - ( targetTabBox . height * 0.5 ) :
( targetTabBox . screenY + yOffset - baseTabBox . screenY ) - scrollBoxObject . height + ( targetTabBox . height * 1.5 ) ;
2007-11-17 00:20:26 -05:00
2010-07-25 12:06:03 -04:00
if ( aOnlyWhenCurrentTabIsInViewport && b . selectedTab != aTab ) {
let box = b . selectedTab . boxObject ;
if ( targetTabBox . screenX - box . screenX + baseTabBox . width + xOffset > scrollBoxObject . width ||
targetTabBox . screenY - box . screenY + baseTabBox . height + yOffset > scrollBoxObject . height )
return ;
}
2007-11-17 00:20:26 -05:00
this . scrollTo ( targetX , targetY ) ;
} ,
2009-12-25 06:19:50 -05:00
scrollToTabSubtree : function TSTBrowser _scrollToTabSubtree ( aTab )
2007-11-17 00:20:26 -05:00
{
var b = this . mTabBrowser ;
var descendant = this . getDescendantTabs ( aTab ) ;
var lastVisible = aTab ;
for ( var i = descendant . length - 1 ; i > - 1 ; i -- )
{
2009-10-25 22:36:42 -04:00
if ( this . isCollapsed ( descendant [ i ] ) ) continue ;
2007-11-17 00:20:26 -05:00
lastVisible = descendant [ i ] ;
break ;
}
2007-11-14 14:34:36 -05:00
2008-06-18 22:11:00 -04:00
if ( this . isTabInViewport ( aTab ) && this . isTabInViewport ( lastVisible ) ) {
return ;
}
2010-03-23 09:33:00 -04:00
var containerPosition = this . tabStrip . boxObject [ this . positionProp ] ;
var containerSize = this . tabStrip . boxObject [ this . sizeProp ] ;
2007-11-17 00:20:26 -05:00
var parentPosition = aTab . boxObject [ this . positionProp ] ;
var lastPosition = lastVisible . boxObject [ this . positionProp ] ;
var tabSize = lastVisible . boxObject [ this . sizeProp ] ;
2007-11-14 14:34:36 -05:00
2007-11-17 00:20:26 -05:00
if ( lastPosition - parentPosition + tabSize > containerSize - tabSize ) { // out of screen
2010-06-25 11:59:59 -04:00
var endPos = parentPosition - this . getFirstNormalTab ( b ) . boxObject [ this . positionProp ] - tabSize * 0.5 ;
2007-11-17 00:20:26 -05:00
var endX = this . isVertical ? 0 : endPos ;
var endY = this . isVertical ? endPos : 0 ;
this . scrollTo ( endX , endY ) ;
}
else if ( ! this . isTabInViewport ( aTab ) && this . isTabInViewport ( lastVisible ) ) {
this . scrollToTab ( aTab ) ;
}
else if ( this . isTabInViewport ( aTab ) && ! this . isTabInViewport ( lastVisible ) ) {
this . scrollToTab ( lastVisible ) ;
}
else if ( parentPosition < containerPosition ) {
this . scrollToTab ( aTab ) ;
}
else {
this . scrollToTab ( lastVisible ) ;
2007-11-14 14:34:36 -05:00
}
} ,
2007-11-17 00:20:26 -05:00
2009-09-03 03:31:49 -04:00
/* show/hide tab bar */
get autoHide ( )
{
return this . _autoHide || ( this . _autoHide = new TreeStyleTabBrowserAutoHide ( this ) ) ;
} ,
// for backward compatibility
2009-12-17 22:20:35 -05:00
get tabbarShown ( ) { return this . autoHide . expanded ; } ,
set tabbarShown ( aValue ) { if ( aValue ) this . autoHide . show ( ) ; else this . autoHide . hide ( ) ; return aValue ; } ,
2009-09-03 04:18:41 -04:00
get tabbarExpanded ( ) { return this . autoHide . expanded ; } ,
2009-12-17 22:20:35 -05:00
set tabbarExpanded ( aValue ) { return this . tabbarShown = aValue ; } ,
2009-09-03 04:18:41 -04:00
get tabbarResizing ( ) { return this . autoHide . isResizing ; } ,
set tabbarResizing ( aValue ) { return this . autoHide . isResizing = aValue ; } ,
2009-09-03 02:24:06 -04:00
get togglerSize ( ) { return this . autoHide . togglerSize ; } ,
set togglerSize ( aValue ) { return this . autoHide . togglerSize = aValue ; } ,
get sensitiveArea ( ) { return this . autoHide . sensitiveArea ; } ,
set sensitiveArea ( aValue ) { return this . autoHide . sensitiveArea = aValue ; } ,
get lastMouseDownTarget ( ) { return this . autoHide . lastMouseDownTarget ; } ,
set lastMouseDownTarget ( aValue ) { return this . autoHide . lastMouseDownTarget = aValue ; } ,
2009-09-03 04:18:41 -04:00
get tabbarWidth ( ) { return this . autoHide . width ; } ,
set tabbarWidth ( aValue ) { return this . autoHide . widthwidth = aValue ; } ,
get tabbarHeight ( ) { return this . autoHide . height ; } ,
set tabbarHeight ( aValue ) { return this . autoHide . height = aValue ; } ,
2009-09-03 02:24:06 -04:00
get splitterWidth ( ) { return this . autoHide . splitterWidth ; } ,
2010-08-24 13:39:20 -04:00
get autoHideShown ( ) { return this . autoHide . expanded ; } ,
2009-12-17 22:20:35 -05:00
set autoHideShown ( aValue ) { return this . tabbarShown = aValue ; } ,
2010-08-24 13:39:20 -04:00
get autoHideXOffset ( ) { return this . autoHide . XOffset ; } ,
get autoHideYOffset ( ) { return this . autoHide . YOffset ; } ,
2009-09-03 02:24:06 -04:00
get autoHideMode ( ) { return this . autoHide . mode ; } ,
set autoHideMode ( aValue ) { return this . autoHide . mode = aValue ; } ,
2009-12-25 03:34:52 -05:00
updateAutoHideMode : function TSTBrowser _updateAutoHideMode ( ) { this . autoHide . updateAutoHideMode ( ) ; } ,
showHideTabbarInternal : function TSTBrowser _showHideTabbarInternal ( aReason ) { this . autoHide . showHideInternal ( aReason ) ; } ,
showTabbar : function TSTBrowser _showTabbar ( aReason ) { this . autoHide . show ( aReason ) ; } ,
hideTabbar : function TSTBrowser _hideTabbar ( aReason ) { this . autoHide . hide ( aReason ) ; } ,
redrawContentArea : function TSTBrowser _redrawContentArea ( ) { this . autoHide . redrawContentArea ( ) ; } ,
drawTabbarCanvas : function TSTBrowser _drawTabbarCanvas ( ) { this . autoHide . drawBG ( ) ; } ,
2009-09-03 02:24:06 -04:00
get splitterBorderColor ( ) { this . autoHide . splitterBorderColor ; } ,
2009-12-25 03:34:52 -05:00
clearTabbarCanvas : function TSTBrowser _clearTabbarCanvas ( ) { this . autoHide . clearBG ( ) ; } ,
updateTabbarTransparency : function TSTBrowser _updateTabbarTransparency ( ) { this . autoHide . updateTransparency ( ) ; } ,
2009-09-03 02:24:06 -04:00
get autoHideEnabled ( ) { return this . autoHide . enabled ; } ,
set autoHideEnabled ( aValue ) { return this . autoHide . enabled = aValue ; } ,
2009-12-25 03:34:52 -05:00
startAutoHide : function TSTBrowser _startAutoHide ( ) { this . autoHide . start ( ) ; } ,
endAutoHide : function TSTBrowser _endAutoHide ( ) { this . autoHide . end ( ) ; } ,
startAutoHideForFullScreen : function TSTBrowser _startAutoHideForFullScreen ( ) { this . autoHide . startForFullScreen ( ) ; } ,
endAutoHideForFullScreen : function TSTBrowser _endAutoHideForFullScreen ( ) { this . autoHide . endForFullScreen ( ) ; } ,
2009-09-03 02:24:06 -04:00
2009-12-25 03:34:52 -05:00
startListenMouseMove : function TSTBrowser _startListenMouseMove ( ) { this . autoHide . startListenMouseMove ( ) ; } ,
endListenMouseMove : function TSTBrowser _endListenMouseMove ( ) { this . autoHide . endListenMouseMove ( ) ; } ,
2009-09-03 02:24:06 -04:00
get shouldListenMouseMove ( ) { return this . autoHide . shouldListenMouseMove ; } ,
2009-12-25 03:34:52 -05:00
showHideTabbarOnMousemove : function TSTBrowser _showHideTabbarOnMousemove ( ) { this . autoHide . showHideOnMousemove ( ) ; } ,
cancelShowHideTabbarOnMousemove : function TSTBrowser _cancelShowHideTabbarOnMousemove ( ) { this . autoHide . cancelShowHideOnMousemove ( ) ; } ,
showTabbarForFeedback : function TSTBrowser _showTabbarForFeedback ( ) { this . autoHide . showForFeedback ( ) ; } ,
delayedShowTabbarForFeedback : function TSTBrowser _delayedShowTabbarForFeedback ( ) { this . autoHide . delayedShowForFeedback ( ) ; } ,
cancelHideTabbarForFeedback : function TSTBrowser _cancelHideTabbarForFeedback ( ) { this . autoHide . cancelHideForFeedback ( ) ; }
2008-03-09 23:51:21 -04:00
2007-11-14 14:34:36 -05:00
} ;