タブバーを自動で隠す機能について、状態をウィンドウごとに切り替えられるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6667 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-05-08 07:15:38 +00:00
parent 20ca1c2ef8
commit b89ec7dd87

View File

@ -5,7 +5,8 @@ function TreeStyleTabBrowserAutoHide(aOwner)
} }
TreeStyleTabBrowserAutoHide.prototype = { TreeStyleTabBrowserAutoHide.prototype = {
kMODE_DISABLED : 0, kMODE : 'treestyletab-tabbar-autohide-mode',
kMODE_DISABLED : 0,
kMODE_HIDE : 1, kMODE_HIDE : 1,
kMODE_SHRINK : 2, kMODE_SHRINK : 2,
@ -30,17 +31,37 @@ TreeStyleTabBrowserAutoHide.prototype = {
get mode() /* PUBLIC API */ get mode() /* PUBLIC API */
{ {
return TreeStyleTabBrowserAutoHide.mode; var mode = this.mOwner.browser.getAttribute(this.kMODE);
return mode ? parseInt(mode) : this.kMODE_DISABLED ;
}, },
set mode(aValue) set mode(aValue)
{ {
TreeStyleTabBrowserAutoHide.mode = aValue; this.mOwner.browser.setAttribute(this.kMODE, aValue);
return aValue; return aValue;
}, },
getMode : function TSTAutoHide_getMode(aTabBrowser)
{
var b = aTabBrowser || this.mOwner.browser;
var mode = b.getAttribute(this.kMODE);
return mode ? parseInt(mode) : this.kMODE_DISABLED ;
},
getModeForNormal : function TSTAutoHide_getModeForNormal(aTabBrowser)
{
var b = aTabBrowser || this.mOwner.browser;
return b.getAttribute(this.kMODE+'-normal') ||
this.getTreePref('tabbar.autoHide.mode');
},
getModeForFullscreen : function TSTAutoHide_getModeForFullscreen(aTabBrowser)
{
var b = aTabBrowser || this.mOwner.browser;
return b.getAttribute(this.kMODE+'-fullscreen') ||
this.getTreePref('tabbar.autoHide.mode.fullscreen');
},
get state() get state()
{ {
return this.mOwner.mTabBrowser.getAttribute(this.kSTATE) || this.kSTATE_EXPANDED; return this.mOwner.browser.getAttribute(this.kSTATE) || this.kSTATE_EXPANDED;
}, },
get expanded() get expanded()
{ {
@ -60,9 +81,9 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.end(); this.end();
// update internal property after the appearance of the tab bar is updated. // update internal property after the appearance of the tab bar is updated.
window.setTimeout(function(aSelf) { window.setTimeout(function(aSelf) {
aSelf.mode = window.fullScreen && aSelf.getPref('browser.fullscreen.autohide') ? aSelf.mode = (window.fullScreen && aSelf.getPref('browser.fullscreen.autohide')) ?
aSelf.getTreePref('tabbar.autoHide.mode.fullscreen') : aSelf.getModeForFullscreen() :
aSelf.getTreePref('tabbar.autoHide.mode') ; aSelf.getModeForNormal() ;
if (aSelf.mode != aSelf.kMODE_DISABLED) if (aSelf.mode != aSelf.kMODE_DISABLED)
aSelf.start(); aSelf.start();
}, 0, this); }, 0, this);
@ -125,18 +146,18 @@ TreeStyleTabBrowserAutoHide.prototype = {
var sv = this.mOwner; var sv = this.mOwner;
sv.mTabBrowser.addEventListener('mousedown', this, true); sv.browser.addEventListener('mousedown', this, true);
sv.mTabBrowser.addEventListener('mouseup', this, true); sv.browser.addEventListener('mouseup', this, true);
if (sv.isFloating) { if (sv.isFloating) {
sv.tabStrip.addEventListener('mousedown', this, true); sv.tabStrip.addEventListener('mousedown', this, true);
sv.tabStrip.addEventListener('mouseup', this, true); sv.tabStrip.addEventListener('mouseup', this, true);
} }
window.addEventListener('resize', this, true); window.addEventListener('resize', this, true);
sv.mTabBrowser.addEventListener('load', this, true); sv.browser.addEventListener('load', this, true);
sv.mTabBrowser.mPanelContainer.addEventListener('scroll', this, true); sv.browser.mPanelContainer.addEventListener('scroll', this, true);
if (this.shouldListenMouseMove) if (this.shouldListenMouseMove)
this.startListenMouseMove(); this.startListenMouseMove();
if (sv.mTabBrowser == gBrowser && sv.shouldListenKeyEventsForAutoHide) if (sv.browser == gBrowser && sv.shouldListenKeyEventsForAutoHide)
TreeStyleTabService.startListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE); TreeStyleTabService.startListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
this.clearBG(); this.clearBG();
@ -155,17 +176,17 @@ TreeStyleTabBrowserAutoHide.prototype = {
if (!this.expanded) if (!this.expanded)
this.showHideInternal(); this.showHideInternal();
sv.mTabBrowser.removeEventListener('mousedown', this, true); sv.browser.removeEventListener('mousedown', this, true);
sv.mTabBrowser.removeEventListener('mouseup', this, true); sv.browser.removeEventListener('mouseup', this, true);
if (sv.isFloating) { if (sv.isFloating) {
sv.tabStrip.removeEventListener('mousedown', this, true); sv.tabStrip.removeEventListener('mousedown', this, true);
sv.tabStrip.removeEventListener('mouseup', this, true); sv.tabStrip.removeEventListener('mouseup', this, true);
} }
window.removeEventListener('resize', this, true); window.removeEventListener('resize', this, true);
sv.mTabBrowser.removeEventListener('load', this, true); sv.browser.removeEventListener('load', this, true);
sv.mTabBrowser.mPanelContainer.removeEventListener('scroll', this, true); sv.browser.mPanelContainer.removeEventListener('scroll', this, true);
this.endListenMouseMove(); this.endListenMouseMove();
if (sv.mTabBrowser == gBrowser) if (sv.browser == gBrowser)
TreeStyleTabService.endListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE); TreeStyleTabService.endListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
this.clearBG(); this.clearBG();
@ -181,10 +202,10 @@ TreeStyleTabBrowserAutoHide.prototype = {
startForFullScreen : function TSTAutoHide_startForFullScreen() startForFullScreen : function TSTAutoHide_startForFullScreen()
{ {
this.mode = this.getTreePref('tabbar.autoHide.mode'); this.mode = this.getMode();
this.end(); this.end();
this.mode = this.getPref('browser.fullscreen.autohide') ? this.mode = this.getPref('browser.fullscreen.autohide') ?
this.getTreePref('tabbar.autoHide.mode.fullscreen') : this.getModeForFullscreen() :
this.kMODE_DISABLED ; this.kMODE_DISABLED ;
if (this.mode != this.kMODE_DISABLED) { if (this.mode != this.kMODE_DISABLED) {
this.start(); this.start();
@ -194,7 +215,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
endForFullScreen : function TSTAutoHide_endForFullScreen() endForFullScreen : function TSTAutoHide_endForFullScreen()
{ {
this.mode = this.getTreePref('tabbar.autoHide.mode.fullscreen'); this.mode = this.getModeForFullscreen();
this.end(); this.end();
this.mode = this.getTreePref('tabbar.autoHide.mode'); this.mode = this.getTreePref('tabbar.autoHide.mode');
this.mOwner.checkTabsIndentOverflow(); this.mOwner.checkTabsIndentOverflow();
@ -207,7 +228,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
startListenMouseMove : function TSTAutoHide_startListenMouseMove() startListenMouseMove : function TSTAutoHide_startListenMouseMove()
{ {
if (this.mouseMoveListening) return; if (this.mouseMoveListening) return;
this.mOwner.mTabBrowser.addEventListener('mousemove', this, true); this.mOwner.browser.addEventListener('mousemove', this, true);
if (this.mOwner.isFloating) if (this.mOwner.isFloating)
this.mOwner.tabStrip.addEventListener('mousemove', this, true); this.mOwner.tabStrip.addEventListener('mousemove', this, true);
this.mouseMoveListening = true; this.mouseMoveListening = true;
@ -216,7 +237,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
endListenMouseMove : function TSTAutoHide_endListenMouseMove() endListenMouseMove : function TSTAutoHide_endListenMouseMove()
{ {
if (!this.mouseMoveListening) return; if (!this.mouseMoveListening) return;
this.mOwner.mTabBrowser.removeEventListener('mousemove', this, true); this.mOwner.browser.removeEventListener('mousemove', this, true);
if (this.mOwner.isFloating) if (this.mOwner.isFloating)
this.mOwner.tabStrip.removeEventListener('mousemove', this, true); this.mOwner.tabStrip.removeEventListener('mousemove', this, true);
this.mouseMoveListening = false; this.mouseMoveListening = false;
@ -237,7 +258,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.cancelShowHideOnMousemove(); this.cancelShowHideOnMousemove();
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
var box = b.mCurrentBrowser.boxObject; var box = b.mCurrentBrowser.boxObject;
@ -423,7 +444,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
get splitterWidth() get splitterWidth()
{ {
if (this.expanded) { if (this.expanded) {
var splitter = document.getAnonymousElementByAttribute(this.mOwner.mTabBrowser, 'class', this.kSPLITTER); var splitter = document.getAnonymousElementByAttribute(this.mOwner.browser, 'class', this.kSPLITTER);
this._splitterWidth = (splitter ? splitter.boxObject.width : 0 ); this._splitterWidth = (splitter ? splitter.boxObject.width : 0 );
} }
return this._splitterWidth; return this._splitterWidth;
@ -440,7 +461,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.stopRendering(); this.stopRendering();
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
if (this.expanded) { // to be hidden or shrunken if (this.expanded) { // to be hidden or shrunken
@ -483,7 +504,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
onShowing : function TSTAutoHide_onShowing() onShowing : function TSTAutoHide_onShowing()
{ {
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
switch (pos) switch (pos)
@ -522,7 +543,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
onHiding : function TSTAutoHide_onHiding() onHiding : function TSTAutoHide_onHiding()
{ {
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
var box = (sv.tabStripPlaceHolder || sv.tabStrip).boxObject; var box = (sv.tabStripPlaceHolder || sv.tabStrip).boxObject;
@ -559,7 +580,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
event.initEvent('TreeStyleTabAutoHideStateChanging', true, false); event.initEvent('TreeStyleTabAutoHideStateChanging', true, false);
event.shown = this.expanded; event.shown = this.expanded;
event.state = this.state; event.state = this.state;
this.mOwner.mTabBrowser.dispatchEvent(event); this.mOwner.browser.dispatchEvent(event);
}, },
fireStateChangeEvent : function TSTAutoHide_fireStateChangeEvent() fireStateChangeEvent : function TSTAutoHide_fireStateChangeEvent()
@ -571,7 +592,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
event.state = this.state; event.state = this.state;
event.xOffset = this.XOffset; event.xOffset = this.XOffset;
event.yOffset = this.YOffset; event.yOffset = this.YOffset;
this.mOwner.mTabBrowser.dispatchEvent(event); this.mOwner.browser.dispatchEvent(event);
}, },
redrawContentArea : function TSTAutoHide_redrawContentArea() redrawContentArea : function TSTAutoHide_redrawContentArea()
@ -579,10 +600,10 @@ TreeStyleTabBrowserAutoHide.prototype = {
var sv = this.mOwner; var sv = this.mOwner;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
try { try {
var v = sv.mTabBrowser.markupDocumentViewer; var v = sv.browser.markupDocumentViewer;
if (this.shouldRedraw) { if (this.shouldRedraw) {
if (sv.mTabBrowser.hasAttribute(this.kTRANSPARENT) && if (sv.browser.hasAttribute(this.kTRANSPARENT) &&
sv.mTabBrowser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE]) sv.browser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE])
this.drawBG(); this.drawBG();
else else
this.clearBG(); this.clearBG();
@ -634,9 +655,9 @@ TreeStyleTabBrowserAutoHide.prototype = {
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
var frame = sv.mTabBrowser.contentWindow; var frame = sv.browser.contentWindow;
var tabContainerBox = sv.mTabBrowser.mTabContainer.boxObject; var tabContainerBox = sv.browser.mTabContainer.boxObject;
var browserBox = sv.mTabBrowser.mCurrentBrowser.boxObject; var browserBox = sv.browser.mCurrentBrowser.boxObject;
var contentBox = sv.getBoxObjectFor(frame.document.documentElement); var contentBox = sv.getBoxObjectFor(frame.document.documentElement);
var zoom = this.getZoomForFrame(frame); var zoom = this.getZoomForFrame(frame);
@ -663,12 +684,12 @@ TreeStyleTabBrowserAutoHide.prototype = {
var canvasXOffset = 0; var canvasXOffset = 0;
var canvasYOffset = 0; var canvasYOffset = 0;
if (pos == 'top' || pos == 'bottom') if (pos == 'top' || pos == 'bottom')
canvasXOffset = tabContainerBox.screenX - sv.mTabBrowser.boxObject.screenX; canvasXOffset = tabContainerBox.screenX - sv.browser.boxObject.screenX;
else else
canvasYOffset = tabContainerBox.screenY - sv.mTabBrowser.boxObject.screenY; canvasYOffset = tabContainerBox.screenY - sv.browser.boxObject.screenY;
for (let node = this.tabbarCanvas; for (let node = this.tabbarCanvas;
node != sv.mTabBrowser.mTabBox; node != sv.browser.mTabBox;
node = node.parentNode) node = node.parentNode)
{ {
let style = window.getComputedStyle(node, null); let style = window.getComputedStyle(node, null);
@ -725,7 +746,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
'-moz-field' '-moz-field'
); );
ctx.restore(); ctx.restore();
if (sv.mTabBrowser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_FULL]) { if (sv.browser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_FULL]) {
var alpha = Number(this.getTreePref('tabbar.transparent.partialTransparency')); var alpha = Number(this.getTreePref('tabbar.transparent.partialTransparency'));
if (isNaN(alpha)) alpha = 0.25; if (isNaN(alpha)) alpha = 0.25;
ctx.globalAlpha = alpha; ctx.globalAlpha = alpha;
@ -744,7 +765,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
'tabbar.fixed.horizontal' 'tabbar.fixed.horizontal'
) ? ) ?
sv.tabStrip : sv.tabStrip :
document.getAnonymousElementByAttribute(sv.mTabBrowser, 'class', sv.kSPLITTER) ; document.getAnonymousElementByAttribute(sv.browser, 'class', sv.kSPLITTER) ;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
var prop = pos == 'left' ? 'right' : var prop = pos == 'left' ? 'right' :
@ -791,7 +812,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
updateTransparency : function TSTAutoHide_updateTransparency() updateTransparency : function TSTAutoHide_updateTransparency()
{ {
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
var pos = sv.currentTabbarPosition; var pos = sv.currentTabbarPosition;
var style = this.kTRANSPARENT_STYLE[ var style = this.kTRANSPARENT_STYLE[
Math.max( Math.max(
@ -838,9 +859,16 @@ TreeStyleTabBrowserAutoHide.prototype = {
switch (aPrefName) switch (aPrefName)
{ {
case 'extensions.treestyletab.tabbar.autoHide.mode': case 'extensions.treestyletab.tabbar.autoHide.mode':
case 'extensions.treestyletab.tabbar.autoHide.mode.fullscreen': if (window != this.topBrowserWindow) return;
this.mOwner.browser.setAttribute(this.kMODE+'-normal', value);
this.updateMode(); this.updateMode();
break; return;
case 'extensions.treestyletab.tabbar.autoHide.mode.fullscreen':
if (window != this.topBrowserWindow) return;
this.mOwner.browser.setAttribute(this.kMODE+'-fullscreen', value);
this.updateMode();
return;
case 'extensions.treestyletab.tabbar.autoShow.mousemove': case 'extensions.treestyletab.tabbar.autoShow.mousemove':
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown': case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
@ -849,38 +877,38 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.startListenMouseMove(); this.startListenMouseMove();
else else
this.endListenMouseMove(); this.endListenMouseMove();
break; return;
case 'extensions.treestyletab.tabbar.autoHide.area': case 'extensions.treestyletab.tabbar.autoHide.area':
this.sensitiveArea = value; this.sensitiveArea = value;
break; return;
case 'extensions.treestyletab.tabbar.transparent.style': case 'extensions.treestyletab.tabbar.transparent.style':
this.updateTransparency(); this.updateTransparency();
break; return;
case 'extensions.treestyletab.tabbar.togglerSize': case 'extensions.treestyletab.tabbar.togglerSize':
this.togglerSize = value; this.togglerSize = value;
var toggler = document.getAnonymousElementByAttribute(this.mOwner.mTabBrowser, 'class', this.kTABBAR_TOGGLER); var toggler = document.getAnonymousElementByAttribute(this.mOwner.browser, 'class', this.kTABBAR_TOGGLER);
toggler.style.minWidth = toggler.style.minHeight = value+'px'; toggler.style.minWidth = toggler.style.minHeight = value+'px';
if (this.togglerSize <= 0) if (this.togglerSize <= 0)
toggler.setAttribute('collapsed', true); toggler.setAttribute('collapsed', true);
else else
toggler.removeAttribute('collapsed'); toggler.removeAttribute('collapsed');
break; return;
case 'browser.fullscreen.autohide': case 'browser.fullscreen.autohide':
if (!window.fullScreen) return; if (!window.fullScreen) return;
this.end(); this.end();
this.mode = value ? this.mode = value ?
this.getTreePref('tabbar.autoHide.mode.fullscreen') : this.getModeForFullscreen() :
this.kMODE_DISABLED ; this.kMODE_DISABLED ;
if (this.mode != this.kMODE_DISABLED) if (this.mode != this.kMODE_DISABLED)
this.start(); this.start();
break; return;
default: default:
break; return;
} }
}, },
@ -1095,7 +1123,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
if ( if (
!(node instanceof Components.interfaces.nsIDOMElement) || !(node instanceof Components.interfaces.nsIDOMElement) ||
( (
(tabbarBox = this.getBoxObjectFor(this.mOwner.mTabBrowser.mTabContainer)) && (tabbarBox = this.getBoxObjectFor(this.mOwner.browser.mTabContainer)) &&
(nodeBox = this.getBoxObjectFor(node)) && (nodeBox = this.getBoxObjectFor(node)) &&
tabbarBox.screenX <= nodeBox.screenX + nodeBox.width && tabbarBox.screenX <= nodeBox.screenX + nodeBox.width &&
tabbarBox.screenX + tabbarBox.width >= nodeBox.screenX && tabbarBox.screenX + tabbarBox.width >= nodeBox.screenX &&
@ -1109,7 +1137,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
onKeyDown : function TSTAutoHide_onKeyDown(aEvent) onKeyDown : function TSTAutoHide_onKeyDown(aEvent)
{ {
var sv = this.mOwner; var sv = this.mOwner;
var b = sv.mTabBrowser; var b = sv.browser;
if (this.delayedShowForShortcutDone) if (this.delayedShowForShortcutDone)
this.cancelDelayedShowForShortcut(); this.cancelDelayedShowForShortcut();
@ -1165,6 +1193,9 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.showHideOnMousemoveTimer = null; this.showHideOnMousemoveTimer = null;
this.delayedShowForFeedbackTimer = null; this.delayedShowForFeedbackTimer = null;
this.mOwner.browser.setAttribute(this.kMODE+'-normal', this.getTreePref('tabbar.autoHide.mode'));
this.mOwner.browser.setAttribute(this.kMODE+'-fullscreen', this.getTreePref('tabbar.autoHide.mode.fullscreen'));
this.addPrefListener(this); this.addPrefListener(this);
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area'); this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
this.onPrefChange('extensions.treestyletab.tabbar.transparent.style'); this.onPrefChange('extensions.treestyletab.tabbar.transparent.style');
@ -1173,7 +1204,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
aSelf.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode'); aSelf.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode');
}, 0, this); }, 0, this);
var b = this.mOwner.mTabBrowser; var b = this.mOwner.browser;
b.mTabContainer.addEventListener('TabOpen', this, false); b.mTabContainer.addEventListener('TabOpen', this, false);
b.mTabContainer.addEventListener('TabClose', this, false); b.mTabContainer.addEventListener('TabClose', this, false);
b.mTabContainer.addEventListener('TabMove', this, false); b.mTabContainer.addEventListener('TabMove', this, false);
@ -1206,7 +1237,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{ {
this.end(); this.end();
this.removePrefListener(this); this.removePrefListener(this);
var b = this.mOwner.mTabBrowser; var b = this.mOwner.browser;
b.mTabContainer.removeEventListener('TabOpen', this, false); b.mTabContainer.removeEventListener('TabOpen', this, false);
b.mTabContainer.removeEventListener('TabClose', this, false); b.mTabContainer.removeEventListener('TabClose', this, false);
b.mTabContainer.removeEventListener('TabMove', this, false); b.mTabContainer.removeEventListener('TabMove', this, false);
@ -1225,40 +1256,51 @@ TreeStyleTabBrowserAutoHide.prototype.__proto__ = TreeStyleTabService;
// mode // mode
TreeStyleTabBrowserAutoHide.getMode = function TSTAutoHide_class_getMode(aTabBrowser) {
var b = aTabBrowser || TreeStyleTabService.browser;
var mode = b.getAttribute(this.prototype.kMODE);
return mode ? parseInt(mode) : this.prototype.kMODE_DISABLED ;
};
TreeStyleTabBrowserAutoHide.__defineGetter__('mode', function() { /* PUBLIC API */ TreeStyleTabBrowserAutoHide.__defineGetter__('mode', function() { /* PUBLIC API */
if (this.mMode == this.prototype.kMODE_SHRINK && var mode = this.getMode();
if (mode == this.prototype.kMODE_SHRINK &&
TreeStyleTabService.currentTabbarPosition != 'left' && TreeStyleTabService.currentTabbarPosition != 'left' &&
TreeStyleTabService.currentTabbarPosition != 'right') TreeStyleTabService.currentTabbarPosition != 'right')
return this.prototype.kMODE_HIDE; return this.prototype.kMODE_HIDE;
return this.mMode; return mode;
}); });
TreeStyleTabBrowserAutoHide.__defineSetter__('mode', function(aValue) { TreeStyleTabBrowserAutoHide.__defineSetter__('mode', function(aValue) {
this.mMode = aValue; var b = aTabBrowser || TreeStyleTabService.browser;
b.setAttribute(this.prototype.kMODE, aValue);
return aValue; return aValue;
}); });
TreeStyleTabBrowserAutoHide.mMode = TreeStyleTabBrowserAutoHide.prototype.kMODE_HIDE;
TreeStyleTabBrowserAutoHide.toggleMode = function TSTAutoHide_toggleMode() { /* PUBLIC API */ TreeStyleTabBrowserAutoHide.toggleMode = function TSTAutoHide_class_toggleMode(aTabBrowser) { /* PUBLIC API */
var b = aTabBrowser || TreeStyleTabService.browser;
var key = 'tabbar.autoHide.mode'; var key = 'tabbar.autoHide.mode';
var toggleKey = 'tabbar.autoHide.mode.toggle'; var toggleKey = 'tabbar.autoHide.mode.toggle';
if (window.fullScreen) { if (window.fullScreen) {
key += '.fullscreen'; key += '.fullscreen';
toggleKey += '.fullscreen'; toggleKey += '.fullscreen';
} }
TreeStyleTabService.setTreePref(key,
TreeStyleTabService.getTreePref(key) == this.prototype.kMODE_DISABLED ? var mode = this.getMode(b) == this.prototype.kMODE_DISABLED ?
TreeStyleTabService.getTreePref(toggleKey) : TreeStyleTabService.getTreePref(toggleKey) :
this.prototype.kMODE_DISABLED this.prototype.kMODE_DISABLED ;
);
TreeStyleTabService.setTreePref(key, mode);
b.setAttribute(this.prototype.kMODE+'-'+(window.fullScreen ? 'fullscreen' : 'normal' ), mode);
b.treeStyleTab.autoHide.updateMode();
}; };
// for shortcuts // for shortcuts
TreeStyleTabBrowserAutoHide.updateKeyListeners = function TSTAutoHide_updateKeyListeners() { TreeStyleTabBrowserAutoHide.updateKeyListeners = function TSTAutoHide_class_updateKeyListeners() {
if ( if (
TreeStyleTabService.getTreePref('tabbar.autoHide.mode') && this.getMode() &&
this.shouldListenKeyEvents this.shouldListenKeyEvents
) { ) {
TreeStyleTabService.startListenKeyEventsFor(TreeStyleTabService.LISTEN_FOR_AUTOHIDE); TreeStyleTabService.startListenKeyEventsFor(TreeStyleTabService.LISTEN_FOR_AUTOHIDE);