2010-12-06 08:31:58 -05:00
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
|
*
|
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
|
*
|
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
|
* License.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is the Tree Style Tab.
|
|
|
|
|
*
|
|
|
|
|
* The Initial Developer of the Original Code is SHIMODA Hiroshi.
|
2011-01-10 02:02:15 -05:00
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010-2011
|
2010-12-06 08:31:58 -05:00
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): SHIMODA Hiroshi <piro@p.club.ne.jp>
|
|
|
|
|
*
|
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
|
*
|
|
|
|
|
* ***** END LICENSE BLOCK ******/
|
|
|
|
|
|
|
|
|
|
const EXPORTED_SYMBOLS = ['AutoHideBrowser', 'AutoHideWindow'];
|
|
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
|
|
|
|
|
function AutoHideBrowser(aTabBrowser)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.init(aTabBrowser);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2010-12-06 08:31:58 -05:00
|
|
|
|
AutoHideBrowser.prototype = {
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-05-08 03:15:38 -04:00
|
|
|
|
kMODE : 'treestyletab-tabbar-autohide-mode',
|
|
|
|
|
kMODE_DISABLED : 0,
|
2009-09-03 02:24:06 -04:00
|
|
|
|
kMODE_HIDE : 1,
|
|
|
|
|
kMODE_SHRINK : 2,
|
|
|
|
|
|
2009-09-03 22:11:51 -04:00
|
|
|
|
kAUTOHIDE : 'treestyletab-tabbar-autohide',
|
|
|
|
|
|
2009-12-17 21:56:45 -05:00
|
|
|
|
kSTATE : 'treestyletab-tabbar-autohide-state',
|
|
|
|
|
kSTATE_HIDDEN : 'hidden',
|
|
|
|
|
kSTATE_EXPANDED : 'expanded',
|
|
|
|
|
kSTATE_SHRUNKEN : 'shrunken',
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
kSHOWN_BY_UNKNOWN : 0,
|
|
|
|
|
kSHOWN_BY_SHORTCUT : 1 << 0,
|
|
|
|
|
kSHOWN_BY_MOUSEMOVE : 1 << 1,
|
|
|
|
|
kSHOWN_BY_FEEDBACK : 1 << 2,
|
|
|
|
|
kKEEP_SHOWN_ON_MOUSEOVER : (1 << 0) | (1 << 1) | (1 << 2),
|
2009-09-03 04:52:07 -04:00
|
|
|
|
|
|
|
|
|
kTRANSPARENT : 'treestyletab-tabbar-transparent',
|
|
|
|
|
kTRANSPARENT_NONE : 0,
|
|
|
|
|
kTRANSPARENT_PART : 1,
|
|
|
|
|
kTRANSPARENT_FULL : 2,
|
|
|
|
|
kTRANSPARENT_STYLE : ['none', 'part', 'full'],
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-02-03 11:31:50 -05:00
|
|
|
|
get mode() /* PUBLIC API */
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var mode = this.browser.getAttribute(this.kMODE);
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return mode ? parseInt(mode) : this.kMODE_DISABLED ;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
set mode(aValue)
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.browser.setAttribute(this.kMODE, aValue);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return aValue;
|
|
|
|
|
},
|
2009-12-17 22:20:35 -05:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
getMode : function AHB_getMode(aTabBrowser)
|
2010-05-08 03:15:38 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var b = aTabBrowser || this.browser;
|
2010-05-08 03:15:38 -04:00
|
|
|
|
var mode = b.getAttribute(this.kMODE);
|
|
|
|
|
return mode ? parseInt(mode) : this.kMODE_DISABLED ;
|
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
getModeForNormal : function AHB_getModeForNormal(aTabBrowser)
|
2010-05-08 03:15:38 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
return parseInt(b.getAttribute(this.kMODE+'-normal') || this.treeStyleTab.getTreePref('tabbar.autoHide.mode'));
|
2010-05-08 03:15:38 -04:00
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
getModeForFullScreen : function AHB_getModeForFullScreen(aTabBrowser)
|
2010-05-08 03:15:38 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
return parseInt(b.getAttribute(this.kMODE+'-fullscreen') || this.treeStyleTab.getTreePref('tabbar.autoHide.mode.fullscreen'));
|
2010-05-08 03:15:38 -04:00
|
|
|
|
},
|
|
|
|
|
|
2009-12-17 22:20:35 -05:00
|
|
|
|
get state()
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
return this.browser.getAttribute(this.kSTATE) || this.kSTATE_EXPANDED;
|
2009-12-17 22:20:35 -05:00
|
|
|
|
},
|
|
|
|
|
get expanded()
|
|
|
|
|
{
|
|
|
|
|
return this.state == this.kSTATE_EXPANDED;
|
|
|
|
|
},
|
|
|
|
|
get shrunken()
|
|
|
|
|
{
|
|
|
|
|
return this.state == this.kSTATE_SHRUNKEN;
|
|
|
|
|
},
|
|
|
|
|
get hidden()
|
|
|
|
|
{
|
|
|
|
|
return this.state == this.kSTATE_HIDDEN;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
updateMode : function AHB_updateMode()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
this.end();
|
|
|
|
|
// update internal property after the appearance of the tab bar is updated.
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var w = this.window;
|
|
|
|
|
w.setTimeout(function(aSelf) {
|
|
|
|
|
aSelf.mode = (w.fullScreen && aSelf.treeStyleTab.getPref('browser.fullscreen.autohide')) ?
|
2010-05-08 04:30:39 -04:00
|
|
|
|
aSelf.getModeForFullScreen() :
|
2010-05-08 03:15:38 -04:00
|
|
|
|
aSelf.getModeForNormal() ;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (aSelf.mode != aSelf.kMODE_DISABLED)
|
|
|
|
|
aSelf.start();
|
|
|
|
|
}, 0, this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
togglerSize : 0,
|
|
|
|
|
sensitiveArea : 7,
|
|
|
|
|
|
|
|
|
|
get XOffset()
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
switch (this.mode)
|
|
|
|
|
{
|
2010-03-31 05:34:51 -04:00
|
|
|
|
case this.kMODE_DISABLED:
|
|
|
|
|
return 0;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
case this.kMODE_HIDE:
|
2009-09-03 04:18:41 -04:00
|
|
|
|
let offset = this.width + this.splitterWidth;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
if (sv.currentTabbarPosition == 'left') {
|
2009-09-03 02:24:06 -04:00
|
|
|
|
offset -= this.togglerSize;
|
|
|
|
|
}
|
|
|
|
|
return offset;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case this.kMODE_SHRINK:
|
2010-12-06 08:31:58 -05:00
|
|
|
|
return sv.getTreePref('tabbar.width')
|
|
|
|
|
- sv.getTreePref('tabbar.shrunkenWidth');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
get YOffset()
|
|
|
|
|
{
|
2009-09-03 04:18:41 -04:00
|
|
|
|
return this.height;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2010-03-31 04:35:29 -04:00
|
|
|
|
extraXOffset : 0,
|
|
|
|
|
extraYOffset : 0,
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
get currentXOffset()
|
2010-03-31 04:35:29 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
return (
|
2010-05-08 01:37:41 -04:00
|
|
|
|
sv.currentTabbarPosition == 'left' &&
|
2010-03-31 04:35:29 -04:00
|
|
|
|
this.mode != this.kMODE_DISABLED &&
|
|
|
|
|
this.expanded
|
|
|
|
|
) ? this.XOffset : 0 ;
|
|
|
|
|
},
|
|
|
|
|
get currentYOffset()
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
return (
|
2010-05-08 01:37:41 -04:00
|
|
|
|
sv.currentTabbarPosition == 'top' &&
|
2010-03-31 04:35:29 -04:00
|
|
|
|
this.mode != this.kMODE_DISABLED &&
|
|
|
|
|
this.expanded
|
|
|
|
|
) ? this.YOffset : 0 ;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
start : function AHB_start()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (this.enabled) return;
|
|
|
|
|
this.enabled = true;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var w = this.window;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
b.addEventListener('mousedown', this, true);
|
|
|
|
|
b.addEventListener('mouseup', this, true);
|
2010-03-25 23:17:16 -04:00
|
|
|
|
if (sv.isFloating) {
|
2010-03-24 14:55:34 -04:00
|
|
|
|
sv.tabStrip.addEventListener('mousedown', this, true);
|
|
|
|
|
sv.tabStrip.addEventListener('mouseup', this, true);
|
|
|
|
|
}
|
2010-12-06 08:31:58 -05:00
|
|
|
|
w.addEventListener('resize', this, true);
|
|
|
|
|
w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
|
|
|
|
|
w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
|
|
|
|
|
b.addEventListener('load', this, true);
|
|
|
|
|
b.mPanelContainer.addEventListener('scroll', this, true);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (this.shouldListenMouseMove)
|
|
|
|
|
this.startListenMouseMove();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (b == w.gBrowser && sv.shouldListenKeyEventsForAutoHide)
|
|
|
|
|
w.TreeStyleTabService.startListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.clearBG();
|
|
|
|
|
this.updateTransparency();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideInternal();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
end : function AHB_end()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (!this.enabled) return;
|
|
|
|
|
this.enabled = false;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var w = this.window;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (!this.expanded)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideInternal();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
b.removeEventListener('mousedown', this, true);
|
|
|
|
|
b.removeEventListener('mouseup', this, true);
|
2010-03-25 23:17:16 -04:00
|
|
|
|
if (sv.isFloating) {
|
2010-03-24 14:55:34 -04:00
|
|
|
|
sv.tabStrip.removeEventListener('mousedown', this, true);
|
|
|
|
|
sv.tabStrip.removeEventListener('mouseup', this, true);
|
|
|
|
|
}
|
2010-12-06 08:31:58 -05:00
|
|
|
|
w.removeEventListener('resize', this, true);
|
|
|
|
|
w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
|
|
|
|
|
w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
|
|
|
|
|
b.removeEventListener('load', this, true);
|
|
|
|
|
b.mPanelContainer.removeEventListener('scroll', this, true);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.endListenMouseMove();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (b == w.gBrowser)
|
|
|
|
|
w.TreeStyleTabService.endListenKeyEventsFor(sv.LISTEN_FOR_AUTOHIDE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.clearBG();
|
|
|
|
|
this.updateTransparency();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-09-10 06:21:26 -04:00
|
|
|
|
if (!sv.isFloating)
|
|
|
|
|
sv.container.style.margin = 0;
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.removeTabbrowserAttribute(this.kAUTOHIDE);
|
|
|
|
|
sv.removeTabbrowserAttribute(this.kSTATE);
|
|
|
|
|
sv.removeTabbrowserAttribute(this.kTRANSPARENT);
|
2010-09-10 06:21:26 -04:00
|
|
|
|
|
|
|
|
|
sv.setTabStripAttribute('width', this.widthFromMode);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// fullscreen
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
startForFullScreen : function AHB_startForFullScreen()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-05-08 03:15:38 -04:00
|
|
|
|
this.mode = this.getMode();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.end();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.mode = this.treeStyleTab.getPref('browser.fullscreen.autohide') ?
|
2010-05-08 04:30:39 -04:00
|
|
|
|
this.getModeForFullScreen() :
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.kMODE_DISABLED ;
|
|
|
|
|
if (this.mode != this.kMODE_DISABLED) {
|
|
|
|
|
this.start();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.removeTabbrowserAttribute('moz-collapsed');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
endForFullScreen : function AHB_endForFullScreen()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-05-08 04:30:39 -04:00
|
|
|
|
this.mode = this.getModeForFullScreen();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.end();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.mode = this.treeStyleTab.getTreePref('tabbar.autoHide.mode');
|
|
|
|
|
this.treeStyleTab.checkTabsIndentOverflow();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (this.mode != this.kMODE_DISABLED)
|
|
|
|
|
this.start();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// mousemove
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
startListenMouseMove : function AHB_startListenMouseMove()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (this.mouseMoveListening) return;
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.browser.addEventListener('mousemove', this, true);
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (this.treeStyleTab.isFloating)
|
|
|
|
|
this.treeStyleTab.tabStrip.addEventListener('mousemove', this, true);
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.mouseMoveListening = true;
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
endListenMouseMove : function AHB_endListenMouseMove()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (!this.mouseMoveListening) return;
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.browser.removeEventListener('mousemove', this, true);
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (this.treeStyleTab.isFloating)
|
|
|
|
|
this.treeStyleTab.tabStrip.removeEventListener('mousemove', this, true);
|
2010-09-13 22:00:48 -04:00
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.mouseMoveListening = false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get shouldListenMouseMove()
|
|
|
|
|
{
|
2011-01-10 00:01:09 -05:00
|
|
|
|
return this.treeStyleTab.getTreePref('tabbar.autoShow.mousemove');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2011-01-09 11:43:23 -05:00
|
|
|
|
get shouldListenKeyEventsForAutoHide()
|
|
|
|
|
{
|
|
|
|
|
return this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch');
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
showHideOnMousemove : function AHB_showHideOnMousemove(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var w = this.window;
|
|
|
|
|
if ('gestureInProgress' in w && w.gestureInProgress)
|
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.cancelShowHideOnMousemove();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var box = b.mCurrentBrowser.boxObject;
|
|
|
|
|
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (sv.isFloating && this.expanded) { // Firefox 4.0-
|
2010-09-09 22:39:39 -04:00
|
|
|
|
box = {
|
2010-09-09 22:45:40 -04:00
|
|
|
|
screenX : box.screenX + (pos == 'left' ? this.XOffset : 0 ),
|
2010-09-09 22:39:39 -04:00
|
|
|
|
screenY : box.screenY,
|
|
|
|
|
width : box.width - this.XOffset,
|
|
|
|
|
height : box.height
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var sensitiveArea = this.sensitiveArea;
|
|
|
|
|
/* For resizing of shrunken tab bar and clicking closeboxes,
|
|
|
|
|
we have to shrink sensitive area a little. */
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.shrunken) {
|
2009-09-03 02:24:06 -04:00
|
|
|
|
sensitiveArea = 0;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (pos != 'right' || b.getAttribute(sv.kTAB_INVERTED) == 'true')
|
2009-09-03 02:24:06 -04:00
|
|
|
|
sensitiveArea -= 20;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var shouldKeepShown = (
|
|
|
|
|
pos == 'left' ?
|
|
|
|
|
(aEvent.screenX <= box.screenX + sensitiveArea) :
|
|
|
|
|
pos == 'right' ?
|
|
|
|
|
(aEvent.screenX >= box.screenX + box.width - sensitiveArea) :
|
|
|
|
|
pos == 'bottom' ?
|
|
|
|
|
(aEvent.screenY >= box.screenY + box.height - sensitiveArea) :
|
|
|
|
|
(aEvent.screenY <= box.screenY + sensitiveArea)
|
|
|
|
|
);
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded) {
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (
|
|
|
|
|
shouldKeepShown &&
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoShow.keepShownOnMouseover')
|
2009-09-03 02:24:06 -04:00
|
|
|
|
) {
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideReason = this.kSHOWN_BY_MOUSEMOVE;
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this.cancelDelayedShowForShortcut();
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.cancelHideForFeedback();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
else if (
|
|
|
|
|
!shouldKeepShown &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoShow.mousemove')
|
2009-09-03 02:24:06 -04:00
|
|
|
|
) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.showHideOnMousemoveTimer = w.setTimeout(
|
2009-09-03 02:24:06 -04:00
|
|
|
|
function(aSelf) {
|
2009-09-03 03:25:37 -04:00
|
|
|
|
aSelf.cancelDelayedShowForShortcut();
|
2009-09-03 04:18:41 -04:00
|
|
|
|
if (aSelf.showHideReason == aSelf.kSHOWN_BY_MOUSEMOVE)
|
|
|
|
|
aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoHide.delay'),
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (
|
|
|
|
|
pos == 'left' ?
|
|
|
|
|
(aEvent.screenX <= box.screenX + sensitiveArea) :
|
|
|
|
|
pos == 'right' ?
|
|
|
|
|
(aEvent.screenX >= box.screenX + box.width - sensitiveArea) :
|
|
|
|
|
pos == 'bottom' ?
|
|
|
|
|
(aEvent.screenY >= box.screenY + box.height - sensitiveArea) :
|
|
|
|
|
(aEvent.screenY <= box.screenY + sensitiveArea)
|
|
|
|
|
) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.showHideOnMousemoveTimer = w.setTimeout(
|
2009-09-03 02:24:06 -04:00
|
|
|
|
function(aSelf) {
|
2009-09-03 03:25:37 -04:00
|
|
|
|
aSelf.cancelDelayedShowForShortcut();
|
2009-09-03 04:18:41 -04:00
|
|
|
|
aSelf.cancelHideForFeedback();
|
|
|
|
|
aSelf.show(aSelf.kSHOWN_BY_MOUSEMOVE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoHide.delay'),
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
b = null;
|
|
|
|
|
pos = null
|
|
|
|
|
box = null;
|
|
|
|
|
sensitiveArea = null;
|
|
|
|
|
shouldKeepShown = null;
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
cancelShowHideOnMousemove : function AHB_cancelShowHideOnMousemove()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-09-03 04:18:41 -04:00
|
|
|
|
if (this.showHideOnMousemoveTimer) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.clearTimeout(this.showHideOnMousemoveTimer);
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideOnMousemoveTimer = null;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// feedback
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
showForFeedback : function AHB_showForFeedback()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (!this.enabled ||
|
2010-12-06 08:31:58 -05:00
|
|
|
|
!this.treeStyleTab.getTreePref('tabbar.autoShow.feedback'))
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var w = this.window;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
if (this.delayedShowForFeedbackTimer) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
w.clearTimeout(this.delayedShowForFeedbackTimer);
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.delayedShowForFeedbackTimer = null;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.cancelHideForFeedback();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.delayedShowForFeedbackTimer = w.setTimeout(
|
2009-09-03 02:24:06 -04:00
|
|
|
|
function(aSelf) {
|
2009-09-03 04:18:41 -04:00
|
|
|
|
aSelf.delayedShowForFeedbackTimer = null;
|
|
|
|
|
aSelf.delayedShowForFeedback();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
100,
|
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
delayedShowForFeedback : function AHB_delayedShowForFeedback()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.show(this.kSHOWN_BY_FEEDBACK);
|
|
|
|
|
this.cancelHideForFeedback();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.delayedHideTabbarForFeedbackTimer = this.window.setTimeout(
|
2009-09-03 02:24:06 -04:00
|
|
|
|
function(aSelf) {
|
|
|
|
|
aSelf.delayedHideTabbarForFeedbackTimer = null;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
if (aSelf.showHideReason == aSelf.kSHOWN_BY_FEEDBACK)
|
|
|
|
|
aSelf.hide();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback.delay'),
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
cancelHideForFeedback : function AHB_cancelHideForFeedback()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (this.delayedHideTabbarForFeedbackTimer) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.clearTimeout(this.delayedHideTabbarForFeedbackTimer);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.delayedHideTabbarForFeedbackTimer = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
setWidth : function AHB_setWidth(aWidth, aForceExpanded)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (aForceExpanded ||
|
2009-12-17 22:20:35 -05:00
|
|
|
|
this.expanded ||
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.mode != this.kMODE_SHRINK)
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth));
|
2009-09-03 02:24:06 -04:00
|
|
|
|
else
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.setTreePref('tabbar.shrunkenWidth', this.treeStyleTab.maxTabbarWidth(aWidth));
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
updateMenuItem : function AHB_updateMenuItem(aNode)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-09-15 00:51:50 -04:00
|
|
|
|
if (!aNode) return;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (this.mode != this.kMODE_DISABLED)
|
|
|
|
|
aNode.setAttribute('checked', true);
|
|
|
|
|
else
|
|
|
|
|
aNode.removeAttribute('checked');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// show/hide tabbar
|
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
get width()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this._width = this.treeStyleTab.tabStrip.boxObject.width || this._width;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2009-09-03 04:18:41 -04:00
|
|
|
|
return this._width;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2009-09-03 04:18:41 -04:00
|
|
|
|
set width(aNewWidth)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this._width = aNewWidth;
|
|
|
|
|
return this._width;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2009-09-03 04:18:41 -04:00
|
|
|
|
_width : 0,
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
get widthFromMode()
|
2009-09-03 03:25:37 -04:00
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
return (this.shrunken) ?
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') :
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.width') ;
|
2009-09-03 03:25:37 -04:00
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
get placeHolderWidthFromMode()
|
2010-09-12 23:54:04 -04:00
|
|
|
|
{
|
|
|
|
|
return (this.mode == this.kMODE_SHRINK) ?
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.shrunkenWidth') :
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.width') ;
|
2010-09-12 23:54:04 -04:00
|
|
|
|
},
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
get height()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this._height = this.treeStyleTab.tabStrip.boxObject.height;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2009-09-03 04:18:41 -04:00
|
|
|
|
return this._height;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2009-09-03 04:18:41 -04:00
|
|
|
|
set height(aNewHeight)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this._height = aNewHeight;
|
|
|
|
|
return this._height;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
2009-09-03 04:18:41 -04:00
|
|
|
|
_height : 0,
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
get splitterWidth()
|
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var splitter = this.document.getAnonymousElementByAttribute(this.browser, 'class', this.treeStyleTab.kSPLITTER);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this._splitterWidth = (splitter ? splitter.boxObject.width : 0 );
|
|
|
|
|
}
|
|
|
|
|
return this._splitterWidth;
|
|
|
|
|
},
|
|
|
|
|
set splitterWidth(aNewWidth)
|
|
|
|
|
{
|
|
|
|
|
this._splitterWidth = aNewWidth;
|
|
|
|
|
return this._splitterWidth;
|
|
|
|
|
},
|
|
|
|
|
_splitterWidth : 0,
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
showHideInternal : function AHB_showHideInternal(aReason)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (!sv.isFloating)
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.stopRendering();
|
2009-12-17 04:37:25 -05:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var b = this.browser;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded) { // to be hidden or shrunken
|
2009-12-17 04:37:25 -05:00
|
|
|
|
this.onHiding();
|
|
|
|
|
this.showHideReason = aReason || this.kSHOWN_BY_UNKNOWN;
|
2010-07-01 22:47:12 -04:00
|
|
|
|
this.resetContentAreas();
|
2009-12-17 04:37:25 -05:00
|
|
|
|
}
|
|
|
|
|
else { // to be shown or expanded
|
|
|
|
|
this.onShowing();
|
|
|
|
|
this.showHideReason = aReason || this.kSHOWN_BY_UNKNOWN;
|
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-12-17 04:37:25 -05:00
|
|
|
|
this.fireStateChangingEvent();
|
|
|
|
|
|
2010-03-31 14:24:23 -04:00
|
|
|
|
if (this.expanded) {
|
|
|
|
|
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show');
|
|
|
|
|
this.redrawContentArea();
|
|
|
|
|
}
|
|
|
|
|
b.mTabContainer.adjustTabstrip();
|
|
|
|
|
sv.checkTabsIndentOverflow();
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2009-12-17 04:37:25 -05:00
|
|
|
|
aSelf.redrawContentArea();
|
|
|
|
|
aSelf.fireStateChangeEvent();
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (!sv.isFloating)
|
2010-12-06 09:34:32 -05:00
|
|
|
|
sv.startRendering();
|
2009-12-17 04:37:25 -05:00
|
|
|
|
}, 0, this);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
show : function AHB_show(aReason) /* PUBLIC API */
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (!this.expanded)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideInternal(aReason);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
hide : function AHB_hide(aReason) /* PUBLIC API */
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.expanded)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideInternal(aReason);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onShowing : function AHB_onShowing()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (!sv.isFloating) { // -Firefox 3.6
|
2010-09-09 22:39:39 -04:00
|
|
|
|
switch (pos)
|
|
|
|
|
{
|
|
|
|
|
case 'left':
|
|
|
|
|
sv.container.style.marginRight = '-'+this.XOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
case 'right':
|
|
|
|
|
sv.container.style.marginLeft = '-'+this.XOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
case 'bottom':
|
|
|
|
|
sv.container.style.marginTop = '-'+this.YOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sv.container.style.marginBottom = '-'+this.YOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_EXPANDED);
|
2009-12-17 21:56:45 -05:00
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
switch (this.mode)
|
|
|
|
|
{
|
2010-03-31 05:34:51 -04:00
|
|
|
|
case this.kMODE_DISABLED:
|
2010-09-10 06:21:26 -04:00
|
|
|
|
break;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
case this.kMODE_HIDE:
|
2010-09-10 06:21:26 -04:00
|
|
|
|
if (sv.isFloating)
|
2010-12-03 09:50:42 -05:00
|
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case this.kMODE_SHRINK:
|
2010-09-09 22:39:39 -04:00
|
|
|
|
if (pos == 'left' || pos == 'right') {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
let width = sv.maxTabbarWidth(sv.getTreePref('tabbar.width'));
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (sv.isFloating) // Firefox 4.0-
|
2010-12-03 09:50:42 -05:00
|
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
|
2010-09-09 23:27:19 -04:00
|
|
|
|
else // -Firefox 3.6
|
|
|
|
|
sv.setTabStripAttribute('width', width);
|
2010-09-09 22:39:39 -04:00
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onHiding : function AHB_onHiding()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-03-25 23:17:16 -04:00
|
|
|
|
var box = (sv.tabStripPlaceHolder || sv.tabStrip).boxObject;
|
2010-03-24 14:55:34 -04:00
|
|
|
|
|
|
|
|
|
this.tabbarHeight = box.height;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
this.width = box.width || this.width;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var splitter = this.document.getAnonymousElementByAttribute(b, 'class', sv.kSPLITTER);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.splitterWidth = (splitter ? splitter.boxObject.width : 0 );
|
2010-09-09 22:39:39 -04:00
|
|
|
|
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (!sv.isFloating) // -Firefox 3.6
|
2010-09-09 22:39:39 -04:00
|
|
|
|
sv.container.style.margin = 0;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
switch (this.mode)
|
|
|
|
|
{
|
2010-03-31 05:34:51 -04:00
|
|
|
|
case this.kMODE_DISABLED:
|
2010-09-10 06:21:26 -04:00
|
|
|
|
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'hidden');
|
|
|
|
|
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_HIDDEN);
|
|
|
|
|
break;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
case this.kMODE_HIDE:
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'hidden');
|
|
|
|
|
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_HIDDEN);
|
2010-12-03 09:50:42 -05:00
|
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
case this.kMODE_SHRINK:
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show');
|
|
|
|
|
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_SHRUNKEN);
|
2010-09-10 06:21:26 -04:00
|
|
|
|
if (pos == 'left' || pos == 'right')
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.setTabStripAttribute('width', sv.getTreePref('tabbar.shrunkenWidth'));
|
2010-12-03 09:50:42 -05:00
|
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
fireStateChangingEvent : function AHB_fireStateChangingEvent()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2011-01-11 05:29:14 -05:00
|
|
|
|
var data = {
|
|
|
|
|
shown : this.expanded,
|
|
|
|
|
state : this.state
|
|
|
|
|
};
|
2010-12-20 06:54:42 -05:00
|
|
|
|
|
2011-01-11 05:29:14 -05:00
|
|
|
|
/* PUBLIC API */
|
|
|
|
|
this.treeStyleTab.fireDataContainerEvent(this.treeStyleTab.kEVENT_TYPE_AUTO_HIDE_STATE_CHANGING, this.browser, true, false, data);
|
2010-12-20 06:54:42 -05:00
|
|
|
|
// for backward compatibility
|
2011-01-11 05:29:14 -05:00
|
|
|
|
this.treeStyleTab.fireDataContainerEvent(this.treeStyleTab.kEVENT_TYPE_AUTO_HIDE_STATE_CHANGING.replace(/^nsDOM/, ''), this.browser, true, false, data);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
fireStateChangeEvent : function AHB_fireStateChangeEvent()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2011-01-11 05:29:14 -05:00
|
|
|
|
var data = {
|
|
|
|
|
shown : this.expanded,
|
|
|
|
|
state : this.state,
|
|
|
|
|
xOffset : this.XOffset,
|
|
|
|
|
yOffset : this.YOffset
|
|
|
|
|
};
|
2010-12-20 06:54:42 -05:00
|
|
|
|
|
2011-01-11 05:29:14 -05:00
|
|
|
|
/* PUBLIC API */
|
|
|
|
|
this.treeStyleTab.fireDataContainerEvent(this.treeStyleTab.kEVENT_TYPE_AUTO_HIDE_STATE_CHANGE, this.browser, true, false, data);
|
2010-12-20 06:54:42 -05:00
|
|
|
|
// for backward compatibility
|
2011-01-11 05:29:14 -05:00
|
|
|
|
this.treeStyleTab.fireDataContainerEvent(this.treeStyleTab.kEVENT_TYPE_AUTO_HIDE_STATE_CHANGE.replace(/^nsDOM/, ''), this.browser, true, false, data);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
redrawContentArea : function AHB_redrawContentArea()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2010-09-09 23:27:19 -04:00
|
|
|
|
if (sv.isFloating)
|
2010-09-09 22:17:00 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var w = this.window;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
try {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var v = this.browser.markupDocumentViewer;
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.shouldRedraw) {
|
2010-05-08 03:15:38 -04:00
|
|
|
|
if (sv.browser.hasAttribute(this.kTRANSPARENT) &&
|
|
|
|
|
sv.browser.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE])
|
2009-12-24 10:01:23 -05:00
|
|
|
|
this.drawBG();
|
|
|
|
|
else
|
|
|
|
|
this.clearBG();
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
v.move(w.outerWidth, w.outerHeight);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
v.move(
|
|
|
|
|
(
|
|
|
|
|
pos == 'left' ? -this.XOffset :
|
|
|
|
|
pos == 'right' ? this.XOffset :
|
|
|
|
|
0
|
2010-03-31 04:35:29 -04:00
|
|
|
|
) - this.extraXOffset,
|
2009-09-03 02:24:06 -04:00
|
|
|
|
(
|
|
|
|
|
pos == 'top' ? -this.YOffset :
|
|
|
|
|
pos == 'bottom' ? this.YOffset :
|
|
|
|
|
0
|
2010-03-31 04:35:29 -04:00
|
|
|
|
) - this.extraYOffset
|
2009-09-03 02:24:06 -04:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2009-12-24 10:01:23 -05:00
|
|
|
|
this.clearBG();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
v.move(w.outerWidth, w.outerHeight);
|
2010-03-31 04:35:29 -04:00
|
|
|
|
v.move(-this.extraXOffset, -this.extraYOffset);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
2010-03-24 15:23:21 -04:00
|
|
|
|
dump(e);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
redrawContentAreaWithDelay : function AHB_redrawContentAreaWithDelay()
|
2010-03-31 04:35:29 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (this.treeStyleTab.isFloating)
|
2010-09-09 22:17:00 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2010-03-31 04:35:29 -04:00
|
|
|
|
aSelf.redrawContentArea();
|
|
|
|
|
}, 0, this);
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
resetContentAreas : function AHB_resetContentAreas()
|
2010-07-01 22:47:12 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (this.treeStyleTab.isFloating)
|
2010-09-09 22:17:00 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.getTabsArray(this.browser).forEach(function(aTab) {
|
2010-07-01 22:47:12 -04:00
|
|
|
|
try {
|
|
|
|
|
aTab.linkedBrowser.markupDocumentViewer.move(0, 0);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
}
|
|
|
|
|
}, this);
|
|
|
|
|
},
|
|
|
|
|
|
2009-12-17 04:37:25 -05:00
|
|
|
|
get shouldRedraw()
|
2009-09-08 21:55:48 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
return !this.treeStyleTab.isFloating && this.enabled && this.expanded;
|
2009-09-08 21:55:48 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
drawBG : function AHB_drawBG()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var canvas = this.tabbarCanvas;
|
|
|
|
|
if (sv.isFloating || !canvas || this.isResizing)
|
2010-09-09 23:27:19 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
|
|
|
|
|
canvas.style.width = (canvas.width = 1)+'px';
|
|
|
|
|
canvas.style.height = (canvas.height = 1)+'px';
|
2009-12-24 10:01:23 -05:00
|
|
|
|
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var frame = b.contentWindow;
|
|
|
|
|
var tabContainerBox = b.mTabContainer.boxObject;
|
|
|
|
|
var browserBox = b.mCurrentBrowser.boxObject;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var contentBox = sv.getBoxObjectFor(frame.document.documentElement);
|
|
|
|
|
|
2009-12-17 04:37:25 -05:00
|
|
|
|
var zoom = this.getZoomForFrame(frame);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
var x = (pos == 'right') ? browserBox.width - this.XOffset : 0 ;
|
|
|
|
|
var y = (pos == 'bottom') ? browserBox.height - this.YOffset : 0 ;
|
|
|
|
|
if (pos == 'left' && this.mode == this.kMODE_HIDE)
|
|
|
|
|
x -= this.togglerSize;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
x += this.extraXOffset;
|
|
|
|
|
y += this.extraYOffset;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var xOffset = (zoom == 1 && (pos == 'top' || pos == 'bottom')) ?
|
2010-03-31 04:35:29 -04:00
|
|
|
|
Math.max(0, contentBox.screenX + frame.scrollX - browserBox.screenX) :
|
2009-09-03 02:24:06 -04:00
|
|
|
|
0 ;
|
|
|
|
|
var yOffset = (zoom == 1 && (pos == 'left' || pos == 'right')) ?
|
2010-03-31 04:35:29 -04:00
|
|
|
|
Math.max(0, contentBox.screenY + frame.scrollY - browserBox.screenY) :
|
2009-09-03 02:24:06 -04:00
|
|
|
|
0 ;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var w = tabContainerBox.width - xOffset;
|
|
|
|
|
var h = tabContainerBox.height - yOffset;
|
2010-03-31 04:35:29 -04:00
|
|
|
|
w -= this.extraXOffset;
|
|
|
|
|
h -= this.extraYOffset;
|
2009-12-17 00:55:45 -05:00
|
|
|
|
|
|
|
|
|
var canvasXOffset = 0;
|
|
|
|
|
var canvasYOffset = 0;
|
2009-12-16 21:29:20 -05:00
|
|
|
|
if (pos == 'top' || pos == 'bottom')
|
2010-12-06 08:31:58 -05:00
|
|
|
|
canvasXOffset = tabContainerBox.screenX - b.boxObject.screenX;
|
2009-12-16 21:29:20 -05:00
|
|
|
|
else
|
2010-12-06 08:31:58 -05:00
|
|
|
|
canvasYOffset = tabContainerBox.screenY - b.boxObject.screenY;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
for (let node = canvas;
|
|
|
|
|
node != b.mTabBox;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
node = node.parentNode)
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
let style = this.window.getComputedStyle(node, null);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
'border-left-width,border-right-width,margin-left,margin-right,padding-left,padding-right'
|
|
|
|
|
.split(',').forEach(function(aProperty) {
|
|
|
|
|
let value = sv.getPropertyPixelValue(style, aProperty);
|
|
|
|
|
w -= value;
|
|
|
|
|
if (aProperty.indexOf('left') < -1) x += value;
|
|
|
|
|
}, this);
|
|
|
|
|
'border-top-width,border-bottom-width,margin-top,margin-bottom,padding-left,padding-right'
|
|
|
|
|
.split(',').forEach(function(aProperty) {
|
|
|
|
|
let value = sv.getPropertyPixelValue(style, aProperty);
|
|
|
|
|
h -= value;
|
|
|
|
|
if (aProperty.indexOf('top') < -1) y += value;
|
|
|
|
|
}, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// zero width (heigh) canvas becomes wrongly size!!
|
|
|
|
|
w = Math.max(1, w);
|
|
|
|
|
h = Math.max(1, h);
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
canvas.style.display = 'inline';
|
|
|
|
|
canvas.style.margin = (yOffset)+'px 0 0 '+(xOffset)+'px';
|
|
|
|
|
canvas.style.width = (canvas.width = w)+'px';
|
|
|
|
|
canvas.style.height = (canvas.height = h)+'px';
|
2010-03-31 04:35:29 -04:00
|
|
|
|
|
|
|
|
|
w += this.extraXOffset;
|
|
|
|
|
h += this.extraYOffset;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var ctx = canvas.getContext('2d');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
ctx.clearRect(0, 0, w, h);
|
|
|
|
|
ctx.save();
|
|
|
|
|
if (this.mode == this.kMODE_SHRINK) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var offset = sv.getTreePref('tabbar.shrunkenWidth') + this.splitterWidth;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (pos == 'left')
|
|
|
|
|
ctx.translate(offset, 0);
|
|
|
|
|
else
|
|
|
|
|
x += this.splitterWidth;
|
|
|
|
|
w -= offset;
|
|
|
|
|
}
|
|
|
|
|
ctx.globalAlpha = 1;
|
|
|
|
|
if (pos == 'left' || pos == 'right') {
|
|
|
|
|
ctx.fillStyle = this.splitterBorderColor;
|
|
|
|
|
ctx.fillRect((pos == 'left' ? -1 : w+1 ), 0, 1, h);
|
|
|
|
|
}
|
|
|
|
|
ctx.save();
|
|
|
|
|
ctx.scale(zoom, zoom);
|
|
|
|
|
ctx.drawWindow(
|
|
|
|
|
frame,
|
2009-12-17 00:55:45 -05:00
|
|
|
|
(x / zoom)+frame.scrollX+canvasXOffset,
|
|
|
|
|
(y / zoom)+frame.scrollY+canvasYOffset,
|
2009-09-03 02:24:06 -04:00
|
|
|
|
w / zoom,
|
|
|
|
|
h / zoom,
|
|
|
|
|
'-moz-field'
|
|
|
|
|
);
|
|
|
|
|
ctx.restore();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (b.getAttribute(this.kTRANSPARENT) != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_FULL]) {
|
|
|
|
|
var alpha = Number(sv.getTreePref('tabbar.transparent.partialTransparency'));
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (isNaN(alpha)) alpha = 0.25;
|
|
|
|
|
ctx.globalAlpha = alpha;
|
|
|
|
|
ctx.fillStyle = 'black';
|
|
|
|
|
ctx.fillRect(0, 0, w, h);
|
|
|
|
|
}
|
|
|
|
|
ctx.restore();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
get splitterBorderColor()
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var w = this.window;
|
|
|
|
|
var borderNode = sv.getTreePref(
|
2009-09-03 02:24:06 -04:00
|
|
|
|
sv.isVertical ?
|
|
|
|
|
'tabbar.fixed.vertical' :
|
|
|
|
|
'tabbar.fixed.horizontal'
|
|
|
|
|
) ?
|
2010-03-23 09:33:00 -04:00
|
|
|
|
sv.tabStrip :
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.document.getAnonymousElementByAttribute(b, 'class', sv.kSPLITTER) ;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var prop = pos == 'left' ? 'right' :
|
|
|
|
|
pos == 'right' ? 'left' :
|
|
|
|
|
pos == 'top' ? 'bottom' :
|
|
|
|
|
'top' ;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var borderColor = w.getComputedStyle(borderNode, null).getPropertyValue('-moz-border-'+prop+'-colors');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (borderColor == 'none')
|
2010-12-06 08:31:58 -05:00
|
|
|
|
borderRight = w.getComputedStyle(borderNode, null).getPropertyValue('border-'+prop+'-color');
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
/rgba?\(([^,]+),([^,]+),([^,]+)(,.*)?\)/.test(borderColor);
|
|
|
|
|
|
|
|
|
|
return 'rgb('+[
|
|
|
|
|
parseInt(parseInt(RegExp.$1) * 0.8),
|
|
|
|
|
parseInt(parseInt(RegExp.$2) * 0.8),
|
|
|
|
|
parseInt(parseInt(RegExp.$3) * 0.8)
|
|
|
|
|
].join(',')+')';
|
|
|
|
|
},
|
2009-12-17 04:37:25 -05:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
getZoomForFrame : function AHB_getZoomForFrame(aFrame)
|
2009-12-17 04:37:25 -05:00
|
|
|
|
{
|
2009-12-21 05:07:39 -05:00
|
|
|
|
var zoom = aFrame
|
2010-12-06 08:31:58 -05:00
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
|
.QueryInterface(Ci.nsIDocShell)
|
2009-12-21 05:07:39 -05:00
|
|
|
|
.contentViewer
|
2010-12-06 08:31:58 -05:00
|
|
|
|
.QueryInterface(Ci.nsIMarkupDocumentViewer)
|
2009-12-21 05:07:39 -05:00
|
|
|
|
.fullZoom;
|
2009-12-17 04:37:25 -05:00
|
|
|
|
return (zoom * 1000 % 1) ? zoom+0.025 : zoom ;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
clearBG : function AHB_clearBG()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var canvas = this.tabbarCanvas;
|
|
|
|
|
if (this.treeStyleTab.isFloating || !canvas)
|
2010-09-09 22:17:00 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
canvas.style.display = 'none';
|
|
|
|
|
canvas.style.margin = 0;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
// zero width (heigh) canvas becomes wrongly size!!
|
2010-12-06 08:31:58 -05:00
|
|
|
|
canvas.style.width = canvas.style.height = '1px';
|
|
|
|
|
canvas.width = canvas.height = 1;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
updateTransparency : function AHB_updateTransparency()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
2010-05-08 01:37:41 -04:00
|
|
|
|
var pos = sv.currentTabbarPosition;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
var style = this.kTRANSPARENT_STYLE[
|
|
|
|
|
Math.max(
|
|
|
|
|
this.kTRANSPARENT_NONE,
|
|
|
|
|
Math.min(
|
|
|
|
|
this.kTRANSPARENT_FULL,
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.transparent.style')
|
2009-09-03 02:24:06 -04:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
];
|
|
|
|
|
if (pos != 'top' &&
|
|
|
|
|
this.mode != this.kMODE_DISABLED &&
|
2010-03-24 14:36:54 -04:00
|
|
|
|
style != this.kTRANSPARENT_STYLE[this.kTRANSPARENT_NONE]) {
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.setTabbrowserAttribute(this.kTRANSPARENT, style);
|
2010-03-24 14:36:54 -04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.removeTabbrowserAttribute(this.kTRANSPARENT);
|
2010-03-24 14:36:54 -04:00
|
|
|
|
}
|
2010-12-03 09:50:42 -05:00
|
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_APPEARANCE_CHANGE);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// event handling
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
observe : function AHB_observe(aSubject, aTopic, aData)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
switch (aTopic)
|
|
|
|
|
{
|
|
|
|
|
case 'nsPref:changed':
|
|
|
|
|
this.onPrefChange(aData);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
domains : [
|
|
|
|
|
'extensions.treestyletab.',
|
|
|
|
|
'browser.fullscreen.autohide'
|
|
|
|
|
],
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onPrefChange : function AHB_onPrefChange(aPrefName)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var value = this.treeStyleTab.getPref(aPrefName);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
switch (aPrefName)
|
|
|
|
|
{
|
|
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.mode':
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (!this.window.TreeStyleTabService.shouldApplyNewPref) return;
|
|
|
|
|
this.browser.setAttribute(this.kMODE+'-normal', value);
|
2010-05-08 03:15:38 -04:00
|
|
|
|
this.updateMode();
|
|
|
|
|
return;
|
|
|
|
|
|
2010-03-31 05:34:51 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.mode.fullscreen':
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (!this.window.TreeStyleTabService.shouldApplyNewPref) return;
|
|
|
|
|
this.browser.setAttribute(this.kMODE+'-fullscreen', value);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.updateMode();
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.mousemove':
|
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.accelKeyDown':
|
|
|
|
|
case 'extensions.treestyletab.tabbar.autoShow.feedback':
|
|
|
|
|
if (this.enabled && this.shouldListenMouseMove)
|
|
|
|
|
this.startListenMouseMove();
|
|
|
|
|
else
|
|
|
|
|
this.endListenMouseMove();
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.area':
|
|
|
|
|
this.sensitiveArea = value;
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-09-12 23:54:04 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.width':
|
|
|
|
|
case 'extensions.treestyletab.tabbar.shrunkenWidth':
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2010-09-12 23:54:04 -04:00
|
|
|
|
aSelf.onTabbarResized();
|
|
|
|
|
}, 0, this);
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-09-12 23:54:04 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.transparent.style':
|
|
|
|
|
return this.updateTransparency();
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
case 'extensions.treestyletab.tabbar.togglerSize':
|
|
|
|
|
this.togglerSize = value;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var toggler = this.document.getAnonymousElementByAttribute(this.browser, 'class', this.treeStyleTab.kTABBAR_TOGGLER);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
toggler.style.minWidth = toggler.style.minHeight = value+'px';
|
|
|
|
|
if (this.togglerSize <= 0)
|
|
|
|
|
toggler.setAttribute('collapsed', true);
|
|
|
|
|
else
|
|
|
|
|
toggler.removeAttribute('collapsed');
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
case 'browser.fullscreen.autohide':
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (!this.window.fullScreen) return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.end();
|
|
|
|
|
this.mode = value ?
|
2010-05-08 04:30:39 -04:00
|
|
|
|
this.getModeForFullScreen() :
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.kMODE_DISABLED ;
|
|
|
|
|
if (this.mode != this.kMODE_DISABLED)
|
|
|
|
|
this.start();
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
default:
|
2010-05-08 03:15:38 -04:00
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
handleEvent : function AHB_handleEvent(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
switch (aEvent.type)
|
|
|
|
|
{
|
|
|
|
|
case 'mousedown':
|
|
|
|
|
this.onMouseDown(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'mouseup':
|
|
|
|
|
this.onMouseUp(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'mousemove':
|
|
|
|
|
if (this.handleMouseMove(aEvent)) return;
|
|
|
|
|
case 'resize':
|
|
|
|
|
this.onResize(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'scroll':
|
2009-09-08 22:12:58 -04:00
|
|
|
|
this.onScroll(aEvent);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'load':
|
2009-09-08 21:55:48 -04:00
|
|
|
|
if (this.shouldRedraw)
|
|
|
|
|
this.redrawContentArea();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return;
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
|
|
|
|
case 'TabOpen':
|
|
|
|
|
case 'TabClose':
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showForFeedback();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'TabMove':
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (!this.treeStyleTab.subTreeMovingCount && !this.treeStyleTab.internallyTabMovingCount)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showForFeedback();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case 'select':
|
2009-09-08 21:55:48 -04:00
|
|
|
|
if (this.shouldRedraw)
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this.redrawContentArea();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (!this.window.TreeStyleTabService.accelKeyPressed)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showForFeedback();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_TABBAR_POSITION_CHANGING:
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.isResizing = false;
|
|
|
|
|
this.clearBG();
|
2009-12-17 22:20:35 -05:00
|
|
|
|
if (this.shouldRedraw)
|
|
|
|
|
this.hide();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_TABBAR_POSITION_CHANGED:
|
2010-09-13 21:10:55 -04:00
|
|
|
|
if (this.enabled)
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2010-09-13 21:12:11 -04:00
|
|
|
|
aSelf.show();
|
2010-09-13 21:10:55 -04:00
|
|
|
|
aSelf.hide();
|
|
|
|
|
}, 0, this);
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.updateTransparency();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN:
|
2011-01-10 23:20:01 -05:00
|
|
|
|
this.onKeyDown(aEvent.getData('sourceEvent'));
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START:
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this.cancelDelayedShowForShortcut();
|
|
|
|
|
if (this.enabled &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') &&
|
2009-09-03 03:25:37 -04:00
|
|
|
|
(
|
2011-01-10 23:20:01 -05:00
|
|
|
|
aEvent.getData('scrollDown') ||
|
|
|
|
|
aEvent.getData('scrollUp') ||
|
2009-09-03 03:25:37 -04:00
|
|
|
|
( // when you release "shift" key
|
2009-12-17 22:20:35 -05:00
|
|
|
|
this.expanded &&
|
2011-01-10 23:20:01 -05:00
|
|
|
|
aEvent.getData('standBy') &&
|
|
|
|
|
aEvent.getData('onlyShiftKey')
|
2009-09-03 03:25:37 -04:00
|
|
|
|
)
|
|
|
|
|
))
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.show(this.kSHOWN_BY_SHORTCUT);
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END:
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this.cancelDelayedShowForShortcut();
|
|
|
|
|
if (this.enabled &&
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideReason == this.kSHOWN_BY_SHORTCUT)
|
|
|
|
|
this.hide();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
return;
|
2010-12-02 12:54:59 -05:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_PRINT_PREVIEW_ENTERED:
|
2010-12-02 12:54:59 -05:00
|
|
|
|
this.hide();
|
|
|
|
|
this.endListenMouseMove();
|
|
|
|
|
return;
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
case this.treeStyleTab.kEVENT_TYPE_PRINT_PREVIEW_EXITED:
|
2010-12-02 12:54:59 -05:00
|
|
|
|
if (this.enabled && this.shouldListenMouseMove)
|
|
|
|
|
this.startListenMouseMove();
|
|
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onMouseDown : function AHB_onMouseDown(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var w = this.window;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (
|
2009-09-03 04:18:41 -04:00
|
|
|
|
!this.isResizing &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.evaluateXPath(
|
|
|
|
|
'ancestor-or-self::*[@class="'+sv.kSPLITTER+'"]',
|
2009-09-03 05:14:41 -04:00
|
|
|
|
aEvent.originalTarget || aEvent.target,
|
2010-12-06 08:31:58 -05:00
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
2009-09-03 02:24:06 -04:00
|
|
|
|
).booleanValue
|
|
|
|
|
) {
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.isResizing = true;
|
|
|
|
|
this.clearBG();
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.setTabbrowserAttribute(sv.kRESIZING, true);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
/* canvas<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\<EFBFBD><EFBFBD><EFBFBD>ɂ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̂Ɠ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>^<EFBFBD>C<EFBFBD>~<EFBFBD><EFBFBD><EFBFBD>O<EFBFBD>Ń<EFBFBD><EFBFBD>T<EFBFBD>C<EFBFBD>Y<EFBFBD><EFBFBD><EFBFBD>s<EFBFBD><EFBFBD><EFBFBD>ƁA
|
|
|
|
|
<EFBFBD>܂<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><EFBFBD>canvas<EFBFBD>̑傫<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>c<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>܂܂Ȃ̂ŁA<EFBFBD><EFBFBD><EFBFBD>̑傫<EFBFBD><EFBFBD><EFBFBD>ȉ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD>^<EFBFBD>u<EFBFBD>o<EFBFBD>[<EFBFBD>̕<EFBFBD><EFBFBD><EFBFBD><EFBFBD>k<EFBFBD>߂<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>Ȃ<EFBFBD><EFBFBD>B<EFBFBD>蓮<EFBFBD>ŃC<EFBFBD>x<EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><EFBFBD><EFBFBD>đ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ă<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD>̖<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>h<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƃ<EFBFBD><EFBFBD>ł<EFBFBD><EFBFBD><EFBFBD><EFBFBD>B */
|
|
|
|
|
aEvent.preventDefault();
|
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
var flags = 0;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
const nsIDOMNSEvent = Ci.nsIDOMNSEvent;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (aEvent.altKey) flags |= nsIDOMNSEvent.ALT_MASK;
|
|
|
|
|
if (aEvent.ctrlKey) flags |= nsIDOMNSEvent.CONTROL_MASK;
|
|
|
|
|
if (aEvent.shiftKey) flags |= nsIDOMNSEvent.SHIFT_MASK;
|
|
|
|
|
if (aEvent.metaKey) flags |= nsIDOMNSEvent.META_MASK;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
w.setTimeout(function(aX, aY, aButton, aDetail) {
|
|
|
|
|
w.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
|
.getInterface(Ci.nsIDOMWindowUtils)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
.sendMouseEvent('mousedown', aX, aY, aButton, aDetail, flags);
|
|
|
|
|
flags = null;
|
|
|
|
|
}, 0, aEvent.clientX, aEvent.clientY, aEvent.button, aEvent.detail);
|
|
|
|
|
}
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.cancelShowHideOnMousemove();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (
|
|
|
|
|
this.enabled &&
|
2009-12-17 22:20:35 -05:00
|
|
|
|
this.expanded &&
|
2009-09-03 02:24:06 -04:00
|
|
|
|
(
|
2010-12-06 08:31:58 -05:00
|
|
|
|
aEvent.originalTarget.ownerDocument != this.document ||
|
|
|
|
|
!sv.getTabBrowserFromChild(aEvent.originalTarget)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
)
|
|
|
|
|
)
|
2009-09-03 05:14:41 -04:00
|
|
|
|
this.hide();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.lastMouseDownTarget = aEvent.originalTarget.localName;
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onMouseUp : function AHB_onMouseUp(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
if (aEvent.originalTarget &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.evaluateXPath(
|
|
|
|
|
'ancestor-or-self::*[@class="'+sv.kSPLITTER+'"]',
|
2009-09-03 05:17:12 -04:00
|
|
|
|
aEvent.originalTarget,
|
2010-12-06 08:31:58 -05:00
|
|
|
|
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
2009-09-03 05:17:12 -04:00
|
|
|
|
).booleanValue) {
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.isResizing = false;
|
2010-03-28 14:22:15 -04:00
|
|
|
|
sv.removeTabbrowserAttribute(sv.kRESIZING);
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2009-09-08 22:12:58 -04:00
|
|
|
|
if (!aSelf.shouldRedraw) return;
|
2009-09-03 05:22:34 -04:00
|
|
|
|
aSelf.redrawContentArea();
|
|
|
|
|
aSelf.drawBG();
|
|
|
|
|
}, 0, this);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.cancelShowHideOnMousemove();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.lastMouseDownTarget = null;
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
handleMouseMove : function AHB_handleMouseMove(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
if (this.isResizing &&
|
2009-09-03 02:24:06 -04:00
|
|
|
|
/^(scrollbar|thumb|slider|scrollbarbutton)$/i.test(this.lastMouseDownTarget))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (
|
2010-09-10 06:21:26 -04:00
|
|
|
|
!sv.isPopupShown() &&
|
2009-09-03 02:24:06 -04:00
|
|
|
|
(
|
2009-12-17 22:20:35 -05:00
|
|
|
|
!this.expanded ||
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER
|
2009-09-03 02:24:06 -04:00
|
|
|
|
)
|
|
|
|
|
)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideOnMousemove(aEvent);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onResize : function AHB_onResize(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
if (
|
2010-09-12 23:54:04 -04:00
|
|
|
|
aEvent.originalTarget &&
|
2009-12-24 10:01:23 -05:00
|
|
|
|
(
|
2010-12-06 08:31:58 -05:00
|
|
|
|
aEvent.originalTarget.ownerDocument == this.document ||
|
|
|
|
|
aEvent.originalTarget == this.window
|
2010-09-12 23:54:04 -04:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
this.onTabbarResized();
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onTabbarResized : function AHB_onTabbarResized()
|
2010-09-12 23:54:04 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
2010-09-12 23:54:04 -04:00
|
|
|
|
if (sv.isFloating || !this.shouldRedraw)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
return;
|
2010-09-12 23:54:04 -04:00
|
|
|
|
|
2010-05-08 01:37:41 -04:00
|
|
|
|
switch (sv.currentTabbarPosition)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
case 'left':
|
|
|
|
|
sv.container.style.marginRight = '-'+this.XOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
case 'right':
|
|
|
|
|
sv.container.style.marginLeft = '-'+this.XOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
case 'bottom':
|
|
|
|
|
sv.container.style.marginTop = '-'+this.YOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
sv.container.style.marginBottom = '-'+this.YOffset+'px';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
this.redrawContentArea();
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onScroll : function AHB_onScroll(aEvent)
|
2009-09-08 22:12:58 -04:00
|
|
|
|
{
|
|
|
|
|
var node = aEvent.originalTarget;
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if ((node && node.ownerDocument == this.document) || !this.shouldRedraw) return;
|
2009-09-08 22:12:58 -04:00
|
|
|
|
|
|
|
|
|
var tabbarBox, nodeBox;
|
|
|
|
|
if (
|
2010-12-06 08:31:58 -05:00
|
|
|
|
!(node instanceof Ci.nsIDOMElement) ||
|
2009-09-08 22:12:58 -04:00
|
|
|
|
(
|
2010-12-06 08:31:58 -05:00
|
|
|
|
(tabbarBox = this.treeStyleTab.getBoxObjectFor(this.browser.mTabContainer)) &&
|
|
|
|
|
(nodeBox = this.treeStyleTab.getBoxObjectFor(node)) &&
|
2009-09-08 22:12:58 -04:00
|
|
|
|
tabbarBox.screenX <= nodeBox.screenX + nodeBox.width &&
|
|
|
|
|
tabbarBox.screenX + tabbarBox.width >= nodeBox.screenX &&
|
|
|
|
|
tabbarBox.screenY <= nodeBox.screenY + nodeBox.height &&
|
|
|
|
|
tabbarBox.screenY + tabbarBox.height >= nodeBox.screenY
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
this.redrawContentArea();
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
onKeyDown : function AHB_onKeyDown(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
var w = this.window;
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
|
|
|
|
if (this.delayedShowForShortcutDone)
|
|
|
|
|
this.cancelDelayedShowForShortcut();
|
|
|
|
|
|
|
|
|
|
if (
|
2010-09-14 03:39:17 -04:00
|
|
|
|
sv.getTabsArray(b).length > 1 &&
|
2009-09-03 03:25:37 -04:00
|
|
|
|
!aEvent.altKey &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
w.TreeStyleTabService.accelKeyPressed
|
2009-09-03 03:25:37 -04:00
|
|
|
|
) {
|
|
|
|
|
if (this.enabled &&
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoShow.accelKeyDown') &&
|
2009-12-17 22:20:35 -05:00
|
|
|
|
!this.expanded &&
|
2009-09-03 03:25:37 -04:00
|
|
|
|
!this.delayedAutoShowTimer &&
|
|
|
|
|
!this.delayedShowForShortcutTimer) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.delayedShowForShortcutTimer = w.setTimeout(
|
2009-09-03 03:25:37 -04:00
|
|
|
|
function(aSelf) {
|
|
|
|
|
aSelf.delayedShowForShortcutDone = true;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
aSelf.show(aSelf.kSHOWN_BY_SHORTCUT);
|
2009-09-03 03:25:37 -04:00
|
|
|
|
sv = null;
|
|
|
|
|
b = null;
|
|
|
|
|
},
|
2010-12-06 08:31:58 -05:00
|
|
|
|
sv.getTreePref('tabbar.autoShow.accelKeyDown.delay'),
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this
|
|
|
|
|
);
|
|
|
|
|
this.delayedShowForShortcutDone = false;
|
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
2009-09-03 03:25:37 -04:00
|
|
|
|
else {
|
|
|
|
|
if (this.enabled)
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.hide();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
cancelDelayedShowForShortcut : function AHB_cancelDelayedShowForShortcut()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2009-09-03 03:25:37 -04:00
|
|
|
|
if (this.delayedShowForShortcutTimer) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.clearTimeout(this.delayedShowForShortcutTimer);
|
2009-09-03 03:25:37 -04:00
|
|
|
|
this.delayedShowForShortcutTimer = null;
|
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
},
|
|
|
|
|
|
2009-09-03 03:25:37 -04:00
|
|
|
|
delayedShowForShortcutTimer : null,
|
|
|
|
|
delayedShowForShortcutDone : true,
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
init : function AHB_init(aTabBrowser)
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.browser = aTabBrowser;
|
|
|
|
|
this.document = aTabBrowser.ownerDocument;
|
|
|
|
|
this.window = this.document.defaultView;
|
|
|
|
|
this.treeStyleTab = aTabBrowser.treeStyleTab;
|
|
|
|
|
|
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
|
|
|
|
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.enabled = false;
|
|
|
|
|
this.mouseMoveListening = false;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideReason = 0;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.lastMouseDownTarget = null;
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.isResizing = false;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
|
this.showHideOnMousemoveTimer = null;
|
|
|
|
|
this.delayedShowForFeedbackTimer = null;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
b.setAttribute(this.kMODE+'-normal', sv.getTreePref('tabbar.autoHide.mode'));
|
|
|
|
|
b.setAttribute(this.kMODE+'-fullscreen', sv.getTreePref('tabbar.autoHide.mode.fullscreen'));
|
|
|
|
|
sv.addPrefListener(this);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
|
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.transparent.style');
|
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.togglerSize');
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.window.setTimeout(function(aSelf) {
|
2009-09-03 02:24:06 -04:00
|
|
|
|
aSelf.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode');
|
|
|
|
|
}, 0, this);
|
|
|
|
|
|
2010-03-23 09:33:00 -04:00
|
|
|
|
b.mTabContainer.addEventListener('TabOpen', this, false);
|
|
|
|
|
b.mTabContainer.addEventListener('TabClose', this, false);
|
|
|
|
|
b.mTabContainer.addEventListener('TabMove', this, false);
|
2009-09-03 04:18:41 -04:00
|
|
|
|
b.mTabContainer.addEventListener('select', this, false);
|
2010-12-06 08:31:58 -05:00
|
|
|
|
b.addEventListener(sv.kEVENT_TYPE_TABBAR_POSITION_CHANGING, this, false);
|
|
|
|
|
b.addEventListener(sv.kEVENT_TYPE_TABBAR_POSITION_CHANGED, this, false);
|
|
|
|
|
b.addEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN, this, false);
|
|
|
|
|
b.addEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START, this, false);
|
|
|
|
|
b.addEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, this, false);
|
|
|
|
|
|
|
|
|
|
if (!sv.isFloating) {
|
|
|
|
|
let stack = this.document.getAnonymousElementByAttribute(b.mTabContainer, 'class', 'tabs-stack');
|
2010-09-10 06:48:49 -04:00
|
|
|
|
if (stack) {
|
2010-12-06 08:31:58 -05:00
|
|
|
|
let canvas = this.document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
|
2010-09-10 06:48:49 -04:00
|
|
|
|
canvas.setAttribute('style', 'display:none;width:1;height:1;');
|
2010-03-24 15:23:21 -04:00
|
|
|
|
stack.firstChild.appendChild(canvas);
|
2010-09-10 06:48:49 -04:00
|
|
|
|
this.tabbarCanvas = canvas;
|
|
|
|
|
this.clearBG();
|
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
destroy : function AHB_destroy()
|
2009-09-03 02:24:06 -04:00
|
|
|
|
{
|
|
|
|
|
this.end();
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.removePrefListener(this);
|
2010-05-08 04:30:39 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
|
var b = this.browser;
|
2010-03-23 09:33:00 -04:00
|
|
|
|
b.mTabContainer.removeEventListener('TabOpen', this, false);
|
|
|
|
|
b.mTabContainer.removeEventListener('TabClose', this, false);
|
|
|
|
|
b.mTabContainer.removeEventListener('TabMove', this, false);
|
2009-09-03 04:18:41 -04:00
|
|
|
|
b.mTabContainer.removeEventListener('select', this, false);
|
2010-12-06 08:31:58 -05:00
|
|
|
|
b.removeEventListener(sv.kEVENT_TYPE_TABBAR_POSITION_CHANGING, this, false);
|
|
|
|
|
b.removeEventListener(sv.kEVENT_TYPE_TABBAR_POSITION_CHANGED, this, false);
|
|
|
|
|
b.removeEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN, this, false);
|
|
|
|
|
b.removeEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START, this, false);
|
|
|
|
|
b.removeEventListener(sv.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, this, false);
|
|
|
|
|
|
|
|
|
|
delete this.treeStyleTab;
|
|
|
|
|
delete this.browser;
|
|
|
|
|
delete this.document;
|
|
|
|
|
delete this.window;
|
2010-05-08 04:30:39 -04:00
|
|
|
|
},
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
saveCurrentState : function AHB_saveCurrentState()
|
2010-05-08 04:30:39 -04:00
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var b = this.browser;
|
2010-05-08 04:30:39 -04:00
|
|
|
|
var prefs = {
|
|
|
|
|
'tabbar.autoHide.mode' : this.getModeForNormal(b),
|
|
|
|
|
'tabbar.autoHide.mode.fullscreen' : this.getModeForFullScreen(b),
|
|
|
|
|
};
|
|
|
|
|
for (var i in prefs)
|
|
|
|
|
{
|
2010-12-06 08:31:58 -05:00
|
|
|
|
if (this.treeStyleTab.getTreePref(i) != prefs[i])
|
|
|
|
|
this.treeStyleTab.setTreePref(i, prefs[i]);
|
2010-05-08 04:30:39 -04:00
|
|
|
|
}
|
2009-09-03 02:24:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
function AutoHideWindow(aWindow)
|
|
|
|
|
{
|
|
|
|
|
this.init(aWindow);
|
|
|
|
|
}
|
|
|
|
|
AutoHideWindow.prototype = {
|
2010-12-08 02:38:00 -05:00
|
|
|
|
get browser()
|
|
|
|
|
{
|
|
|
|
|
return this.treeStyleTab.browser;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
// mode
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
getMode : function AHW_getMode(aTabBrowser)
|
|
|
|
|
{
|
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
var mode = b.getAttribute(AutoHideBrowser.prototype.kMODE);
|
|
|
|
|
return mode ? parseInt(mode) : AutoHideBrowser.prototype.kMODE_DISABLED ;
|
|
|
|
|
},
|
2010-05-08 03:15:38 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
get mode() /* PUBLIC API */
|
|
|
|
|
{
|
|
|
|
|
var mode = this.getMode();
|
|
|
|
|
if (mode == AutoHideBrowser.prototype.kMODE_SHRINK &&
|
|
|
|
|
this.treeStyleTab.currentTabbarPosition != 'left' &&
|
|
|
|
|
this.treeStyleTab.currentTabbarPosition != 'right')
|
|
|
|
|
return AutoHideBrowser.prototype.kMODE_HIDE;
|
|
|
|
|
return mode;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
set mode(aValue)
|
|
|
|
|
{
|
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
b.setAttribute(AutoHideBrowser.prototype.kMODE, aValue);
|
|
|
|
|
return aValue;
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
toggleMode : function AHW_toggleMode(aTabBrowser) /* PUBLIC API */
|
|
|
|
|
{
|
|
|
|
|
var b = aTabBrowser || this.browser;
|
|
|
|
|
var w = this.window;
|
|
|
|
|
|
|
|
|
|
var key = 'tabbar.autoHide.mode';
|
|
|
|
|
var toggleKey = 'tabbar.autoHide.mode.toggle';
|
|
|
|
|
if (w.fullScreen) {
|
|
|
|
|
key += '.fullscreen';
|
|
|
|
|
toggleKey += '.fullscreen';
|
|
|
|
|
}
|
2010-05-08 03:15:38 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
var mode = this.getMode(b) == AutoHideBrowser.prototype.kMODE_DISABLED ?
|
|
|
|
|
this.treeStyleTab.getTreePref(toggleKey) :
|
|
|
|
|
AutoHideBrowser.prototype.kMODE_DISABLED ;
|
2010-05-08 03:15:38 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
this.treeStyleTab.setTreePref(key, mode);
|
|
|
|
|
b.setAttribute(AutoHideBrowser.prototype.kMODE+'-'+(w.fullScreen ? 'fullscreen' : 'normal' ), mode);
|
|
|
|
|
b.treeStyleTab.autoHide.updateMode();
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
|
|
// for shortcuts
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
updateKeyListeners : function AHW_updateKeyListeners()
|
|
|
|
|
{
|
|
|
|
|
if (
|
|
|
|
|
this.getMode() &&
|
|
|
|
|
this.shouldListenKeyEvents
|
|
|
|
|
) {
|
|
|
|
|
this.treeStyleTab.startListenKeyEventsFor(this.treeStyleTab.LISTEN_FOR_AUTOHIDE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.treeStyleTab.endListenKeyEventsFor(this.treeStyleTab.LISTEN_FOR_AUTOHIDE);
|
|
|
|
|
}
|
|
|
|
|
var w = this.window;
|
|
|
|
|
w.setTimeout(function() {
|
|
|
|
|
if (w.windowState != Ci.nsIDOMChromeWindow.STATE_NORMAL) return;
|
|
|
|
|
var count = 0;
|
|
|
|
|
var resizeTimer = w.setInterval(function(){
|
|
|
|
|
if (++count > 100 || w.innerHeight > 0) {
|
|
|
|
|
w.clearInterval(resizeTimer);
|
|
|
|
|
w.resizeBy(-1,-1);
|
|
|
|
|
w.resizeBy(1,1);
|
|
|
|
|
}
|
|
|
|
|
}, 250);
|
|
|
|
|
}, 0);
|
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
|
get shouldListenKeyEvents()
|
|
|
|
|
{
|
|
|
|
|
return !this.treeStyleTab.ctrlTabPreviewsEnabled &&
|
|
|
|
|
(
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') ||
|
|
|
|
|
this.treeStyleTab.getTreePref('tabbar.autoShow.feedback')
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
init : function AHB_init(aWindow)
|
|
|
|
|
{
|
|
|
|
|
this.window = aWindow;
|
|
|
|
|
this.document = aWindow.document;
|
|
|
|
|
this.treeStyleTab = aWindow.TreeStyleTabService;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
destroy : function AHB_destroy()
|
|
|
|
|
{
|
|
|
|
|
delete this.treeStyleTab;
|
|
|
|
|
delete this.document;
|
|
|
|
|
delete this.window;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|