2002-09-30 07:22:13 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<bindings id="buttonBindings"
|
|
|
|
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">
|
|
|
|
|
2003-11-20 08:14:08 +03:00
|
|
|
<binding id="button-base" extends="chrome://global/content/bindings/general.xml#basetext">
|
2002-09-30 07:22:13 +04:00
|
|
|
<implementation implements="nsIDOMXULButtonElement, nsIAccessibleProvider">
|
|
|
|
<property name="accessible">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
|
|
|
|
return accService.createXULButtonAccessible(this);
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="type"
|
|
|
|
onget="return this.getAttribute('type');"
|
|
|
|
onset="this.setAttribute('type', val); return val;"/>
|
|
|
|
|
|
|
|
<property name="dlgType"
|
2006-01-16 01:24:14 +03:00
|
|
|
onget="return this.getAttribute('dlgtype');"
|
|
|
|
onset="this.setAttribute('dlgtype', val); return val;"/>
|
2002-09-30 07:22:13 +04:00
|
|
|
|
|
|
|
<property name="group"
|
|
|
|
onget="return this.getAttribute('group');"
|
|
|
|
onset="this.setAttribute('group', val); return val;"/>
|
|
|
|
|
2005-02-22 20:53:26 +03:00
|
|
|
<property name="open" onget="return this.hasAttribute('open');">
|
|
|
|
<setter><![CDATA[
|
2005-02-23 06:37:24 +03:00
|
|
|
if (this.boxObject instanceof
|
|
|
|
Components.interfaces.nsIMenuBoxObject) {
|
|
|
|
this.boxObject.openMenu(val);
|
|
|
|
} else {
|
|
|
|
// Fall back to just setting the attribute
|
|
|
|
if (val) {
|
|
|
|
this.setAttribute('open', 'true');
|
|
|
|
} else {
|
|
|
|
this.removeAttribute('open');
|
|
|
|
}
|
|
|
|
}
|
2005-02-22 20:53:26 +03:00
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
2002-09-30 07:22:13 +04:00
|
|
|
|
|
|
|
<property name="checked" onget="return this.hasAttribute('checked');">
|
|
|
|
<setter><![CDATA[
|
|
|
|
if (this.type == "checkbox") {
|
|
|
|
this.checkState = val ? 1 : 0;
|
|
|
|
} else if (this.type == "radio" && val) {
|
|
|
|
var sibs = this.parentNode.getElementsByAttribute("group", this.group);
|
|
|
|
for (var i = 0; i < sibs.length; ++i)
|
|
|
|
sibs[i].removeAttribute("checked");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
this.setAttribute("checked", "true");
|
|
|
|
else
|
|
|
|
this.removeAttribute("checked");
|
|
|
|
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="checkState">
|
|
|
|
<getter><![CDATA[
|
|
|
|
var state = this.getAttribute("checkState");
|
|
|
|
if (state == "")
|
|
|
|
return this.checked ? 1 : 0;
|
|
|
|
else
|
|
|
|
return state == "0" ? 0 : (state == "2" ? 2 : 1);
|
|
|
|
]]></getter>
|
|
|
|
<setter><![CDATA[
|
|
|
|
this.setAttribute("checkState", val);
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="autoCheck"
|
|
|
|
onget="return this.getAttribute('autoCheck') == 'true';"
|
|
|
|
onset="this.setAttribute('autoCheck', val); return val;"/>
|
2002-11-11 04:51:50 +03:00
|
|
|
|
|
|
|
<method name ="filterButtons">
|
|
|
|
<parameter name="node"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (node.localName == "button" && node.accessKey &&
|
|
|
|
!node.disabled && !node.collapsed && !node.hidden)
|
|
|
|
return NodeFilter.FILTER_ACCEPT;
|
|
|
|
return NodeFilter.FILTER_SKIP;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="fireAccessKeyButton">
|
|
|
|
<parameter name="aSubtree"/>
|
|
|
|
<parameter name="aAccessKeyLower"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var iterator = aSubtree.ownerDocument.createTreeWalker(aSubtree,
|
|
|
|
NodeFilter.SHOW_ELEMENT,
|
|
|
|
this.filterButtons, false);
|
|
|
|
while (iterator.nextNode()) {
|
|
|
|
var test = iterator.currentNode;
|
|
|
|
if (test.accessKey.toLowerCase() == aAccessKeyLower &&
|
|
|
|
!test.disabled && !test.collapsed && !test.hidden) {
|
|
|
|
test.focus();
|
|
|
|
test.click();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2002-09-30 07:22:13 +04:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="command">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.autoCheck || !this.hasAttribute("autoCheck")) {
|
|
|
|
if (this.type == "checkbox") {
|
|
|
|
this.checked = !this.checked;
|
|
|
|
} else if (this.type == "radio") {
|
|
|
|
this.checked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
2002-11-11 04:51:50 +03:00
|
|
|
<handler event="keypress">
|
|
|
|
<![CDATA[
|
|
|
|
if (event.keyCode == KeyEvent.DOM_VK_UP ||
|
|
|
|
event.keyCode == KeyEvent.DOM_VK_LEFT)
|
|
|
|
return window.document.commandDispatcher.rewindFocus();
|
|
|
|
|
|
|
|
if (event.keyCode == KeyEvent.DOM_VK_DOWN ||
|
|
|
|
event.keyCode == KeyEvent.DOM_VK_RIGHT)
|
|
|
|
return window.document.commandDispatcher.advanceFocus();
|
|
|
|
|
2003-08-17 15:08:25 +04:00
|
|
|
if (event.keyCode || event.charCode <= 32 || event.altKey ||
|
|
|
|
event.ctrlKey || event.metaKey)
|
|
|
|
return; // No printable char pressed, not a potential accesskey
|
2002-11-11 04:51:50 +03:00
|
|
|
|
|
|
|
// Possible accesskey pressed
|
|
|
|
var charPressedLower = String.fromCharCode(event.charCode).toLowerCase();
|
|
|
|
|
|
|
|
// If the accesskey of the current button is pressed, just activate it
|
|
|
|
if (this.accessKey.toLowerCase() == charPressedLower) {
|
|
|
|
this.click();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Search for accesskey in the list of buttons for this doc and each subdoc
|
|
|
|
// Get the buttons for the main document and all sub-frames
|
|
|
|
for (var frameCount = -1; frameCount < window.top.frames.length; frameCount++) {
|
|
|
|
var doc = (frameCount == -1)? window.top.document:
|
|
|
|
window.top.frames[frameCount].document
|
|
|
|
if (this.fireAccessKeyButton(doc.documentElement, charPressedLower))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test anonymous buttons
|
|
|
|
var dlg = window.top.document;
|
|
|
|
var buttonBox = dlg.getAnonymousElementByAttribute(dlg.documentElement,
|
|
|
|
"anonid", "buttons");
|
|
|
|
if (buttonBox)
|
|
|
|
this.fireAccessKeyButton(buttonBox, charPressedLower);
|
|
|
|
]]>
|
|
|
|
</handler>
|
2002-09-30 07:22:13 +04:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="button" display="xul:button"
|
2003-11-20 08:14:08 +03:00
|
|
|
extends="chrome://global/content/bindings/button.xml#button-base">
|
2002-09-30 07:22:13 +04:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/button.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content>
|
|
|
|
<children includes="observes|template|menupopup|tooltip"/>
|
|
|
|
<xul:hbox class="box-inherit button-box" xbl:inherits="align,dir,pack,orient"
|
|
|
|
align="center" pack="center" flex="1">
|
|
|
|
<children>
|
|
|
|
<xul:image class="button-icon" xbl:inherits="src=image"/>
|
2005-03-02 13:53:06 +03:00
|
|
|
<xul:label class="button-text" xbl:inherits="value=label,accesskey,crop"/>
|
2002-09-30 07:22:13 +04:00
|
|
|
</children>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="menu" display="xul:menu"
|
2003-11-20 08:14:08 +03:00
|
|
|
extends="chrome://global/content/bindings/button.xml#button">
|
2002-09-30 07:22:13 +04:00
|
|
|
<content>
|
|
|
|
<children includes="observes|template|menupopup|tooltip"/>
|
|
|
|
<xul:hbox class="box-inherit button-box" xbl:inherits="align,dir,pack,orient"
|
|
|
|
align="center" pack="center" flex="1">
|
|
|
|
<children>
|
|
|
|
<xul:image class="button-icon" xbl:inherits="src=image"/>
|
|
|
|
<xul:label class="button-text" xbl:inherits="value=label,accesskey,crop" flex="1"/>
|
|
|
|
<xul:dropmarker class="button-menu-dropmarker" xbl:inherits="open,disabled"/>
|
|
|
|
</children>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
2005-04-01 19:48:44 +04:00
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="keypress" keycode="VK_RETURN" action="this.open = true;"/>
|
|
|
|
<handler event="keypress" key=" " action="this.open = true;"/>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
2002-09-30 07:22:13 +04:00
|
|
|
|
|
|
|
<binding id="menu-button-base"
|
2003-11-20 08:14:08 +03:00
|
|
|
extends="chrome://global/content/bindings/button.xml#button-base">
|
2002-09-30 07:22:13 +04:00
|
|
|
<implementation>
|
|
|
|
<constructor>
|
|
|
|
this.init();
|
|
|
|
</constructor>
|
|
|
|
|
|
|
|
<method name="init">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var btn = document.getAnonymousElementByAttribute(this, "anonid", "button");
|
|
|
|
if (!btn)
|
|
|
|
throw "XBL binding for <button type=\"menu-button\"/> binding must contain an element with anonid=\"button\"";
|
|
|
|
|
|
|
|
btn._menubuttonParent = this;
|
|
|
|
btn.addEventListener("mouseover", function() {
|
|
|
|
if (!this.disabled)
|
|
|
|
this._menubuttonParent.buttonover = true;
|
|
|
|
}, true);
|
|
|
|
btn.addEventListener("mouseout", function() {
|
|
|
|
this._menubuttonParent.buttonover = false;
|
|
|
|
}, true);
|
|
|
|
btn.addEventListener("mousedown", function() {
|
|
|
|
if (!this.disabled) {
|
|
|
|
this._menubuttonParent.buttondown = true;
|
|
|
|
this._menubuttonParent._captureMouseUp();
|
|
|
|
}
|
|
|
|
}, true);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="buttonover" onget="return this.getAttribute('buttonover');">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
var v = val || val == "true";
|
|
|
|
if (!v && this.buttondown) {
|
|
|
|
this.buttondown = false;
|
|
|
|
this._pendingActive = true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (this._pendingActive) {
|
|
|
|
this.buttondown = true;
|
|
|
|
this._pendingActive = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v)
|
|
|
|
this.setAttribute("buttonover", "true");
|
|
|
|
else
|
|
|
|
this.removeAttribute("buttonover");
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="buttondown" onget="return this.getAttribute('buttondown') == 'true';">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (val || val == "true")
|
|
|
|
this.setAttribute("buttondown", "true");
|
|
|
|
else
|
|
|
|
this.removeAttribute("buttondown");
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<field name="_pendingActive">false</field>
|
|
|
|
|
|
|
|
<method name="_captureMouseUp">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
document.__ButtonMenuMouseDown__ = this;
|
|
|
|
document.addEventListener("mouseup", this._onGlobalMouseUp, true);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_onGlobalMouseUp" readonly="true">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var btn = document.__ButtonMenuMouseDown__;
|
|
|
|
btn._onMouseReallyUp();
|
|
|
|
document.removeEventListener("mouseup", btn._onGlobalMouseUp, true);
|
|
|
|
delete document.__ButtonMenuMouseDown__;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_onMouseReallyUp">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this._pendingActive = false;
|
|
|
|
this.buttondown = false;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="menu-button" display="xul:menu"
|
2003-11-20 08:14:08 +03:00
|
|
|
extends="chrome://global/content/bindings/button.xml#menu-button-base">
|
2002-09-30 07:22:13 +04:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/button.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content>
|
|
|
|
<children includes="observes|template|menupopup|tooltip"/>
|
|
|
|
<xul:button class="box-inherit button-menubutton-button"
|
|
|
|
anonid="button" flex="1" allowevents="true"
|
|
|
|
xbl:inherits="disabled,crop,image,label,accessKey,command,
|
|
|
|
buttonover,buttondown,align,dir,pack,orient">
|
|
|
|
<children/>
|
|
|
|
</xul:button>
|
|
|
|
<xul:dropmarker class="button-menubutton-dropmarker" xbl:inherits="open,disabled"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="button-image" display="xul:button"
|
2003-11-20 08:14:08 +03:00
|
|
|
extends="chrome://global/content/bindings/button.xml#button">
|
2002-09-30 07:22:13 +04:00
|
|
|
<content>
|
|
|
|
<xul:image class="button-image-icon" xbl:inherits="src=image"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2006-01-16 01:24:14 +03:00
|
|
|
</bindings>
|