2011-11-29 13:40:11 -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.
|
2014-03-31 02:10:51 -04:00
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2011-2014
|
2011-11-29 13:40:11 -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>
|
2013-11-09 14:28:07 -05:00
|
|
|
* Tetsuharu OHZEKI <https://github.com/saneyuki>
|
2011-11-29 13:40:11 -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 = ['FullTooltipManager'];
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
2012-10-19 08:38:35 -04:00
|
|
|
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');
|
|
|
|
|
2014-04-02 06:25:51 -04:00
|
|
|
Components.utils.import('resource://treestyletab-modules/lib/inherit.jsm');
|
2012-09-27 02:42:50 -04:00
|
|
|
Components.utils.import('resource://treestyletab-modules/base.js');
|
2011-12-09 06:10:04 -05:00
|
|
|
Components.utils.import('resource://treestyletab-modules/pseudoTreeBuilder.js');
|
2011-11-29 13:40:11 -05:00
|
|
|
|
2012-11-11 08:48:42 -05:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
2012-10-19 08:38:35 -04:00
|
|
|
|
2013-10-08 12:09:01 -04:00
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, 'ScreenManager',
|
|
|
|
'@mozilla.org/gfx/screenmanager;1', 'nsIScreenManager');
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
function FullTooltipManager(aOwner)
|
|
|
|
{
|
|
|
|
this.init(aOwner);
|
|
|
|
}
|
2014-04-02 06:25:51 -04:00
|
|
|
FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
2011-11-29 13:40:11 -05:00
|
|
|
|
|
|
|
kTOOLTIP_MODE_DEFAULT : 0,
|
|
|
|
kTOOLTIP_MODE_COLLAPSED : 1,
|
|
|
|
kTOOLTIP_MODE_ALWAYS : 2,
|
|
|
|
|
|
|
|
get window()
|
|
|
|
{
|
|
|
|
return this.owner.window;
|
|
|
|
},
|
|
|
|
|
|
|
|
get document()
|
|
|
|
{
|
|
|
|
return this.owner.document;
|
|
|
|
},
|
|
|
|
|
|
|
|
get tabTooltip()
|
|
|
|
{
|
2012-01-13 03:38:12 -05:00
|
|
|
return this.document.getElementById('tabbrowser-tab-tooltip');
|
2011-11-29 13:40:11 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
get tabFullTooltip()
|
|
|
|
{
|
|
|
|
return this.document.getElementById('treestyletab-full-tree-tooltip');
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
init : function FTM_init(aOwner)
|
|
|
|
{
|
|
|
|
this.owner = aOwner;
|
|
|
|
|
|
|
|
this.tabTooltip.addEventListener('popupshowing', this, true);
|
|
|
|
this.tabTooltip.addEventListener('popuphiding', this, true);
|
2011-11-29 14:27:08 -05:00
|
|
|
|
2011-12-09 06:10:04 -05:00
|
|
|
this.tabFullTooltip.addEventListener('click', this, false);
|
2011-12-09 12:35:19 -05:00
|
|
|
this.tabFullTooltip.addEventListener(PseudoTreeBuilder.kTAB_LINK_CLICK, this, true);
|
2011-11-29 14:27:08 -05:00
|
|
|
this.tabFullTooltip.addEventListener('popupshown', this, true);
|
|
|
|
this.tabFullTooltip.addEventListener('popuphidden', this, true);
|
2011-11-29 13:40:11 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy : function FTM_destroy()
|
|
|
|
{
|
2011-11-29 14:27:08 -05:00
|
|
|
this.cancel();
|
|
|
|
this.stopListenTooltipEvents();
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
this.tabTooltip.removeEventListener('popupshowing', this, true);
|
|
|
|
this.tabTooltip.removeEventListener('popuphiding', this, true);
|
2011-11-29 14:27:08 -05:00
|
|
|
|
2011-12-09 06:10:04 -05:00
|
|
|
this.tabFullTooltip.removeEventListener('click', this, false);
|
2011-12-09 12:35:19 -05:00
|
|
|
this.tabFullTooltip.removeEventListener(PseudoTreeBuilder.kTAB_LINK_CLICK, this, true);
|
2011-11-29 14:27:08 -05:00
|
|
|
this.tabFullTooltip.removeEventListener('popupshown', this, true);
|
|
|
|
this.tabFullTooltip.removeEventListener('popuphidden', this, true);
|
2011-11-29 13:40:11 -05:00
|
|
|
|
|
|
|
delete this.owner;
|
|
|
|
},
|
|
|
|
|
|
|
|
handleEvent : function FTM_handleEvent(aEvent)
|
|
|
|
{
|
|
|
|
switch (aEvent.type)
|
|
|
|
{
|
|
|
|
case 'click':
|
|
|
|
return this.onClick(aEvent);
|
|
|
|
|
2011-12-09 06:10:04 -05:00
|
|
|
case PseudoTreeBuilder.kTAB_LINK_CLICK:
|
|
|
|
return this.onItemClick(aEvent);
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
case 'popupshowing':
|
2011-11-29 14:27:08 -05:00
|
|
|
return this.onDefaultTooltipShowing(aEvent);
|
2011-11-29 13:40:11 -05:00
|
|
|
|
|
|
|
case 'popuphiding':
|
2011-11-29 14:27:08 -05:00
|
|
|
return this.onDefaultTooltipHiding(aEvent);
|
|
|
|
|
|
|
|
case 'popupshown':
|
|
|
|
return this.onShown(aEvent);
|
|
|
|
|
|
|
|
case 'popuphidden':
|
|
|
|
return this.onHidden(aEvent);
|
|
|
|
|
|
|
|
case 'mousemove':
|
|
|
|
return this.onTooltipMouseMove(aEvent);
|
|
|
|
|
|
|
|
case 'mouseover':
|
|
|
|
return this.cancelDelayedHide();
|
|
|
|
|
2011-11-30 05:33:12 -05:00
|
|
|
case 'mouseout':
|
|
|
|
return this.hideWithDelay();
|
|
|
|
|
2011-11-29 14:27:08 -05:00
|
|
|
default:
|
|
|
|
return this.onTooltipEvent(aEvent);
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-11-29 14:27:08 -05:00
|
|
|
getFullTooltipFromEvent : function FTM_getFullTooltipFromEvent(aEvent)
|
|
|
|
{
|
|
|
|
return this.evaluateXPath(
|
|
|
|
'ancestor-or-self::xul:tooltip[@id="'+this.tabFullTooltip.id+'"]',
|
|
|
|
aEvent.target,
|
|
|
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
|
|
).singleNodeValue;
|
|
|
|
},
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
onClick : function FTM_onClick(aEvent)
|
|
|
|
{
|
2011-12-09 06:10:04 -05:00
|
|
|
this.tabFullTooltip.hidePopup();
|
|
|
|
},
|
|
|
|
|
|
|
|
onItemClick : function FTM_onItemClick(aEvent)
|
|
|
|
{
|
2014-03-11 12:50:40 -04:00
|
|
|
var id = aEvent.detail.id;
|
2011-12-09 06:10:04 -05:00
|
|
|
if (id) {
|
2011-11-29 13:40:11 -05:00
|
|
|
let tab = this.getTabById(id, this.owner.browser);
|
2011-12-09 12:35:19 -05:00
|
|
|
if (tab) {
|
2014-03-11 12:50:40 -04:00
|
|
|
let event = aEvent.detail.sourceEvent;
|
2011-12-11 09:09:53 -05:00
|
|
|
if (event.button == 1 ||
|
|
|
|
(event.button == 0 && this.isAccelKeyPressed(event)))
|
2011-12-09 12:35:19 -05:00
|
|
|
this.owner.browser.removeTab(tab);
|
2011-12-09 12:36:08 -05:00
|
|
|
else if (event.button != 2)
|
2011-12-09 12:35:19 -05:00
|
|
|
this.owner.browser.selectedTab = tab;
|
|
|
|
}
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
|
|
|
this.tabFullTooltip.hidePopup();
|
|
|
|
},
|
|
|
|
|
2011-11-29 14:27:08 -05:00
|
|
|
onDefaultTooltipShowing : function FTM_onDefaultTooltipShowing(aEvent)
|
2011-11-29 13:40:11 -05:00
|
|
|
{
|
|
|
|
this.cancel();
|
|
|
|
this.handleDefaultTooltip(aEvent);
|
|
|
|
},
|
|
|
|
|
2011-11-29 14:27:08 -05:00
|
|
|
onDefaultTooltipHiding : function FTM_onDefaultTooltipHiding(aEvent)
|
|
|
|
{
|
|
|
|
this.cancel();
|
|
|
|
},
|
|
|
|
|
|
|
|
onShown : function FTM_onShown(aEvent)
|
|
|
|
{
|
|
|
|
this.startListenTooltipEvents();
|
2011-11-30 06:22:19 -05:00
|
|
|
|
|
|
|
var tooltip = this.tabFullTooltip;
|
|
|
|
tooltip.setAttribute('popup-shown', true);
|
|
|
|
|
|
|
|
var w = {},
|
|
|
|
h = {};
|
|
|
|
var box = tooltip.boxObject;
|
|
|
|
var scrollBoxObject = tooltip.firstChild.scrollBoxObject;
|
|
|
|
scrollBoxObject.getScrolledSize(w, h);
|
|
|
|
var currentW = box.width - scrollBoxObject.width + w.value;
|
|
|
|
var currentH = box.height - scrollBoxObject.height + h.value;
|
|
|
|
var currentX = box.screenX;
|
|
|
|
var currentY = box.screenY;
|
|
|
|
|
2011-12-04 13:46:40 -05:00
|
|
|
var currentScreen = Cc['@mozilla.org/gfx/screenmanager;1']
|
|
|
|
.getService(Ci.nsIScreenManager)
|
|
|
|
.screenForRect(box.screenX, box.screenY, box.width, box.height);
|
|
|
|
var screenLeft = {},
|
|
|
|
screenTop = {},
|
|
|
|
screenWidth = {},
|
|
|
|
screenHeight = {};
|
|
|
|
currentScreen.GetRect(screenLeft, screenTop, screenWidth, screenHeight);
|
2011-11-30 06:22:19 -05:00
|
|
|
|
2011-12-04 13:46:40 -05:00
|
|
|
var style = tooltip.style;
|
|
|
|
style.maxWidth = screenWidth.value+'px';
|
|
|
|
style.maxHeight = screenHeight.value+'px';
|
2011-11-30 13:02:03 -05:00
|
|
|
style.minWidth = 0;
|
|
|
|
style.minHeight = 0;
|
2011-12-04 13:48:54 -05:00
|
|
|
if (currentX + currentW + screenLeft.value >= screenWidth.value)
|
2011-12-04 13:46:40 -05:00
|
|
|
style.marginLeft = (Math.max(screenLeft.value, screenWidth.value - currentW) - this.window.screenX)+'px';
|
2011-12-04 13:48:54 -05:00
|
|
|
if (currentY + currentH + screenTop.value >= screenHeight.value)
|
2011-12-04 13:46:40 -05:00
|
|
|
style.marginTop = (Math.max(screenTop.value, screenHeight.value - currentH) - this.window.screenY)+'px';
|
2011-11-29 14:27:08 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
onHidden : function FTM_onHidden(aEvent)
|
|
|
|
{
|
2011-11-30 06:22:19 -05:00
|
|
|
this.tabFullTooltip.removeAttribute('popup-shown');
|
2011-11-29 14:27:08 -05:00
|
|
|
this.stopListenTooltipEvents();
|
|
|
|
this.clear();
|
|
|
|
},
|
|
|
|
|
|
|
|
onTooltipMouseMove : function FTM_onTooltipMouseMove(aEvent)
|
2011-11-29 13:40:11 -05:00
|
|
|
{
|
2011-11-30 05:33:12 -05:00
|
|
|
if (this.getFullTooltipFromEvent(aEvent))
|
|
|
|
this.cancelDelayedHide();
|
|
|
|
else
|
2011-11-29 14:27:08 -05:00
|
|
|
this.hideWithDelay();
|
|
|
|
},
|
|
|
|
|
|
|
|
onTooltipEvent : function FTM_onTooltipEvent(aEvent)
|
|
|
|
{
|
|
|
|
if (!this.getFullTooltipFromEvent(aEvent))
|
|
|
|
this.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
startListenTooltipEvents : function FTM_startListenTooltipEvents()
|
|
|
|
{
|
|
|
|
if (this.listening)
|
|
|
|
return;
|
|
|
|
this.window.addEventListener('DOMMouseScroll', this, true);
|
|
|
|
this.window.addEventListener('keydown', this, true);
|
|
|
|
this.window.addEventListener('mousedown', this, true);
|
|
|
|
this.window.addEventListener('mouseup', this, true);
|
|
|
|
this.window.addEventListener('dragstart', this, true);
|
|
|
|
this.window.addEventListener('mousemove', this, true);
|
2011-11-30 05:33:12 -05:00
|
|
|
this.tabFullTooltip.addEventListener('mouseover', this, false);
|
|
|
|
this.tabFullTooltip.addEventListener('mouseout', this, false);
|
2011-11-29 14:27:08 -05:00
|
|
|
this.listening = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
stopListenTooltipEvents : function FTM_stopListenTooltipEvents()
|
|
|
|
{
|
|
|
|
if (!this.listening)
|
|
|
|
return;
|
|
|
|
this.window.removeEventListener('DOMMouseScroll', this, true);
|
|
|
|
this.window.removeEventListener('keydown', this, true);
|
|
|
|
this.window.removeEventListener('mousedown', this, true);
|
|
|
|
this.window.removeEventListener('mouseup', this, true);
|
|
|
|
this.window.removeEventListener('dragstart', this, true);
|
|
|
|
this.window.removeEventListener('mousemove', this, true);
|
2011-11-30 05:33:12 -05:00
|
|
|
this.tabFullTooltip.removeEventListener('mouseover', this, false);
|
|
|
|
this.tabFullTooltip.removeEventListener('mouseout', this, false);
|
2011-11-29 14:27:08 -05:00
|
|
|
this.listening = false;
|
2011-11-29 13:40:11 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
handleDefaultTooltip : function FTM_handleDefaultTooltip(aEvent)
|
|
|
|
{
|
|
|
|
var tab = this.getTabFromChild(this.document.tooltipNode);
|
|
|
|
if (!tab || tab.localName != 'tab')
|
|
|
|
return;
|
|
|
|
|
|
|
|
var label;
|
|
|
|
var collapsed = this.isSubtreeCollapsed(tab);
|
2012-10-23 12:43:56 -04:00
|
|
|
var mode = utils.getTreePref('tooltip.mode');
|
2011-11-29 13:40:11 -05:00
|
|
|
|
|
|
|
var base = parseInt(tab.getAttribute(this.kNEST) || 0);
|
|
|
|
var descendant = this.getDescendantTabs(tab);
|
|
|
|
var indentPart = ' ';
|
|
|
|
var tree = null;
|
|
|
|
var fullTooltipExtraLabel = '';
|
|
|
|
if (mode > this.kTOOLTIP_MODE_DEFAULT &&
|
|
|
|
descendant.length) {
|
|
|
|
let tabs = [tab].concat(descendant);
|
2012-10-23 12:43:56 -04:00
|
|
|
let tabsToBeListed = tabs.slice(0, Math.max(1, utils.getTreePref('tooltip.maxCount')));
|
2011-11-29 13:40:11 -05:00
|
|
|
tree = tabsToBeListed
|
|
|
|
.map(function(aTab) {
|
|
|
|
let label = aTab.getAttribute('label');
|
|
|
|
let indent = '';
|
|
|
|
let nest = parseInt(aTab.getAttribute(this.kNEST) || 0) - base;
|
|
|
|
for (let i = 0; i < nest; i++)
|
|
|
|
{
|
|
|
|
indent += indentPart;
|
|
|
|
}
|
2013-01-02 21:08:25 -05:00
|
|
|
return utils.treeBundle.getFormattedString('tooltip.item.label', [label, indent]);
|
2011-11-29 13:40:11 -05:00
|
|
|
}, this)
|
|
|
|
.join('\n');
|
|
|
|
if (tabs.length != tabsToBeListed.length) {
|
2013-01-02 21:08:25 -05:00
|
|
|
tree += '\n'+indentPart+utils.treeBundle.getFormattedString('tooltip.more', [tabs.length-tabsToBeListed.length]);
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-09 08:28:48 -04:00
|
|
|
var shouldShowTree = mode != this.kTOOLTIP_MODE_DEFAULT && (collapsed || mode == this.kTOOLTIP_MODE_ALWAYS);
|
2011-11-29 13:40:11 -05:00
|
|
|
if ('mOverCloseButton' in tab && tab.mOverCloseButton) {
|
|
|
|
if (descendant.length &&
|
2012-10-23 12:43:56 -04:00
|
|
|
(collapsed || utils.getTreePref('closeParentBehavior') == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN)) {
|
2011-11-29 13:40:11 -05:00
|
|
|
label = tree || tab.getAttribute('label');
|
2012-04-09 08:28:48 -04:00
|
|
|
label = label && shouldShowTree ?
|
2013-01-02 21:08:25 -05:00
|
|
|
utils.treeBundle.getFormattedString('tooltip.closeTree.labeled', [label]) :
|
|
|
|
utils.treeBundle.getString('tooltip.closeTree') ;
|
|
|
|
fullTooltipExtraLabel = utils.treeBundle.getFormattedString('tooltip.closeTree.labeled', ['%TREE%']).split(/\s*%TREE%\s*/);
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (tab.getAttribute(this.kTWISTY_HOVER) == 'true') {
|
2011-11-29 13:52:47 -05:00
|
|
|
let key = collapsed ?
|
2011-11-29 13:40:11 -05:00
|
|
|
'tooltip.expandSubtree' :
|
|
|
|
'tooltip.collapseSubtree' ;
|
|
|
|
label = tree || tab.getAttribute('label');
|
2012-04-09 08:28:48 -04:00
|
|
|
label = label && shouldShowTree ?
|
2013-01-02 21:08:25 -05:00
|
|
|
utils.treeBundle.getFormattedString(key+'.labeled', [label]) :
|
|
|
|
utils.treeBundle.getString(key) ;
|
|
|
|
fullTooltipExtraLabel = utils.treeBundle.getFormattedString(key+'.labeled', ['%TREE%']).split(/\s*%TREE%\s*/);
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
2012-04-09 08:28:48 -04:00
|
|
|
else if (shouldShowTree) {
|
2011-11-29 13:40:11 -05:00
|
|
|
label = tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!label)
|
|
|
|
return;
|
|
|
|
|
|
|
|
aEvent.target.setAttribute('label', label);
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
2012-04-09 08:28:48 -04:00
|
|
|
if (shouldShowTree)
|
|
|
|
this.setup(aEvent.target, tab, fullTooltipExtraLabel);
|
2011-11-29 13:40:11 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
2013-10-08 12:09:01 -04:00
|
|
|
/**
|
|
|
|
* If the window is maximized, screenX and screenY can be out of
|
|
|
|
* visible screen rect. On the other hand,
|
|
|
|
* nsIPopupBoxObject#openPopupAtScreen() automatically reposition
|
|
|
|
* the popup if it is going to be shown out of the visible screen
|
|
|
|
* rect. As the result, the popup will be repositioned unexpectedly
|
|
|
|
* if I use the raw screenX and screenY.
|
|
|
|
* https://github.com/piroor/treestyletab/issues/302
|
|
|
|
* To prevent such a result, I have to calculate valid base position
|
|
|
|
* for the popup.
|
|
|
|
*/
|
|
|
|
get windowBasePosition() {
|
|
|
|
var screen = ScreenManager.screenForRect(
|
|
|
|
this.window.screenX,
|
|
|
|
this.window.screenY,
|
|
|
|
this.window.outerWidth,
|
|
|
|
this.window.outerHeight
|
|
|
|
);
|
|
|
|
var screenMinX = {},
|
|
|
|
screenMinY = {},
|
|
|
|
screenMaxX = {},
|
|
|
|
screenMaxY = {};
|
|
|
|
screen.GetAvailRect(screenMinX, screenMinY, screenMaxX, screenMaxY);
|
|
|
|
|
|
|
|
return {
|
|
|
|
x: Math.max(this.window.screenX, screenMinX.value),
|
|
|
|
y: Math.max(this.window.screenY, screenMinY.value)
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
setup : function FTM_setup(aBaseTooltip, aTab, aExtraLabels)
|
|
|
|
{
|
|
|
|
this.cancel();
|
|
|
|
|
2012-10-23 12:43:56 -04:00
|
|
|
var delay = utils.getTreePref('tooltip.fullTooltipDelay');
|
2011-11-29 13:40:11 -05:00
|
|
|
if (delay < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._fullTooltipTimer = this.window.setTimeout(function(aSelf) {
|
2013-10-08 12:09:01 -04:00
|
|
|
var basePosition = aSelf.windowBasePosition;
|
2011-11-30 06:22:19 -05:00
|
|
|
var box = aBaseTooltip.boxObject;
|
2013-10-08 12:09:01 -04:00
|
|
|
var x = box.screenX - basePosition.x;
|
|
|
|
var y = box.screenY - basePosition.y;
|
2011-11-30 06:22:19 -05:00
|
|
|
var w = box.width;
|
|
|
|
var h = box.height;
|
2011-11-29 13:40:11 -05:00
|
|
|
aBaseTooltip.hidePopup();
|
|
|
|
|
|
|
|
aSelf.fill(aTab, aExtraLabels);
|
|
|
|
|
2011-11-30 06:22:19 -05:00
|
|
|
var tooltip = aSelf.tabFullTooltip;
|
|
|
|
let (style = tooltip.style) {
|
|
|
|
style.marginLeft = x+'px';
|
|
|
|
style.marginTop = y+'px';
|
2011-11-30 13:02:03 -05:00
|
|
|
style.maxWidth = style.minWidth = w+'px';
|
|
|
|
style.maxHeight = style.minHeight = h+'px';
|
2011-11-30 06:22:19 -05:00
|
|
|
}
|
2013-10-08 12:09:01 -04:00
|
|
|
tooltip.openPopupAtScreen(basePosition.x, basePosition.y, false);
|
2011-11-29 13:40:11 -05:00
|
|
|
}, Math.max(delay, 0), this);
|
|
|
|
},
|
|
|
|
|
|
|
|
cancel : function FTM_destroyFullTooltip()
|
|
|
|
{
|
|
|
|
if (this._fullTooltipTimer) {
|
|
|
|
this.window.clearTimeout(this._fullTooltipTimer);
|
|
|
|
this._fullTooltipTimer = null;
|
|
|
|
}
|
2011-11-29 14:27:08 -05:00
|
|
|
this.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
hide : function FTM_hide()
|
|
|
|
{
|
|
|
|
this.cancelDelayedHide();
|
2011-11-29 13:40:11 -05:00
|
|
|
this.tabFullTooltip.hidePopup();
|
|
|
|
},
|
|
|
|
|
2011-11-29 14:27:08 -05:00
|
|
|
|
|
|
|
hideWithDelay : function FTM_hideWithDelay()
|
|
|
|
{
|
|
|
|
this.cancelDelayedHide();
|
|
|
|
this._delayedHideTimer = this.window.setTimeout(function(aSelf) {
|
|
|
|
aSelf.hide();
|
|
|
|
}, 500, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
cancelDelayedHide : function FTM_cancelDelayedHide()
|
|
|
|
{
|
|
|
|
if (this._delayedHideTimer) {
|
|
|
|
this.window.clearTimeout(this._delayedHideTimer);
|
|
|
|
this._delayedHideTimer = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
|
2011-11-29 13:40:11 -05:00
|
|
|
fill : function FTM_fill(aTab, aExtraLabels)
|
|
|
|
{
|
|
|
|
this.clear();
|
|
|
|
|
2011-12-09 06:10:04 -05:00
|
|
|
var tree = PseudoTreeBuilder.build(aTab);
|
2011-11-30 06:32:57 -05:00
|
|
|
var root = this.document.createElement('arrowscrollbox');
|
|
|
|
root.setAttribute('orient', 'vertical');
|
|
|
|
root.setAttribute('flex', 1);
|
2011-11-29 13:40:11 -05:00
|
|
|
|
|
|
|
if (aExtraLabels) {
|
|
|
|
if (typeof aExtraLabels == 'string')
|
|
|
|
aExtraLabels = [aExtraLabels];
|
2012-02-04 16:31:03 -05:00
|
|
|
for (let i = 0, maxi = aExtraLabels.length; i < maxi; i++)
|
2012-02-04 13:15:38 -05:00
|
|
|
{
|
2012-02-04 16:31:03 -05:00
|
|
|
let label = aExtraLabels[i];
|
2014-03-31 02:10:51 -04:00
|
|
|
label = label.trim();
|
2012-02-04 13:15:38 -05:00
|
|
|
if (!label)
|
|
|
|
continue;
|
2011-11-29 13:40:11 -05:00
|
|
|
root.appendChild(this.document.createElement('description'))
|
2012-02-04 13:15:38 -05:00
|
|
|
.appendChild(this.document.createTextNode(label));
|
|
|
|
}
|
2011-11-29 13:40:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
root.insertBefore(tree, root.firstChild && root.firstChild.nextSibling);
|
|
|
|
|
2011-11-30 06:32:57 -05:00
|
|
|
this.tabFullTooltip.appendChild(root);
|
2011-11-29 13:40:11 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
clear : function FTM_clear()
|
|
|
|
{
|
|
|
|
var range = this.document.createRange();
|
2011-11-30 06:32:57 -05:00
|
|
|
range.selectNodeContents(this.tabFullTooltip);
|
2011-11-29 13:40:11 -05:00
|
|
|
range.deleteContents();
|
|
|
|
range.detach();
|
|
|
|
}
|
2014-04-02 06:25:51 -04:00
|
|
|
});
|