toolkit/content/widgets/checkbox.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/widgets/checkbox.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.8 +
     1.9 +
    1.10 +<bindings id="checkboxBindings"
    1.11 +   xmlns="http://www.mozilla.org/xbl"
    1.12 +   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.13 +   xmlns:xbl="http://www.mozilla.org/xbl">
    1.14 +
    1.15 +  <binding id="checkbox" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline">
    1.16 +    <resources>
    1.17 +      <stylesheet src="chrome://global/skin/checkbox.css"/>
    1.18 +    </resources>
    1.19 +  </binding>
    1.20 +
    1.21 +  <binding id="checkbox-baseline" role="xul:checkbox"
    1.22 +    extends="chrome://global/content/bindings/general.xml#basetext">
    1.23 +    <content>
    1.24 +      <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
    1.25 +      <xul:hbox class="checkbox-label-box" flex="1">
    1.26 +        <xul:image class="checkbox-icon" xbl:inherits="src"/>
    1.27 +        <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/>
    1.28 +      </xul:hbox>
    1.29 +    </content>
    1.30 +    
    1.31 +    <implementation implements="nsIDOMXULCheckboxElement">
    1.32 +      <method name="setChecked">
    1.33 +        <parameter name="aValue"/>
    1.34 +        <body>
    1.35 +        <![CDATA[
    1.36 +          var change = (aValue != (this.getAttribute('checked') == 'true'));
    1.37 +          if (aValue)
    1.38 +            this.setAttribute('checked', 'true');
    1.39 +          else
    1.40 +            this.removeAttribute('checked');
    1.41 +          if (change) {
    1.42 +            var event = document.createEvent('Events');
    1.43 +            event.initEvent('CheckboxStateChange', true, true);
    1.44 +            this.dispatchEvent(event);
    1.45 +          }
    1.46 +          return aValue;
    1.47 +        ]]>
    1.48 +        </body>
    1.49 +      </method>
    1.50 +      
    1.51 +      <!-- public implementation -->
    1.52 +      <property name="checked"    onset="return this.setChecked(val);"
    1.53 +                                  onget="return this.getAttribute('checked') == 'true';"/>
    1.54 +    </implementation>
    1.55 +    
    1.56 +    <handlers>
    1.57 +      <!-- While it would seem we could do this by handling oncommand, we need can't
    1.58 +           because any external oncommand handlers might get called before ours, and
    1.59 +           then they would see the incorrect value of checked. -->           
    1.60 +      <handler event="click" button="0" action="if (!this.disabled) this.checked = !this.checked;"/>
    1.61 +      <handler event="keypress" key=" ">
    1.62 +        <![CDATA[
    1.63 +          this.checked = !this.checked;
    1.64 +        ]]>
    1.65 +      </handler>
    1.66 +    </handlers>
    1.67 +  </binding> 
    1.68 +
    1.69 +  <binding id="checkbox-with-spacing"
    1.70 +           extends="chrome://global/content/bindings/checkbox.xml#checkbox">
    1.71 +
    1.72 +    <content>
    1.73 +      <xul:hbox class="checkbox-spacer-box">
    1.74 +        <xul:image class="checkbox-check" xbl:inherits="checked,disabled"/>
    1.75 +      </xul:hbox>
    1.76 +      <xul:hbox class="checkbox-label-center-box" flex="1">
    1.77 +        <xul:hbox class="checkbox-label-box" flex="1">
    1.78 +          <xul:image class="checkbox-icon" xbl:inherits="src"/>
    1.79 +          <xul:label class="checkbox-label" xbl:inherits="xbl:text=label,accesskey,crop" flex="1"/>
    1.80 +        </xul:hbox>
    1.81 +      </xul:hbox>
    1.82 +    </content>
    1.83 +  </binding>
    1.84 +
    1.85 +</bindings>

mercurial