2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
2012-05-21 04:12:37 -07:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<bindings id="popupBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
|
|
|
|
<binding id="popup-base">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/popup.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2008-01-23 15:49:10 -08:00
|
|
|
<implementation implements="nsIDOMXULPopupElement">
|
2010-07-27 06:38:04 -07:00
|
|
|
<property name="label" onget="return this.getAttribute('label');"
|
|
|
|
onset="this.setAttribute('label', val); return val;"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="position" onget="return this.getAttribute('position');"
|
|
|
|
onset="this.setAttribute('position', val); return val;"/>
|
|
|
|
<property name="popupBoxObject">
|
|
|
|
<getter>
|
|
|
|
return this.boxObject.QueryInterface(Components.interfaces.nsIPopupBoxObject);
|
|
|
|
</getter>
|
|
|
|
</property>
|
2007-07-04 08:49:38 -07:00
|
|
|
|
2007-08-15 16:52:47 -07:00
|
|
|
<property name="state" readonly="true"
|
|
|
|
onget="return this.popupBoxObject.popupState"/>
|
|
|
|
|
2010-08-09 09:17:19 -07:00
|
|
|
<property name="triggerNode" readonly="true"
|
|
|
|
onget="return this.popupBoxObject.triggerNode"/>
|
|
|
|
|
2010-09-21 10:53:01 -07:00
|
|
|
<property name="anchorNode" readonly="true"
|
|
|
|
onget="return this.popupBoxObject.anchorNode"/>
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
<method name="openPopup">
|
|
|
|
<parameter name="aAnchorElement"/>
|
|
|
|
<parameter name="aPosition"/>
|
|
|
|
<parameter name="aX"/>
|
|
|
|
<parameter name="aY"/>
|
|
|
|
<parameter name="aIsContextMenu"/>
|
|
|
|
<parameter name="aAttributesOverride"/>
|
2010-08-09 09:17:19 -07:00
|
|
|
<parameter name="aTriggerEvent"/>
|
2007-07-04 08:49:38 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var popupBox = this.popupBoxObject;
|
|
|
|
if (popupBox)
|
|
|
|
popupBox.openPopup(aAnchorElement, aPosition, aX, aY,
|
2010-08-09 09:17:19 -07:00
|
|
|
aIsContextMenu, aAttributesOverride, aTriggerEvent);
|
2007-07-04 08:49:38 -07:00
|
|
|
} catch(e) {}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="openPopupAtScreen">
|
|
|
|
<parameter name="aX"/>
|
|
|
|
<parameter name="aY"/>
|
|
|
|
<parameter name="aIsContextMenu"/>
|
2010-08-09 09:17:19 -07:00
|
|
|
<parameter name="aTriggerEvent"/>
|
2007-07-04 08:49:38 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var popupBox = this.popupBoxObject;
|
|
|
|
if (popupBox)
|
2010-08-09 09:17:19 -07:00
|
|
|
popupBox.openPopupAtScreen(aX, aY, aIsContextMenu, aTriggerEvent);
|
2007-07-04 08:49:38 -07:00
|
|
|
} catch(e) {}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<method name="showPopup">
|
|
|
|
<parameter name="element"/>
|
|
|
|
<parameter name="xpos"/>
|
|
|
|
<parameter name="ypos"/>
|
|
|
|
<parameter name="popuptype"/>
|
|
|
|
<parameter name="anchoralignment"/>
|
|
|
|
<parameter name="popupalignment"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var popupBox = null;
|
|
|
|
var menuBox = null;
|
|
|
|
try {
|
|
|
|
popupBox = this.popupBoxObject;
|
|
|
|
} catch(e) {}
|
|
|
|
try {
|
2011-02-08 11:18:36 -08:00
|
|
|
menuBox = this.parentNode.boxObject;
|
2007-03-22 10:30:00 -07:00
|
|
|
} catch(e) {}
|
2011-02-08 11:18:36 -08:00
|
|
|
if (menuBox instanceof Components.interfaces.nsIMenuBoxObject)
|
2007-03-22 10:30:00 -07:00
|
|
|
menuBox.openMenu(true);
|
|
|
|
else if (popupBox)
|
|
|
|
popupBox.showPopup(element, this, xpos, ypos, popuptype, anchoralignment, popupalignment);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="hidePopup">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var popupBox = null;
|
|
|
|
var menuBox = null;
|
|
|
|
try {
|
|
|
|
popupBox = this.boxObject.QueryInterface(Components.interfaces.nsIPopupBoxObject);
|
|
|
|
} catch(e) {}
|
|
|
|
try {
|
2011-02-08 11:18:36 -08:00
|
|
|
menuBox = this.parentNode.boxObject;
|
2007-03-22 10:30:00 -07:00
|
|
|
} catch(e) {}
|
2011-02-08 11:18:36 -08:00
|
|
|
if (menuBox instanceof Components.interfaces.nsIMenuBoxObject)
|
2007-03-22 10:30:00 -07:00
|
|
|
menuBox.openMenu(false);
|
|
|
|
else if (popupBox)
|
|
|
|
popupBox.hidePopup();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="autoPosition">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.popupBoxObject.autoPosition;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.popupBoxObject.autoPosition = val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
2013-04-18 17:47:27 -07:00
|
|
|
|
|
|
|
<property name="alignmentPosition" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.popupBoxObject.alignmentPosition;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
2013-05-08 15:59:03 -07:00
|
|
|
|
|
|
|
<property name="alignmentOffset" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.popupBoxObject.alignmentOffset;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<method name="enableKeyboardNavigator">
|
|
|
|
<parameter name="aEnableKeyboardNavigator"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.enableKeyboardNavigator(aEnableKeyboardNavigator);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="enableRollup">
|
|
|
|
<parameter name="aEnableRollup"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.enableRollup(aEnableRollup);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="sizeTo">
|
|
|
|
<parameter name="aWidth"/>
|
|
|
|
<parameter name="aHeight"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.sizeTo(aWidth, aHeight);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="moveTo">
|
|
|
|
<parameter name="aLeft"/>
|
|
|
|
<parameter name="aTop"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.moveTo(aLeft, aTop);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2011-06-03 12:38:23 -07:00
|
|
|
|
2012-10-23 05:11:13 -07:00
|
|
|
<method name="moveToAnchor">
|
|
|
|
<parameter name="aAnchorElement"/>
|
|
|
|
<parameter name="aPosition"/>
|
|
|
|
<parameter name="aX"/>
|
|
|
|
<parameter name="aY"/>
|
|
|
|
<parameter name="aAttributesOverride"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.moveToAnchor(aAnchorElement, aPosition, aX, aY, aAttributesOverride);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2011-06-03 12:38:23 -07:00
|
|
|
<method name="getOuterScreenRect">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.popupBoxObject.getOuterScreenRect();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="popup"
|
2008-01-23 15:49:10 -08:00
|
|
|
extends="chrome://global/content/bindings/popup.xml#popup-base">
|
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
<content>
|
2009-12-11 14:02:13 -08:00
|
|
|
<xul:arrowscrollbox class="popup-internal-box" flex="1" orient="vertical"
|
|
|
|
smoothscroll="false">
|
2007-07-04 08:49:38 -07:00
|
|
|
<children/>
|
|
|
|
</xul:arrowscrollbox>
|
|
|
|
</content>
|
|
|
|
|
2008-01-23 15:49:10 -08:00
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULMenupopup;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
</implementation>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<handlers>
|
|
|
|
<handler event="popupshowing" phase="target">
|
|
|
|
<![CDATA[
|
|
|
|
var array = [];
|
|
|
|
var width = 0;
|
|
|
|
for (var menuitem = this.firstChild; menuitem; menuitem = menuitem.nextSibling) {
|
|
|
|
if (menuitem.localName == "menuitem" && menuitem.hasAttribute("acceltext")) {
|
|
|
|
var accel = document.getAnonymousElementByAttribute(menuitem, "anonid", "accel");
|
|
|
|
if (accel && accel.boxObject) {
|
|
|
|
array.push(accel);
|
|
|
|
if (accel.boxObject.width > width)
|
|
|
|
width = accel.boxObject.width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var i = 0; i < array.length; i++)
|
|
|
|
array[i].width = width;
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2008-01-23 15:49:10 -08:00
|
|
|
<binding id="panel"
|
|
|
|
extends="chrome://global/content/bindings/popup.xml#popup-base">
|
|
|
|
<!-- This separate binding for dialog-like panels - not menu, list or autocomplete popups
|
|
|
|
exposes the popup as an alert or a pane, depending on whether it is always intended
|
|
|
|
to get keyboard navigation when it opens -->
|
|
|
|
<implementation implements="nsIDOMXULPopupElement, nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return (this.getAttribute("noautofocus") == "true") ?
|
|
|
|
Components.interfaces.nsIAccessibleProvider.XULAlert :
|
|
|
|
Components.interfaces.nsIAccessibleProvider.XULPane;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
<field name="_prevFocus">0</field>
|
2011-06-03 12:38:24 -07:00
|
|
|
<field name="_dragBindingAlive">true</field>
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.getAttribute("backdrag") == "true" && !this._draggableStarted) {
|
|
|
|
this._draggableStarted = true;
|
|
|
|
try {
|
|
|
|
let tmp = {};
|
|
|
|
Components.utils.import("resource://gre/modules/WindowDraggingUtils.jsm", tmp);
|
2012-02-02 00:28:04 -08:00
|
|
|
let draghandle = new tmp.WindowDraggingElement(this);
|
2011-06-03 12:38:24 -07:00
|
|
|
draghandle.mouseDownCheck = function () this._dragBindingAlive;
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</constructor>
|
2008-01-23 15:49:10 -08:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="popupshowing"><![CDATA[
|
|
|
|
// Capture the previous focus before has a chance to get set inside the panel
|
|
|
|
try {
|
|
|
|
this._prevFocus = document.commandDispatcher.focusedElement;
|
|
|
|
if (!this._prevFocus) // Content window has focus
|
|
|
|
this._prevFocus = document.commandDispatcher.focusedWindow;
|
2008-10-10 04:47:17 -07:00
|
|
|
} catch (ex) {
|
|
|
|
this._prevFocus = document.activeElement;
|
|
|
|
}
|
|
|
|
]]></handler>
|
2008-01-23 15:49:10 -08:00
|
|
|
<handler event="popupshown"><![CDATA[
|
|
|
|
// Fire event for accessibility APIs
|
|
|
|
var alertEvent = document.createEvent("Events");
|
|
|
|
alertEvent.initEvent("AlertActive", true, true);
|
|
|
|
this.dispatchEvent(alertEvent);
|
|
|
|
]]></handler>
|
|
|
|
<handler event="popuphiding"><![CDATA[
|
2008-10-10 04:47:17 -07:00
|
|
|
try {
|
|
|
|
this._currentFocus = document.commandDispatcher.focusedElement;
|
|
|
|
} catch (e) {
|
|
|
|
this._currentFocus = document.activeElement;
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
<handler event="popuphidden"><![CDATA[
|
|
|
|
var currentFocus = this._currentFocus;
|
|
|
|
var prevFocus = this._prevFocus;
|
|
|
|
this._currentFocus = null;
|
|
|
|
this._prevFocus = null;
|
|
|
|
if (prevFocus && currentFocus && this.getAttribute("norestorefocus") != "true") {
|
|
|
|
// Try to restore focus
|
2008-01-23 15:49:10 -08:00
|
|
|
try {
|
|
|
|
if (document.commandDispatcher.focusedWindow != window)
|
|
|
|
return; // Focus has already been set to a window outside of this panel
|
|
|
|
} catch(ex) {}
|
2008-10-10 04:47:17 -07:00
|
|
|
while (currentFocus) {
|
|
|
|
if (currentFocus == this) {
|
2008-01-23 15:49:10 -08:00
|
|
|
// Focus was set on an element inside this panel,
|
|
|
|
// so we need to move it back to where it was previously
|
2009-06-15 11:38:25 -07:00
|
|
|
try {
|
|
|
|
let fm = Components.classes["@mozilla.org/focus-manager;1"]
|
|
|
|
.getService(Components.interfaces.nsIFocusManager);
|
|
|
|
fm.setFocus(prevFocus, fm.FLAG_NOSCROLL);
|
|
|
|
} catch(e) {
|
|
|
|
prevFocus.focus();
|
|
|
|
}
|
2008-01-23 15:49:10 -08:00
|
|
|
return;
|
|
|
|
}
|
2008-10-10 04:47:17 -07:00
|
|
|
currentFocus = currentFocus.parentNode;
|
2008-01-23 15:49:10 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2010-10-13 12:41:37 -07:00
|
|
|
<binding id="arrowpanel" extends="chrome://global/content/bindings/popup.xml#panel">
|
2010-12-05 14:10:36 -08:00
|
|
|
<content flip="both" side="top" position="bottomcenter topleft">
|
2012-06-24 21:03:57 -07:00
|
|
|
<xul:box anonid="container" class="panel-arrowcontainer" flex="1"
|
|
|
|
xbl:inherits="side,panelopen">
|
2010-10-13 12:41:37 -07:00
|
|
|
<xul:box anonid="arrowbox" class="panel-arrowbox">
|
2013-04-18 17:47:27 -07:00
|
|
|
<xul:image anonid="arrow" class="panel-arrow" xbl:inherits="side"/>
|
2010-10-13 12:41:37 -07:00
|
|
|
</xul:box>
|
2012-06-19 07:07:24 -07:00
|
|
|
<xul:box class="panel-arrowcontent" xbl:inherits="side,align,dir,orient,pack" flex="1">
|
|
|
|
<children/>
|
|
|
|
<xul:box class="panel-inner-arrowcontentfooter" xbl:inherits="footertype" hidden="true"/>
|
2010-10-13 12:41:37 -07:00
|
|
|
</xul:box>
|
|
|
|
</xul:box>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
2011-09-30 12:47:13 -07:00
|
|
|
<field name="_fadeTimer">null</field>
|
2012-12-20 17:26:32 -08:00
|
|
|
<method name="sizeTo">
|
|
|
|
<parameter name="aWidth"/>
|
|
|
|
<parameter name="aHeight"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.sizeTo(aWidth, aHeight);
|
|
|
|
if (this.state == "open")
|
|
|
|
this.adjustArrowPosition();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="moveTo">
|
|
|
|
<parameter name="aLeft"/>
|
|
|
|
<parameter name="aTop"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.moveTo(aLeft, aTop);
|
|
|
|
if (this.state == "open")
|
|
|
|
this.adjustArrowPosition();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="moveToAnchor">
|
|
|
|
<parameter name="aAnchorElement"/>
|
|
|
|
<parameter name="aPosition"/>
|
|
|
|
<parameter name="aX"/>
|
|
|
|
<parameter name="aY"/>
|
|
|
|
<parameter name="aAttributesOverride"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.popupBoxObject.moveToAnchor(aAnchorElement, aPosition, aX, aY, aAttributesOverride);
|
|
|
|
if (this.state == "open")
|
|
|
|
this.adjustArrowPosition();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="adjustArrowPosition">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2010-10-13 12:41:37 -07:00
|
|
|
var arrow = document.getAnonymousElementByAttribute(this, "anonid", "arrow");
|
|
|
|
|
|
|
|
var anchor = this.anchorNode;
|
|
|
|
if (!anchor) {
|
|
|
|
arrow.hidden = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-18 17:47:27 -07:00
|
|
|
var container = document.getAnonymousElementByAttribute(this, "anonid", "container");
|
|
|
|
var arrowbox = document.getAnonymousElementByAttribute(this, "anonid", "arrowbox");
|
2012-12-24 11:47:34 -08:00
|
|
|
|
2013-05-08 15:59:03 -07:00
|
|
|
// if this panel has a "sliding" arrow, we may have previously set margins...
|
|
|
|
arrowbox.style.removeProperty("margin");
|
|
|
|
|
2013-04-18 17:47:27 -07:00
|
|
|
var position = this.alignmentPosition;
|
|
|
|
if (position.indexOf("start_") == 0 || position.indexOf("end_") == 0) {
|
|
|
|
container.orient = "";
|
|
|
|
arrowbox.orient = "vertical";
|
2013-05-08 15:59:03 -07:00
|
|
|
if (position.indexOf("_after") > 0) {
|
|
|
|
arrowbox.pack = "end";
|
|
|
|
arrowbox.style.marginBottom = this.alignmentOffset + "px";
|
|
|
|
} else {
|
|
|
|
arrowbox.pack = "start";
|
|
|
|
arrowbox.style.marginTop = this.alignmentOffset + "px";
|
|
|
|
}
|
2012-12-24 11:47:34 -08:00
|
|
|
|
2013-04-18 17:47:27 -07:00
|
|
|
// The assigned side stays the same regardless of direction.
|
|
|
|
var isRTL = (window.getComputedStyle(this).direction == "rtl");
|
2012-12-24 11:47:34 -08:00
|
|
|
|
2013-04-18 17:47:27 -07:00
|
|
|
if (position.indexOf("start_") == 0) {
|
|
|
|
container.dir = "reverse";
|
|
|
|
this.setAttribute("side", isRTL ? "left" : "right");
|
2012-12-24 11:47:34 -08:00
|
|
|
}
|
|
|
|
else {
|
2013-04-18 17:47:27 -07:00
|
|
|
container.dir = "";
|
|
|
|
this.setAttribute("side", isRTL ? "right" : "left");
|
2012-12-24 11:47:34 -08:00
|
|
|
}
|
|
|
|
}
|
2013-04-18 17:47:27 -07:00
|
|
|
else if (position.indexOf("before_") == 0 || position.indexOf("after_") == 0) {
|
|
|
|
container.orient = "vertical";
|
|
|
|
arrowbox.orient = "";
|
2013-05-08 15:59:03 -07:00
|
|
|
if (position.indexOf("_end") > 0) {
|
|
|
|
arrowbox.pack = "end";
|
|
|
|
arrowbox.style.marginRight = this.alignmentOffset + "px";
|
|
|
|
} else {
|
|
|
|
arrowbox.pack = "start";
|
|
|
|
arrowbox.style.marginLeft = this.alignmentOffset + "px";
|
|
|
|
}
|
2013-04-18 17:47:27 -07:00
|
|
|
|
|
|
|
if (position.indexOf("before_") == 0) {
|
|
|
|
container.dir = "reverse";
|
|
|
|
this.setAttribute("side", "bottom");
|
2010-10-13 12:41:37 -07:00
|
|
|
}
|
|
|
|
else {
|
2013-04-18 17:47:27 -07:00
|
|
|
container.dir = "";
|
|
|
|
this.setAttribute("side", "top");
|
2010-10-13 12:41:37 -07:00
|
|
|
}
|
|
|
|
}
|
2013-04-18 17:47:27 -07:00
|
|
|
|
|
|
|
arrow.hidden = false;
|
2012-12-20 17:26:32 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
<handlers>
|
|
|
|
<handler event="popupshowing" phase="target">
|
|
|
|
<![CDATA[
|
|
|
|
this.adjustArrowPosition();
|
2010-10-13 12:41:37 -07:00
|
|
|
// set fading
|
|
|
|
var fade = this.getAttribute("fade");
|
|
|
|
var fadeDelay = (fade == "fast") ? 1 : fade == "slow" ? 4000 : 0;
|
|
|
|
if (fadeDelay) {
|
|
|
|
this._fadeTimer = setTimeout(function (self) {
|
|
|
|
self.style.opacity = 0.2;
|
|
|
|
}, fadeDelay, this);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
2010-12-05 14:10:36 -08:00
|
|
|
<handler event="popuphiding" phase="target">
|
2010-10-13 12:41:37 -07:00
|
|
|
clearTimeout(this._fadeTimer);
|
|
|
|
this.style.removeProperty("opacity");
|
|
|
|
</handler>
|
2010-12-05 14:10:36 -08:00
|
|
|
<handler event="transitionend" phase="target">
|
2010-10-13 12:41:37 -07:00
|
|
|
<![CDATA[
|
2012-06-24 21:03:57 -07:00
|
|
|
if (event.propertyName == "opacity" &&
|
|
|
|
event.originalTarget == this) {
|
2010-10-13 12:41:37 -07:00
|
|
|
this.hidePopup();
|
|
|
|
this.style.removeProperty("opacity");
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
2012-06-24 21:03:57 -07:00
|
|
|
<handler event="popupshown" phase="target">
|
|
|
|
this.setAttribute("panelopen", "true");
|
|
|
|
</handler>
|
2012-07-13 07:28:21 -07:00
|
|
|
<handler event="popuphidden" phase="target">
|
2012-06-24 21:03:57 -07:00
|
|
|
this.removeAttribute("panelopen");
|
2012-07-13 07:28:21 -07:00
|
|
|
</handler>
|
2010-10-13 12:41:37 -07:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2008-10-20 08:33:49 -07:00
|
|
|
<binding id="tooltip" extends="chrome://global/content/bindings/popup.xml#popup-base">
|
2007-03-22 10:30:00 -07:00
|
|
|
<content>
|
|
|
|
<children>
|
2007-07-05 12:11:36 -07:00
|
|
|
<xul:label class="tooltip-label" xbl:inherits="xbl:text=label" flex="1"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</children>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIAccessibleProvider">
|
|
|
|
<property name="accessibleType" readonly="true">
|
|
|
|
<getter>
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULTooltip;
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<field name="_mouseOutCount">0</field>
|
|
|
|
<field name="_isMouseOver">false</field>
|
|
|
|
|
|
|
|
<property name="label"
|
|
|
|
onget="return this.getAttribute('label');"
|
|
|
|
onset="this.setAttribute('label', val); return val;"/>
|
2013-03-21 05:58:07 -07:00
|
|
|
|
|
|
|
<property name="page" onset="if (val) this.setAttribute('page', 'true');
|
|
|
|
else this.removeAttribute('page');
|
|
|
|
return val;"
|
|
|
|
onget="return this.getAttribute('page') == 'true';"/>
|
|
|
|
|
|
|
|
<!-- Given the supplied element within a page, set the tooltip's text to the text
|
|
|
|
for that element. Returns true if text was assigned, and false if the no text
|
|
|
|
is set, which normally would be used to cancel tooltip display.
|
|
|
|
|
|
|
|
Note that DefaultTooltipTextProvider::GetNodeText() from nsDocShellTreeOwner.cpp
|
|
|
|
also performs the same function, but for embedded clients that don't use a XUL/JS
|
|
|
|
layer. These two should be kept synchronized.
|
|
|
|
-->
|
|
|
|
<method name="fillInPageTooltip">
|
|
|
|
<parameter name="tipElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Don't show the tooltip if the tooltip node is a document or disconnected.
|
|
|
|
if (!tipElement || !tipElement.ownerDocument ||
|
|
|
|
(tipElement.ownerDocument.compareDocumentPosition(tipElement) & document.DOCUMENT_POSITION_DISCONNECTED)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var defView = tipElement.ownerDocument.defaultView;
|
|
|
|
// XXX Work around bug 350679:
|
|
|
|
// "Tooltips can be fired in documents with no view".
|
|
|
|
if (!defView)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
const XLinkNS = "http://www.w3.org/1999/xlink";
|
|
|
|
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
|
|
|
var titleText = null;
|
|
|
|
var XLinkTitleText = null;
|
|
|
|
var SVGTitleText = null;
|
|
|
|
var lookingForSVGTitle = true;
|
|
|
|
var direction = tipElement.ownerDocument.dir;
|
|
|
|
|
|
|
|
// If the element is invalid per HTML5 Forms specifications and has no title,
|
|
|
|
// show the constraint validation error message.
|
|
|
|
if ((tipElement instanceof HTMLInputElement ||
|
|
|
|
tipElement instanceof HTMLTextAreaElement ||
|
|
|
|
tipElement instanceof HTMLSelectElement ||
|
|
|
|
tipElement instanceof HTMLButtonElement) &&
|
|
|
|
!tipElement.hasAttribute('title') &&
|
|
|
|
(!tipElement.form || !tipElement.form.noValidate)) {
|
|
|
|
// If the element is barred from constraint validation or valid,
|
|
|
|
// the validation message will be the empty string.
|
|
|
|
titleText = tipElement.validationMessage || null;
|
|
|
|
}
|
|
|
|
|
2013-03-27 04:38:07 -07:00
|
|
|
// If the element is an <input type='file'> without a title, we should show
|
|
|
|
// the current file selection.
|
|
|
|
if (!titleText &&
|
|
|
|
tipElement instanceof HTMLInputElement &&
|
|
|
|
tipElement.type == 'file' &&
|
|
|
|
!tipElement.hasAttribute('title')) {
|
|
|
|
let files = tipElement.files;
|
|
|
|
|
|
|
|
if (files.length == 0) {
|
2013-03-28 11:12:24 -07:00
|
|
|
try {
|
|
|
|
var bundle = Components.classes['@mozilla.org/intl/stringbundle;1']
|
|
|
|
.getService(Components.interfaces.nsIStringBundleService)
|
|
|
|
.createBundle("chrome://global/locale/layout/HtmlForm.properties");
|
|
|
|
if (tipElement.multiple) {
|
|
|
|
titleText = bundle.GetStringFromName("NoFilesSelected");
|
|
|
|
} else {
|
|
|
|
titleText = bundle.GetStringFromName("NoFileSelected");
|
|
|
|
}
|
|
|
|
} catch(e) {}
|
2013-03-27 04:38:07 -07:00
|
|
|
} else {
|
|
|
|
titleText = files[0].name;
|
|
|
|
for (let i=1; i<files.length; ++i) {
|
|
|
|
titleText += "\n" + files[i].name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-21 05:58:07 -07:00
|
|
|
while ((titleText == null) && (XLinkTitleText == null) &&
|
|
|
|
(SVGTitleText == null) && tipElement) {
|
|
|
|
if (tipElement.nodeType == Node.ELEMENT_NODE &&
|
|
|
|
tipElement.namespaceURI != XULNS) {
|
|
|
|
titleText = tipElement.getAttribute("title");
|
|
|
|
|
|
|
|
if ((tipElement instanceof HTMLAnchorElement ||
|
|
|
|
tipElement instanceof HTMLAreaElement ||
|
|
|
|
tipElement instanceof HTMLLinkElement ||
|
|
|
|
tipElement instanceof SVGAElement) && tipElement.href) {
|
|
|
|
XLinkTitleText = tipElement.getAttributeNS(XLinkNS, "title");
|
|
|
|
}
|
|
|
|
if (lookingForSVGTitle &&
|
|
|
|
(!(tipElement instanceof SVGElement) ||
|
|
|
|
tipElement.parentNode.nodeType == Node.DOCUMENT_NODE)) {
|
|
|
|
lookingForSVGTitle = false;
|
|
|
|
}
|
|
|
|
if (lookingForSVGTitle) {
|
|
|
|
for (let childNode of tipElement.childNodes) {
|
|
|
|
if (childNode instanceof SVGTitleElement) {
|
|
|
|
SVGTitleText = childNode.textContent;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
direction = defView.getComputedStyle(tipElement, "")
|
|
|
|
.getPropertyValue("direction");
|
|
|
|
}
|
|
|
|
|
|
|
|
tipElement = tipElement.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.style.direction = direction;
|
|
|
|
|
|
|
|
return [titleText, XLinkTitleText, SVGTitleText].some(function (t) {
|
|
|
|
if (t && /\S/.test(t)) {
|
|
|
|
// Make CRLF and CR render one line break each.
|
|
|
|
this.label = t.replace(/\r\n?/g, '\n');
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}, this);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="mouseover"><![CDATA[
|
|
|
|
var rel = event.relatedTarget;
|
|
|
|
//dump("ENTERING " + (rel ? rel.localName : "null") + "\n");
|
|
|
|
if (!rel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// find out if the node we entered from is one of our anonymous children
|
|
|
|
while (rel) {
|
|
|
|
if (rel == this)
|
|
|
|
break;
|
|
|
|
rel = rel.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the exited node is not a descendant of ours, we are entering for the first time
|
|
|
|
if (rel != this)
|
|
|
|
this._isMouseOver = true;
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="mouseout"><![CDATA[
|
|
|
|
var rel = event.relatedTarget;
|
|
|
|
//dump("LEAVING " + (rel ? rel.localName : "null") + "\n");
|
|
|
|
|
|
|
|
// relatedTarget is null when the titletip is first shown: a mouseout event fires
|
|
|
|
// because the mouse is exiting the main window and entering the titletip "window".
|
|
|
|
// relatedTarget is also null when the mouse exits the main window completely,
|
|
|
|
// so count how many times relatedTarget was null after titletip is first shown
|
|
|
|
// and hide popup the 2nd time
|
|
|
|
if (!rel) {
|
|
|
|
++this._mouseOutCount;
|
|
|
|
if (this._mouseOutCount > 1)
|
|
|
|
this.hidePopup();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// find out if the node we are entering is one of our anonymous children
|
|
|
|
while (rel) {
|
|
|
|
if (rel == this)
|
|
|
|
break;
|
|
|
|
rel = rel.parentNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the entered node is not a descendant of ours, hide the tooltip
|
|
|
|
if (rel != this && this._isMouseOver) {
|
|
|
|
this.hidePopup();
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
2013-03-21 05:58:07 -07:00
|
|
|
<handler event="popupshowing"><![CDATA[
|
|
|
|
if (this.page && !this.fillInPageTooltip(this.triggerNode)) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<handler event="popuphiding"><![CDATA[
|
|
|
|
this._isMouseOver = false;
|
|
|
|
this._mouseOutCount = 0;
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="popup-scrollbars" extends="chrome://global/content/bindings/popup.xml#popup">
|
|
|
|
<content>
|
|
|
|
<xul:hbox class="popup-internal-box" flex="1" orient="vertical" style="overflow: auto;">
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|