mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-06 09:05:45 +00:00
69 lines
2.0 KiB
XML
69 lines
2.0 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<bindings id="checkboxBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<binding id="checkbox" display="xul:button">
|
|
<implementation>
|
|
<property name="checked">
|
|
<getter>
|
|
var image = this.getElementByAttribute("cbattr", "image");
|
|
if (image) {
|
|
return image.hasAttribute("checked");
|
|
}
|
|
return false;
|
|
</getter>
|
|
<setter>
|
|
var image = this.getElementByAttribute("cbattr", "image");
|
|
if (image) {
|
|
if (val)
|
|
image.setAttribute("checked", "true");
|
|
else image.removeAttribute("checked");
|
|
}
|
|
</setter>
|
|
</property>
|
|
|
|
<!-- Internal Implementation Methods -->
|
|
<method name="getElementByAttribute">
|
|
<parameter name="aAttributeName"/>
|
|
<parameter name="aAttributeValue"/>
|
|
<body>
|
|
<![CDATA[
|
|
var anonymousNodes = document.getAnonymousNodes(this);
|
|
for (var i = 0; i < anonymousNodes.length; ++i)
|
|
return this.recursiveAttributeSearch(anonymousNodes[i], aAttributeName, aAttributeValue);
|
|
return null;
|
|
]]>
|
|
</body>
|
|
</method>
|
|
<method name="recursiveAttributeSearch">
|
|
<parameter name="aNode"/>
|
|
<parameter name="aAttributeName"/>
|
|
<parameter name="aAttributeValue"/>
|
|
<body>
|
|
<![CDATA[
|
|
if (aNode) {
|
|
if (aNode.getAttribute(aAttributeName) == aAttributeValue)
|
|
return aNode;
|
|
|
|
for (var i = 0; i < aNode.childNodes.length; ++i)
|
|
return this.recursiveAttributeSearch(aNode.childNodes[i], aAttributeName, aAttributeValue);
|
|
}
|
|
return null;
|
|
]]>
|
|
</body>
|
|
</method>
|
|
</implementation>
|
|
<handlers>
|
|
<handler event="command">
|
|
<![CDATA[
|
|
this.checked = !this.checked;
|
|
]]>
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
</bindings>
|
|
|
|
|