rearrange methods

This commit is contained in:
Piro / SHIMODA Hiroshi 2011-01-22 13:21:39 +09:00
parent 54eaa6aa78
commit 68cc97b38b

View File

@ -34,12 +34,9 @@ TreeStyleTabBrowser.prototype = {
startProp : 'top', startProp : 'top',
endProp : 'bottom', endProp : 'bottom',
maxTreeLevel : -1,
maxTreeLevelPhisical : false, maxTreeLevelPhisical : false,
enableSubtreeIndent : true, /* elements */
allowSubtreeCollapseExpand : true,
hideAlltabsButton : true,
get browser() get browser()
{ {
@ -94,53 +91,58 @@ TreeStyleTabBrowser.prototype = {
this.evaluateXPath('descendant::xul:tooltip', this.browser.mStrip, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue; // -Firefox 3.6 this.evaluateXPath('descendant::xul:tooltip', this.browser.mStrip, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue; // -Firefox 3.6
}, },
get tabbarDNDObserver() /* properties */
get maxTreeLevel()
{ {
if (!this._tabbarDNDObserver) { return this._maxTreeLevel;
let ns = {};
Components.utils.import('resource://treestyletab-modules/tabbarDNDObserver.js', ns);
this._tabbarDNDObserver = new ns.TabbarDNDObserver(this.mTabBrowser);
}
return this._tabbarDNDObserver;
}, },
set maxTreeLevel(aValue)
get panelDNDObserver()
{ {
if (!this._panelDNDObserver) { this._maxTreeLevel = aValue;
let ns = {}; this.setTabbrowserAttribute(this.kMAX_LEVEL, this._maxTreeLevel || '0');
Components.utils.import('resource://treestyletab-modules/tabpanelDNDObserver.js', ns); this.enableSubtreeIndent = this._maxTreeLevel != 0;
this._panelDNDObserver = new ns.TabpanelDNDObserver(this.mTabBrowser); return aValue;
}
return this._panelDNDObserver;
}, },
_maxTreeLevel : -1,
/* utils */ get enableSubtreeIndent()
/* get tab contents */
getTabLabel : function TSTBrowser_getTabLabel(aTab)
{ {
var label = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X return this._enableSubtreeIndent;
( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-container')
) ||
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text tab-label') || // Firefox 4.0-
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text'); // Firefox 3.5 - Firefox 3.6
return label;
}, },
set enableSubtreeIndent(aValue)
getTabClosebox : function TSTBrowser_getTabClosebox(aTab)
{ {
var close = ( // Tab Mix Plus this._enableSubtreeIndent = aValue;
this.getTreePref('compatibility.TMP') && this.setTabbrowserAttribute(this.kINDENTED, this._enableSubtreeIndent ? 'true' : null);
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button always-right') return aValue;
) ||
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button');
return close;
}, },
_enableSubtreeIndent : true,
/* status */ get allowSubtreeCollapseExpand()
{
return this._allowSubtreeCollapseExpand;
},
set allowSubtreeCollapseExpand(aValue)
{
this._allowSubtreeCollapseExpand = aValue;
this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, this._allowSubtreeCollapseExpand ? 'true' : null);
return aValue;
},
_allowSubtreeCollapseExpand : true,
get hideAlltabsButton()
{
return this._hideAlltabsButton;
},
set hideAlltabsButton(aValue)
{
this._hideAlltabsButton = aValue;
this.setTabbrowserAttribute(this.kHIDE_ALLTABS, this._hideAlltabsButton ? 'true' : null);
return aValue;
},
_hideAlltabsButton : true,
/* status getters */
get isVertical() get isVertical()
{ {
@ -179,6 +181,32 @@ TreeStyleTabBrowser.prototype = {
); );
}, },
/* utils */
/* get tab contents */
getTabLabel : function TSTBrowser_getTabLabel(aTab)
{
var label = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X
( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-container')
) ||
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text tab-label') || // Firefox 4.0-
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text'); // Firefox 3.5 - Firefox 3.6
return label;
},
getTabClosebox : function TSTBrowser_getTabClosebox(aTab)
{
var close = ( // Tab Mix Plus
this.getTreePref('compatibility.TMP') &&
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button always-right')
) ||
document.getAnonymousElementByAttribute(aTab, 'class', 'tab-close-button');
return close;
},
isTabInViewport : function TSTBrowser_isTabInViewport(aTab) isTabInViewport : function TSTBrowser_isTabInViewport(aTab)
{ {
if (!this.preInitialized || !aTab) if (!this.preInitialized || !aTab)
@ -268,38 +296,6 @@ TreeStyleTabBrowser.prototype = {
} }
}, },
onPinTab : function TSTBrowser_onPinTab(aTab)
{
var parentTab = this.getParentTab(aTab);
if (!parentTab)
this.collapseExpandSubtree(aTab, false);
this.getChildTabs(aTab).reverse().forEach(
parentTab ?
function(aChildTab) {
this.attachTabTo(aChildTab, parentTab, {
dontExpand : true,
dontMove : true
});
} :
this.partTab,
this);
this.partTab(aTab);
this.collapseExpandTab(aTab, false);
if (this.isVertical) this.positionPinnedTabs();
},
onUnpinTab : function TSTBrowser_onUnpinTab(aTab)
{
aTab.style.marginLeft = '';
aTab.style.marginTop = '';
this.updateInvertedTabContentsOrder(aTab);
if (this.isVertical) this.positionPinnedTabs();
},
updateTabsZIndex : function TSTBrowser_updateTabsZIndex(aStacked) updateTabsZIndex : function TSTBrowser_updateTabsZIndex(aStacked)
{ {
var tabs = this.getTabsArray(this.mTabBrowser); var tabs = this.getTabsArray(this.mTabBrowser);
@ -1233,21 +1229,13 @@ TreeStyleTabBrowser.prototype = {
}, 0, this); }, 0, this);
this.allowSubtreeCollapseExpand = this.getTreePref('allowSubtreeCollapseExpand.'+orient) ; this.allowSubtreeCollapseExpand = this.getTreePref('allowSubtreeCollapseExpand.'+orient) ;
this.setTabbrowserAttribute(this.kALLOW_COLLAPSE, this.allowSubtreeCollapseExpand ? 'true' : null);
this.maxTreeLevel = this.getTreePref('maxTreeLevel.'+orient); this.maxTreeLevel = this.getTreePref('maxTreeLevel.'+orient);
this.setTabbrowserAttribute(this.kMAX_LEVEL, this.maxTreeLevel || '0');
this.enableSubtreeIndent = this.maxTreeLevel != 0;
this.setTabbrowserAttribute(this.kINDENTED, this.enableSubtreeIndent ? 'true' : null);
this.setTabbrowserAttribute(this.kALLOW_STACK, this.canStackTabs ? 'true' : null); this.setTabbrowserAttribute(this.kALLOW_STACK, this.canStackTabs ? 'true' : null);
this.updateTabsZIndex(this.canStackTabs); this.updateTabsZIndex(this.canStackTabs);
if (!this.isFloating) { if (!this.isFloating)
this.hideAlltabsButton = this.getTreePref('tabbar.hideAlltabsButton.'+orient); this.hideAlltabsButton = this.getTreePref('tabbar.hideAlltabsButton.'+orient);
this.setTabbrowserAttribute(this.kHIDE_ALLTABS, this.hideAlltabsButton ? 'true' : null);
}
if (this.maxTreeLevelPhisical) if (this.maxTreeLevelPhisical)
this.promoteTooDeepLevelTabs(); this.promoteTooDeepLevelTabs();
@ -3095,6 +3083,38 @@ TreeStyleTabBrowser.prototype = {
TreeStyleTabService.restoringTree = TreeStyleTabService.getRestoringTabsCount() > 0; TreeStyleTabService.restoringTree = TreeStyleTabService.getRestoringTabsCount() > 0;
}, },
onPinTab : function TSTBrowser_onPinTab(aTab)
{
var parentTab = this.getParentTab(aTab);
if (!parentTab)
this.collapseExpandSubtree(aTab, false);
this.getChildTabs(aTab).reverse().forEach(
parentTab ?
function(aChildTab) {
this.attachTabTo(aChildTab, parentTab, {
dontExpand : true,
dontMove : true
});
} :
this.partTab,
this);
this.partTab(aTab);
this.collapseExpandTab(aTab, false);
if (this.isVertical) this.positionPinnedTabs();
},
onUnpinTab : function TSTBrowser_onUnpinTab(aTab)
{
aTab.style.marginLeft = '';
aTab.style.marginTop = '';
this.updateInvertedTabContentsOrder(aTab);
if (this.isVertical) this.positionPinnedTabs();
},
onDOMAttrModified : function TSTBrowser_onDOMAttrModified(aEvent) onDOMAttrModified : function TSTBrowser_onDOMAttrModified(aEvent)
{ {
switch (aEvent.attrName) switch (aEvent.attrName)
@ -4691,6 +4711,28 @@ TreeStyleTabBrowser.prototype = {
} }
}, },
/* sub modules */
get tabbarDNDObserver()
{
if (!this._tabbarDNDObserver) {
let ns = {};
Components.utils.import('resource://treestyletab-modules/tabbarDNDObserver.js', ns);
this._tabbarDNDObserver = new ns.TabbarDNDObserver(this.mTabBrowser);
}
return this._tabbarDNDObserver;
},
get panelDNDObserver()
{
if (!this._panelDNDObserver) {
let ns = {};
Components.utils.import('resource://treestyletab-modules/tabpanelDNDObserver.js', ns);
this._panelDNDObserver = new ns.TabpanelDNDObserver(this.mTabBrowser);
}
return this._panelDNDObserver;
},
/* show/hide tab bar */ /* show/hide tab bar */
get autoHide() get autoHide()
{ {