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.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* The Initial Developer of the Original Code is YUKI "Piro" Hiroshi.
|
2012-01-13 04:06:40 -05:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010-2012
|
2010-12-06 08:31:58 -05:00
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
2012-10-13 14:31:06 -04:00
|
|
|
* Contributor(s): YUKI "Piro" Hiroshi <piro.outsider.reflex@gmail.com>
|
2010-12-06 08:31:58 -05:00
|
|
|
*
|
|
|
|
* 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;
|
2012-10-19 08:38:35 -04:00
|
|
|
|
|
|
|
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
XPCOMUtils.defineLazyGetter(this, 'utils', function() {
|
2012-10-19 08:38:35 -04:00
|
|
|
var ns = {};
|
|
|
|
Components.utils.import('resource://treestyletab-modules/utils.js', ns);
|
|
|
|
return ns.TreeStyleTabUtils;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
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),
|
|
|
|
|
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;
|
2012-10-23 12:43:56 -04:00
|
|
|
return parseInt(b.getAttribute(this.kMODE+'-normal') || utils.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;
|
2012-10-23 12:43:56 -04:00
|
|
|
return parseInt(b.getAttribute(this.kMODE+'-fullscreen') || utils.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,
|
2011-12-04 12:27:30 -05:00
|
|
|
contentAreaScreenEnabled : true,
|
2011-12-19 02:37:48 -05:00
|
|
|
|
|
|
|
closeButtonsMode : -1,
|
|
|
|
CLOSE_BUTTONS_ONLY_ON_CURRENT_TAB : 0,
|
|
|
|
CLOSE_BUTTONS_ON_ALL_TABS : 1,
|
|
|
|
CLOSE_BUTTONS_DISABLED : 2,
|
|
|
|
CLOSE_BUTTONS_ON_TABBAR : 3,
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
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;
|
2011-12-04 12:27:30 -05:00
|
|
|
let resizer = this.resizer;
|
2011-01-22 10:46:29 -05:00
|
|
|
if (sv.position == 'left') {
|
2011-12-04 12:27:30 -05:00
|
|
|
offset += this.togglerSize;
|
|
|
|
if (resizer)
|
|
|
|
offset += resizer.boxObject.width;
|
|
|
|
}
|
|
|
|
else if (sv.position == 'right') {
|
2009-09-03 02:24:06 -04:00
|
|
|
offset -= this.togglerSize;
|
2011-12-04 12:27:30 -05:00
|
|
|
if (resizer)
|
|
|
|
offset -= resizer.boxObject.width;
|
2009-09-03 02:24:06 -04:00
|
|
|
}
|
|
|
|
return offset;
|
|
|
|
|
|
|
|
default:
|
|
|
|
case this.kMODE_SHRINK:
|
2012-10-23 12:43:56 -04:00
|
|
|
return utils.getTreePref('tabbar.width')
|
|
|
|
- utils.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 (
|
2011-01-22 10:46:29 -05:00
|
|
|
sv.position == '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 (
|
2011-01-22 10:46:29 -05:00
|
|
|
sv.position == '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
|
|
|
|
2011-12-04 12:27:30 -05:00
|
|
|
get screen()
|
|
|
|
{
|
|
|
|
return this.document.getElementById('treestyletab-autohide-content-area-screen');
|
|
|
|
},
|
|
|
|
get resizer()
|
|
|
|
{
|
|
|
|
return this.document.getElementById('treestyletab-tabbar-resizer-splitter');
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
2011-12-04 12:27:30 -05:00
|
|
|
this.screen.hidePopup();
|
|
|
|
|
2011-01-12 03:06:06 -05:00
|
|
|
sv.setTabbrowserAttribute(this.kSTATE, this.kSTATE_EXPANDED);
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
b.addEventListener('mousedown', this, true);
|
|
|
|
b.addEventListener('mouseup', this, true);
|
2011-06-12 13:03:50 -04:00
|
|
|
b.addEventListener('dragover', this, true);
|
|
|
|
b.addEventListener('dragleave', this, true);
|
2012-01-13 04:06:40 -05:00
|
|
|
sv.tabStrip.addEventListener('mousedown', this, true);
|
|
|
|
sv.tabStrip.addEventListener('mouseup', this, true);
|
2010-12-06 08:31:58 -05:00
|
|
|
w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
|
|
|
|
w.addEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
|
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.updateTransparency();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2009-09-03 04:18:41 -04:00
|
|
|
this.showHideInternal();
|
2011-04-06 09:04:02 -04:00
|
|
|
|
|
|
|
b.treeStyleTab.fixTooNarrowTabbar();
|
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
|
|
|
|
2011-01-12 03:06:06 -05:00
|
|
|
this.show();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2011-12-04 12:27:30 -05:00
|
|
|
this.screen.hidePopup();
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
b.removeEventListener('mousedown', this, true);
|
|
|
|
b.removeEventListener('mouseup', this, true);
|
2011-06-12 13:03:50 -04:00
|
|
|
b.removeEventListener('dragover', this, true);
|
|
|
|
b.removeEventListener('dragleave', this, true);
|
2012-01-13 04:06:40 -05:00
|
|
|
sv.tabStrip.removeEventListener('mousedown', this, true);
|
|
|
|
sv.tabStrip.removeEventListener('mouseup', this, true);
|
2010-12-06 08:31:58 -05:00
|
|
|
w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_ENTERED, this, false);
|
|
|
|
w.removeEventListener(sv.kEVENT_TYPE_PRINT_PREVIEW_EXITED, this, false);
|
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.updateTransparency();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2010-03-28 14:22:15 -04:00
|
|
|
sv.removeTabbrowserAttribute(this.kAUTOHIDE);
|
|
|
|
sv.removeTabbrowserAttribute(this.kSTATE);
|
2010-09-10 06:21:26 -04:00
|
|
|
|
2011-01-12 03:06:06 -05:00
|
|
|
if (sv.isVertical)
|
2011-01-12 03:25:41 -05: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();
|
2012-10-23 12:43:56 -04:00
|
|
|
this.mode = utils.getTreePref('tabbar.autoHide.mode');
|
2010-12-06 08:31:58 -05:00
|
|
|
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);
|
2011-12-04 12:27:30 -05:00
|
|
|
this.screen.addEventListener('mousemove', this, true);
|
2012-01-13 11:30:06 -05:00
|
|
|
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);
|
2011-12-04 12:27:30 -05:00
|
|
|
this.screen.removeEventListener('mousemove', this, true);
|
2012-01-13 11:30:06 -05:00
|
|
|
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()
|
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
return utils.getTreePref('tabbar.autoShow.mousemove');
|
2009-09-03 02:24:06 -04:00
|
|
|
},
|
|
|
|
|
2011-01-09 11:43:23 -05:00
|
|
|
get shouldListenKeyEventsForAutoHide()
|
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
return utils.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
|
|
|
utils.getTreePref('tabbar.autoShow.tabSwitch');
|
2011-01-09 11:43:23 -05:00
|
|
|
},
|
|
|
|
|
2011-12-04 12:44:49 -05:00
|
|
|
showHideOnMouseMove : function AHB_showHideOnMouseMove(aEvent)
|
2009-09-03 02:24:06 -04:00
|
|
|
{
|
2011-08-22 22:59:01 -04:00
|
|
|
var position = this.getMousePosition(aEvent);
|
|
|
|
if (position == this.MOUSE_POSITION_UNKNOWN)
|
2010-12-06 08:31:58 -05:00
|
|
|
return;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2011-12-04 12:44:49 -05:00
|
|
|
this.cancelShowHideOnMouseMove();
|
2011-12-04 12:27:30 -05:00
|
|
|
this.showHideContentsAreaScreen();
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2011-08-22 22:59:01 -04:00
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
var b = this.browser;
|
|
|
|
var w = this.window;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2011-08-22 22:59:01 -04:00
|
|
|
var shouldShow = position & this.MOUSE_POSITION_SENSITIVE;
|
2009-12-17 22:20:35 -05:00
|
|
|
if (this.expanded) {
|
2009-09-03 02:24:06 -04:00
|
|
|
if (
|
2011-08-22 22:59:01 -04:00
|
|
|
shouldShow &&
|
2009-09-03 04:18:41 -04:00
|
|
|
this.showHideReason & this.kKEEP_SHOWN_ON_MOUSEOVER &&
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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 (
|
2011-08-22 22:59:01 -04:00
|
|
|
!shouldShow &&
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoShow.mousemove')
|
2009-09-03 02:24:06 -04:00
|
|
|
) {
|
2011-12-04 12:44:49 -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
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoHide.delay'),
|
2009-09-03 02:24:06 -04:00
|
|
|
this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2011-08-22 22:59:01 -04:00
|
|
|
else if (shouldShow) {
|
2011-12-04 12:44:49 -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
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoHide.delay'),
|
2009-09-03 02:24:06 -04:00
|
|
|
this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
b = null;
|
|
|
|
},
|
2011-08-22 22:59:01 -04:00
|
|
|
getMousePosition : function AHB_getMousePosition(aEvent)
|
|
|
|
{
|
|
|
|
var w = this.window;
|
|
|
|
if ('gestureInProgress' in w && w.gestureInProgress)
|
|
|
|
return this.MOUSE_POSITION_UNKNOWN;
|
|
|
|
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
var b = this.browser;
|
|
|
|
var pos = sv.position;
|
2011-12-04 12:27:30 -05:00
|
|
|
var box = this.getContentsAreaBox();
|
2011-08-22 22:59:01 -04:00
|
|
|
|
|
|
|
var sensitiveArea = this.sensitiveArea;
|
2011-12-04 12:44:49 -05:00
|
|
|
if (this.shrunken) {
|
2011-12-19 03:29:37 -05:00
|
|
|
let clickable;
|
2011-12-19 02:37:48 -05:00
|
|
|
if (this.widthFromMode > 24 &&
|
2011-12-19 03:29:37 -05:00
|
|
|
(clickable = this.getNearestClickableBox(aEvent))) {
|
2011-12-19 02:37:48 -05:00
|
|
|
/* For resizing of shrunken tab bar and clicking closeboxes,
|
|
|
|
we have to shrink sensitive area. */
|
2011-12-19 03:29:37 -05:00
|
|
|
sensitiveArea = -(clickable.width + clickable.padding);
|
2011-12-19 02:37:48 -05:00
|
|
|
}
|
2011-12-04 12:44:49 -05:00
|
|
|
else if (this.resizer)
|
|
|
|
sensitiveArea = -this.resizer.boxObject.width;
|
|
|
|
else
|
|
|
|
sensitiveArea = 0;
|
|
|
|
}
|
2011-08-22 22:59:01 -04:00
|
|
|
|
|
|
|
if (
|
|
|
|
pos == 'left' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenX > box.screenX + sensitiveArea) :
|
2011-08-22 22:59:01 -04:00
|
|
|
pos == 'right' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenX < box.screenX + box.width - sensitiveArea) :
|
2011-08-22 22:59:01 -04:00
|
|
|
pos == 'bottom' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenY < box.screenY + box.height - sensitiveArea) :
|
|
|
|
(aEvent.screenY > box.screenY + sensitiveArea)
|
|
|
|
) {
|
|
|
|
return this.MOUSE_POSITION_OUTSIDE;
|
|
|
|
}
|
2011-08-22 22:59:01 -04:00
|
|
|
|
|
|
|
if (
|
|
|
|
pos == 'left' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenX <= box.screenX - sensitiveArea) :
|
2011-08-22 22:59:01 -04:00
|
|
|
pos == 'right' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenX >= box.screenX + box.width + sensitiveArea) :
|
2011-08-22 22:59:01 -04:00
|
|
|
pos == 'bottom' ?
|
2011-11-30 09:22:16 -05:00
|
|
|
(aEvent.screenY >= box.screenY + box.height + sensitiveArea) :
|
|
|
|
(aEvent.screenY <= box.screenY - sensitiveArea)
|
|
|
|
) {
|
|
|
|
return this.MOUSE_POSITION_INSIDE;
|
|
|
|
}
|
2011-08-22 22:59:01 -04:00
|
|
|
|
2011-11-30 09:22:16 -05:00
|
|
|
return this.MOUSE_POSITION_NEAR;
|
2011-08-22 22:59:01 -04:00
|
|
|
},
|
2011-12-04 12:27:30 -05:00
|
|
|
getContentsAreaBox : function AHB_getContentsAreaBox()
|
|
|
|
{
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
var b = this.browser;
|
|
|
|
var box = b.mCurrentBrowser.boxObject;
|
2012-02-03 05:11:56 -05:00
|
|
|
var xoffset = (this.shrunken || this.hidden) ? 0 : this.XOffset ;
|
2012-01-13 04:06:40 -05:00
|
|
|
box = {
|
2012-01-23 13:35:48 -05:00
|
|
|
screenX : box.screenX + (sv.position == 'left' ? xoffset : 0 ),
|
2012-01-13 04:06:40 -05:00
|
|
|
screenY : box.screenY,
|
2012-01-23 13:35:48 -05:00
|
|
|
width : box.width - xoffset,
|
2012-01-13 04:06:40 -05:00
|
|
|
height : box.height
|
|
|
|
};
|
2011-12-04 12:27:30 -05:00
|
|
|
return box;
|
|
|
|
},
|
2011-08-22 22:59:01 -04:00
|
|
|
MOUSE_POSITION_UNKNOWN : 0,
|
|
|
|
MOUSE_POSITION_OUTSIDE : (1 << 0),
|
|
|
|
MOUSE_POSITION_INSIDE : (1 << 1),
|
|
|
|
MOUSE_POSITION_NEAR : (1 << 2),
|
|
|
|
MOUSE_POSITION_SENSITIVE : (1 << 1) | (1 << 2),
|
2011-12-19 03:29:37 -05:00
|
|
|
getNearestClickableBox : function AHB_getNearestClickableBox(aEvent)
|
2011-12-19 02:37:48 -05:00
|
|
|
{
|
|
|
|
var sv = this.treeStyleTab;
|
|
|
|
var tab = sv.getTabFromCoordinate(aEvent[sv.screenPositionProp]);
|
|
|
|
if (!tab)
|
2011-12-19 03:29:37 -05:00
|
|
|
return null;
|
2011-12-19 02:37:48 -05:00
|
|
|
|
|
|
|
var position = sv.invertedScreenPositionProp;
|
|
|
|
var size = sv.invertedSizeProp;
|
|
|
|
var coordinate = aEvent[sv.invertedScreenPositionProp];
|
|
|
|
var tabbox = tab.boxObject;
|
2011-12-19 02:43:18 -05:00
|
|
|
|
|
|
|
var closebox;
|
|
|
|
if (this.closeButtonsMode != this.CLOSE_BUTTONS_DISABLED &&
|
|
|
|
this.closeButtonsMode != this.CLOSE_BUTTONS_ON_TABBAR &&
|
2011-12-19 02:49:23 -05:00
|
|
|
(closebox = sv.getTabClosebox(tab)) &&
|
|
|
|
(closebox = closebox.boxObject) &&
|
2011-12-19 02:43:18 -05:00
|
|
|
closebox.width && closebox.height) {
|
|
|
|
let padding = Math.min(
|
|
|
|
closebox[position] - tabbox[position],
|
|
|
|
(tabbox[position] + tabbox[size]) - (closebox[position] + closebox[size])
|
|
|
|
);
|
|
|
|
if (closebox[position] - padding <= coordinate &&
|
|
|
|
closebox[position] + closebox[size] + padding >= coordinate)
|
2012-05-02 06:29:29 -04:00
|
|
|
return this.cloneBoxObject(closebox, { padding : padding });
|
2011-12-19 02:43:18 -05:00
|
|
|
}
|
|
|
|
|
2011-12-19 02:49:23 -05:00
|
|
|
var twisty;
|
|
|
|
if (sv.canCollapseSubtree(tab) &&
|
|
|
|
(twisty = sv.getTabTwisty(tab)) &&
|
|
|
|
(twisty = twisty.boxObject) &&
|
|
|
|
twisty.width && twisty.height) {
|
|
|
|
let padding = Math.min(
|
|
|
|
twisty[position] - tabbox[position],
|
|
|
|
(tabbox[position] + tabbox[size]) - (twisty[position] + twisty[size])
|
|
|
|
);
|
|
|
|
if (twisty[position] - padding <= coordinate &&
|
|
|
|
twisty[position] + twisty[size] + padding >= coordinate)
|
2012-05-02 06:29:29 -04:00
|
|
|
return this.cloneBoxObject(twisty, { padding : padding });
|
2011-12-19 02:49:23 -05:00
|
|
|
}
|
|
|
|
|
2011-12-19 03:29:37 -05:00
|
|
|
return null;
|
2011-12-19 02:37:48 -05:00
|
|
|
},
|
2012-05-02 06:29:29 -04:00
|
|
|
cloneBoxObject : function AHB_cloneBoxObject(aBoxObject, aOverride)
|
|
|
|
{
|
|
|
|
var box = {};
|
|
|
|
for (let i in aBoxObject)
|
|
|
|
{
|
|
|
|
if (typeof aBoxObject[i] != 'function')
|
|
|
|
box[i] = aBoxObject[i];
|
|
|
|
}
|
|
|
|
Object.keys(aOverride).forEach(function(aKey) {
|
|
|
|
box[aKey] = aOverride[aKey];
|
|
|
|
});
|
|
|
|
return box;
|
|
|
|
},
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2011-12-04 12:44:49 -05:00
|
|
|
cancelShowHideOnMouseMove : function AHB_cancelShowHideOnMouseMove()
|
2009-09-03 02:24:06 -04:00
|
|
|
{
|
2011-12-04 12:44:49 -05:00
|
|
|
if (this.showHideOnMouseMoveTimer) {
|
|
|
|
this.window.clearTimeout(this.showHideOnMouseMoveTimer);
|
|
|
|
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 ||
|
2012-10-23 12:43:56 -04:00
|
|
|
!utils.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
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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)
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref('tabbar.width', this.treeStyleTab.maxTabbarWidth(aWidth));
|
2009-09-03 02:24:06 -04:00
|
|
|
else
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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) ?
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.shrunkenWidth') :
|
|
|
|
utils.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) ?
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.shrunkenWidth') :
|
|
|
|
utils.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
|
|
|
{
|
2012-01-13 04:06:40 -05:00
|
|
|
var sv = this.treeStyleTab;
|
2010-12-06 08:31:58 -05:00
|
|
|
var b = this.browser;
|
2011-01-22 10:46:29 -05:00
|
|
|
var pos = sv.position;
|
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;
|
|
|
|
}
|
|
|
|
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();
|
|
|
|
|
2012-01-13 04:06:40 -05:00
|
|
|
if (this.expanded)
|
2010-03-31 14:24:23 -04:00
|
|
|
sv.setTabbrowserAttribute(this.kAUTOHIDE, 'show');
|
|
|
|
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.fireStateChangeEvent();
|
2011-12-04 12:27:30 -05:00
|
|
|
aSelf.showHideContentsAreaScreen();
|
2009-12-17 04:37:25 -05:00
|
|
|
}, 0, this);
|
2009-09-03 02:24:06 -04:00
|
|
|
},
|
2011-12-04 12:27:30 -05:00
|
|
|
showHideContentsAreaScreen : function AHB_showHideContentsAreaScreen()
|
|
|
|
{
|
2011-12-05 02:27:33 -05:00
|
|
|
if (
|
|
|
|
this.expanded &&
|
|
|
|
this.contentAreaScreenEnabled &&
|
2011-12-05 02:41:13 -05:00
|
|
|
this.treeStyleTab.FocusManager.activeWindow &&
|
2011-12-05 03:10:16 -05:00
|
|
|
this.treeStyleTab.FocusManager.activeWindow.top == this.window &&
|
|
|
|
this.findPluginArea(this.browser.contentWindow)
|
2011-12-05 02:27:33 -05:00
|
|
|
) {
|
2011-12-04 12:27:30 -05:00
|
|
|
let box = this.getContentsAreaBox();
|
|
|
|
let style = this.screen.style;
|
|
|
|
let width = Math.min(box.width, this.window.screen.availWidth - box.screenX);
|
|
|
|
let height = Math.min(box.height, this.window.screen.availHeight - box.screenY);
|
|
|
|
style.width = width+'px';
|
|
|
|
style.height = height+'px';
|
|
|
|
if (this.screen.state == 'open')
|
|
|
|
this.screen.moveTo(box.screenX, box.screenY);
|
|
|
|
else
|
|
|
|
this.screen.openPopupAtScreen(box.screenX, box.screenY, false);
|
|
|
|
this.screen.setAttribute('popup-shown', true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.screen.removeAttribute('popup-shown');
|
|
|
|
if (this.screen.state != 'close')
|
|
|
|
this.screen.hidePopup();
|
|
|
|
}
|
|
|
|
},
|
2011-12-05 03:10:16 -05:00
|
|
|
findPluginArea : function AHB_findPluginArea(aFrame)
|
|
|
|
{
|
|
|
|
return aFrame.document.querySelector('embed, object') ||
|
|
|
|
Array.some(aFrame.frames, arguments.callee);
|
|
|
|
},
|
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;
|
2011-01-22 10:46:29 -05:00
|
|
|
var pos = sv.position;
|
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:
|
2012-01-13 04:06:40 -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') {
|
2012-10-23 12:43:56 -04:00
|
|
|
let width = sv.maxTabbarWidth(utils.getTreePref('tabbar.width'));
|
2012-01-13 04:06:40 -05:00
|
|
|
sv.updateFloatingTabbar(sv.kTABBAR_UPDATE_BY_AUTOHIDE);
|
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;
|
2011-01-22 10:46:29 -05:00
|
|
|
var pos = sv.position;
|
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
|
|
|
|
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')
|
2012-10-23 12:43:56 -04:00
|
|
|
sv.setTabStripAttribute('width', utils.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
|
|
|
},
|
|
|
|
|
|
|
|
|
2009-12-17 04:37:25 -05:00
|
|
|
|
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;
|
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.',
|
2011-12-19 02:37:48 -05:00
|
|
|
'browser.fullscreen.autohide',
|
|
|
|
'browser.tabs.closeButtons'
|
2009-09-03 02:24:06 -04:00
|
|
|
],
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
onPrefChange : function AHB_onPrefChange(aPrefName)
|
2009-09-03 02:24:06 -04:00
|
|
|
{
|
2012-01-23 14:07:56 -05:00
|
|
|
// ignore after destruction
|
|
|
|
if (!this.window || !this.window.TreeStyleTabService)
|
|
|
|
return;
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2011-12-04 12:27:30 -05:00
|
|
|
case 'extensions.treestyletab.tabbar.autoHide.contentAreaScreen.enabled':
|
|
|
|
return this.contentAreaScreenEnabled = value;
|
|
|
|
|
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
|
|
|
|
2011-12-19 02:37:48 -05:00
|
|
|
case 'browser.tabs.closeButtons':
|
|
|
|
return this.closeButtonsMode = value;
|
|
|
|
|
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':
|
2011-06-12 13:03:50 -04:00
|
|
|
return this.onMouseDown(aEvent);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
case 'mouseup':
|
2011-06-12 13:03:50 -04:00
|
|
|
return this.onMouseUp(aEvent);
|
2009-09-03 02:24:06 -04:00
|
|
|
|
|
|
|
case 'mousemove':
|
2012-01-13 04:06:40 -05:00
|
|
|
return this.handleMouseMove(aEvent);
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
|
|
case 'TabOpen':
|
|
|
|
case 'TabClose':
|
2011-06-12 13:03:50 -04:00
|
|
|
return this.showForFeedback();
|
2009-09-03 03:25:37 -04:00
|
|
|
|
|
|
|
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':
|
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;
|
|
|
|
|
2011-06-12 13:03:50 -04:00
|
|
|
case 'dragover':
|
|
|
|
return this.onDragOver(aEvent);
|
|
|
|
|
|
|
|
case 'dragleave':
|
|
|
|
return this.onDragLeave(aEvent);
|
|
|
|
|
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;
|
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-06-12 13:03:50 -04:00
|
|
|
return this.onKeyDown(aEvent.getData('sourceEvent'));
|
2009-09-03 03:25:37 -04:00
|
|
|
|
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 &&
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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;
|
2010-03-28 14:22:15 -04:00
|
|
|
sv.setTabbrowserAttribute(sv.kRESIZING, true);
|
2009-09-03 02:24:06 -04:00
|
|
|
}
|
2011-12-04 12:44:49 -05: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);
|
2009-09-03 02:24:06 -04:00
|
|
|
}
|
2011-12-04 12:44:49 -05: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 (
|
2012-01-23 13:35:48 -05:00
|
|
|
!aEvent.shiftKey &&
|
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
|
2011-12-19 04:58:25 -05:00
|
|
|
) &&
|
|
|
|
!this.lastMouseDownTarget
|
2009-09-03 02:24:06 -04:00
|
|
|
)
|
2011-12-04 12:44:49 -05:00
|
|
|
this.showHideOnMouseMove(aEvent);
|
2009-09-03 02:24:06 -04:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
2011-06-12 13:03:50 -04:00
|
|
|
onDragOver : function AHB_onDragOver(aEvent)
|
|
|
|
{
|
|
|
|
if (this.expanded)
|
|
|
|
return;
|
|
|
|
|
2011-08-22 22:59:01 -04:00
|
|
|
var position = this.getMousePosition(aEvent);
|
|
|
|
if (!(position & this.MOUSE_POSITION_SENSITIVE))
|
|
|
|
return;
|
|
|
|
|
2011-06-12 13:03:50 -04:00
|
|
|
var draggedTabs = this.window['piro.sakura.ne.jp'].tabsDragUtils.getSelectedTabs(aEvent);
|
2011-06-14 11:29:36 -04:00
|
|
|
if (
|
|
|
|
draggedTabs.length ||
|
|
|
|
this.treeStyleTab.tabbarDNDObserver.retrieveURLsFromDataTransfer(aEvent.dataTransfer).length
|
|
|
|
) {
|
2011-06-12 13:03:50 -04:00
|
|
|
this.show(this.kSHOWN_BY_MOUSEMOVE);
|
|
|
|
|
|
|
|
if (this._autoHideOnDragLeaveTimer) {
|
|
|
|
this.window.clearTimeout(this._autoHideOnDragLeaveTimer);
|
|
|
|
delete this._autoHideOnDragLeaveTimer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDragLeave : function AHB_onDragLeave(aEvent)
|
|
|
|
{
|
|
|
|
if (!this.expanded)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._autoHideOnDragLeaveTimer)
|
|
|
|
this.window.clearTimeout(this._autoHideOnDragLeaveTimer);
|
|
|
|
|
2011-08-22 22:59:01 -04:00
|
|
|
var position = this.getMousePosition(aEvent);
|
|
|
|
if (position & this.MOUSE_POSITION_SENSITIVE)
|
|
|
|
return;
|
|
|
|
|
2011-06-12 13:03:50 -04:00
|
|
|
this._autoHideOnDragLeaveTimer = this.window.setTimeout(function(aSelf) {
|
|
|
|
delete aSelf._autoHideOnDragLeaveTimer;
|
|
|
|
aSelf.hide(aSelf.kSHOWN_BY_MOUSEMOVE);
|
|
|
|
}, 100, this);
|
|
|
|
},
|
|
|
|
|
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 (
|
2012-09-23 02:43:49 -04:00
|
|
|
sv.getTabs(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 &&
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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;
|
|
|
|
},
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.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 {
|
2012-01-02 16:00:04 -05:00
|
|
|
if (this.enabled &&
|
|
|
|
this.showHideReason == this.kSHOWN_BY_SHORTCUT)
|
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
|
|
|
|
2011-12-04 12:44:49 -05:00
|
|
|
this.showHideOnMouseMoveTimer = null;
|
2009-09-03 04:18:41 -04:00
|
|
|
this.delayedShowForFeedbackTimer = null;
|
2009-09-03 02:24:06 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
b.setAttribute(this.kMODE+'-normal', utils.getTreePref('tabbar.autoHide.mode'));
|
|
|
|
b.setAttribute(this.kMODE+'-fullscreen', utils.getTreePref('tabbar.autoHide.mode.fullscreen'));
|
2010-12-06 08:31:58 -05:00
|
|
|
sv.addPrefListener(this);
|
2011-12-19 02:37:48 -05:00
|
|
|
this.onPrefChange('browser.tabs.closeButtons');
|
2009-09-03 02:24:06 -04:00
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.area');
|
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.togglerSize');
|
2011-12-04 12:27:30 -05:00
|
|
|
this.onPrefChange('extensions.treestyletab.tabbar.autoHide.contentAreaScreen.enabled');
|
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);
|
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)
|
|
|
|
{
|
2012-10-23 12:43:56 -04:00
|
|
|
if (utils.getTreePref(i) != prefs[i])
|
|
|
|
utils.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 &&
|
2011-01-22 10:46:29 -05:00
|
|
|
this.treeStyleTab.position != 'left' &&
|
|
|
|
this.treeStyleTab.position != 'right')
|
2010-12-06 08:31:58 -05:00
|
|
|
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 ?
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref(toggleKey) :
|
2010-12-06 08:31:58 -05:00
|
|
|
AutoHideBrowser.prototype.kMODE_DISABLED ;
|
2010-05-08 03:15:38 -04:00
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.setTreePref(key, mode);
|
2010-12-06 08:31:58 -05:00
|
|
|
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()
|
|
|
|
{
|
2012-01-23 14:07:56 -05:00
|
|
|
// ignore after destruction
|
|
|
|
if (!this.window || !this.window.TreeStyleTabService)
|
|
|
|
return;
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
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() {
|
2011-06-23 13:43:21 -04:00
|
|
|
if (w.windowState != Ci.nsIDOMChromeWindow.STATE_NORMAL)
|
|
|
|
return;
|
2010-12-06 08:31:58 -05:00
|
|
|
var count = 0;
|
|
|
|
var resizeTimer = w.setInterval(function(){
|
2011-06-23 13:43:21 -04:00
|
|
|
if (w.windowState != Ci.nsIDOMChromeWindow.STATE_NORMAL)
|
|
|
|
return w.clearInterval(resizeTimer);
|
|
|
|
|
2010-12-06 08:31:58 -05:00
|
|
|
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 &&
|
|
|
|
(
|
2012-10-23 12:43:56 -04:00
|
|
|
utils.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
|
|
|
utils.getTreePref('tabbar.autoShow.tabSwitch') ||
|
|
|
|
utils.getTreePref('tabbar.autoShow.feedback')
|
2010-12-06 08:31:58 -05:00
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|