browser/metro/base/content/bindings/toggleswitch.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/content/bindings/toggleswitch.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,144 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.9 +
    1.10 +<!DOCTYPE bindings [
    1.11 +  <!ENTITY % checkboxDTD SYSTEM "chrome://browser/locale/checkbox.dtd">
    1.12 +  %checkboxDTD;
    1.13 +]>
    1.14 +
    1.15 +<bindings
    1.16 +    xmlns="http://www.mozilla.org/xbl"
    1.17 +    xmlns:xbl="http://www.mozilla.org/xbl"
    1.18 +    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.19 +
    1.20 +  <binding id="checkbox-toggleswitch" display="xul:box" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline">
    1.21 +    <content>
    1.22 +      <xul:hbox>
    1.23 +        <xul:description anonid="offlabel" class="offlabel" value="&checkbox.off.label;" xbl:inherits="value=offlabel"/>
    1.24 +        <xul:description anonid="onlabel" class="onlabel" value="&checkbox.on.label;" xbl:inherits="value=onlabel"/>
    1.25 +        <xul:radiogroup anonid="group" xbl:inherits="disabled">
    1.26 +          <xul:radio type="toggle" anonid="off" class="checkbox-radio-off"/>
    1.27 +          <xul:radio type="toggle" anonid="on" class="checkbox-radio-on"/>
    1.28 +        </xul:radiogroup>
    1.29 +      </xul:hbox>
    1.30 +    </content>
    1.31 +    <implementation>
    1.32 +      <constructor><![CDATA[
    1.33 +        this.setChecked(this.checked);
    1.34 +      ]]></constructor>
    1.35 +
    1.36 +      <field name="_group">
    1.37 +        document.getAnonymousElementByAttribute(this, "anonid", "group");
    1.38 +      </field>
    1.39 +
    1.40 +      <field name="_on">
    1.41 +        document.getAnonymousElementByAttribute(this, "anonid", "on");
    1.42 +      </field>
    1.43 +
    1.44 +      <field name="_onlabel">
    1.45 +        document.getAnonymousElementByAttribute(this, "anonid", "onlabel");
    1.46 +      </field>
    1.47 +
    1.48 +      <field name="_off">
    1.49 +        document.getAnonymousElementByAttribute(this, "anonid", "off");
    1.50 +      </field>
    1.51 +
    1.52 +      <field name="_offlabel">
    1.53 +        document.getAnonymousElementByAttribute(this, "anonid", "offlabel");
    1.54 +      </field>
    1.55 +
    1.56 +      <property name="onlabel"
    1.57 +        onget="return this._onlabel.value"
    1.58 +        onset="this._offlabel.value=val"/>
    1.59 +
    1.60 +      <property name="offlabel"
    1.61 +        onget="return this._offlabel.value"
    1.62 +        onset="this._offlabel.value=val"/>
    1.63 +
    1.64 +      <method name="setChecked">
    1.65 +        <parameter name="aValue"/>
    1.66 +        <body>
    1.67 +        <![CDATA[
    1.68 +          let change = (aValue != this.checked);
    1.69 +
    1.70 +          if (aValue) {
    1.71 +            this.setAttribute("checked", "true");
    1.72 +            this._group.selectedItem = this._on;
    1.73 +          } else {
    1.74 +            this.removeAttribute("checked");
    1.75 +            this._group.selectedItem = this._off;
    1.76 +          }
    1.77 +
    1.78 +          if (change) {
    1.79 +            this.fireEvent("CheckboxStateChange");
    1.80 +            this.fireEvent("command");
    1.81 +          }
    1.82 +
    1.83 +          return aValue;
    1.84 +        ]]>
    1.85 +        </body>
    1.86 +      </method>
    1.87 +
    1.88 +      <method name="fireEvent">
    1.89 +        <parameter name="aName"/>
    1.90 +        <body>
    1.91 +          <![CDATA[
    1.92 +            var event = document.createEvent("Events");
    1.93 +            event.initEvent(aName, true, true);
    1.94 +            this.dispatchEvent(event);
    1.95 +          ]]>
    1.96 +        </body>
    1.97 +      </method>
    1.98 +
    1.99 +      <method name="_onClickOrTap">
   1.100 +        <parameter name="aEvent"/>
   1.101 +        <body>
   1.102 +          <![CDATA[
   1.103 +            aEvent.stopPropagation();
   1.104 +            this.setChecked(!this.checked);
   1.105 +          ]]>
   1.106 +        </body>
   1.107 +      </method>
   1.108 +    </implementation>
   1.109 +    <handlers>
   1.110 +      <handler event="click" button="0" phase="capturing">
   1.111 +        <![CDATA[
   1.112 +          this._onClickOrTap(event);
   1.113 +        ]]>
   1.114 +      </handler>
   1.115 +    </handlers>
   1.116 +  </binding>
   1.117 +
   1.118 +  <binding id="setting-fulltoggle-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-bool">
   1.119 +    <implementation>
   1.120 +      <constructor>
   1.121 +        <![CDATA[
   1.122 +          this.input.classList.add("toggleswitch");
   1.123 +        ]]>
   1.124 +      </constructor>
   1.125 +    </implementation>
   1.126 +  </binding>
   1.127 +
   1.128 +  <binding id="setting-fulltoggle-boolint" extends="chrome://mozapps/content/extensions/setting.xml#setting-boolint">
   1.129 +    <implementation>
   1.130 +      <constructor>
   1.131 +        <![CDATA[
   1.132 +          this.input.classList.add("toggleswitch");
   1.133 +        ]]>
   1.134 +      </constructor>
   1.135 +    </implementation>
   1.136 +  </binding>
   1.137 +
   1.138 +  <binding id="setting-fulltoggle-localized-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-localized-bool">
   1.139 +    <implementation>
   1.140 +      <constructor>
   1.141 +        <![CDATA[
   1.142 +          this.input.classList.add("toggleswitch");
   1.143 +        ]]>
   1.144 +      </constructor>
   1.145 +    </implementation>
   1.146 +  </binding>
   1.147 +</bindings>

mercurial