2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<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">
|
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"/>
|
|
|
|
|
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"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var popupBox = this.popupBoxObject;
|
|
|
|
if (popupBox)
|
|
|
|
popupBox.openPopup(aAnchorElement, aPosition, aX, aY,
|
|
|
|
aIsContextMenu, aAttributesOverride);
|
|
|
|
} catch(e) {}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="openPopupAtScreen">
|
|
|
|
<parameter name="aX"/>
|
|
|
|
<parameter name="aY"/>
|
|
|
|
<parameter name="aIsContextMenu"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var popupBox = this.popupBoxObject;
|
|
|
|
if (popupBox)
|
|
|
|
popupBox.openPopupAtScreen(aX, aY, aIsContextMenu);
|
|
|
|
} 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 {
|
|
|
|
menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
|
|
|
|
} catch(e) {}
|
|
|
|
if (menuBox)
|
|
|
|
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 {
|
|
|
|
menuBox = this.parentNode.boxObject.QueryInterface(Components.interfaces.nsIMenuBoxObject);
|
|
|
|
} catch(e) {}
|
|
|
|
if (menuBox)
|
|
|
|
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>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
</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>
|
|
|
|
<xul:arrowscrollbox class="popup-internal-box" flex="1" orient="vertical">
|
|
|
|
<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>
|
|
|
|
</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>
|
|
|
|
|
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;"/>
|
|
|
|
</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>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|