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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     4    - License, v. 2.0. If a copy of the MPL was not distributed with this
     5    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     7 <!DOCTYPE bindings [
     8   <!ENTITY % checkboxDTD SYSTEM "chrome://browser/locale/checkbox.dtd">
     9   %checkboxDTD;
    10 ]>
    12 <bindings
    13     xmlns="http://www.mozilla.org/xbl"
    14     xmlns:xbl="http://www.mozilla.org/xbl"
    15     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    17   <binding id="checkbox-toggleswitch" display="xul:box" extends="chrome://global/content/bindings/checkbox.xml#checkbox-baseline">
    18     <content>
    19       <xul:hbox>
    20         <xul:description anonid="offlabel" class="offlabel" value="&checkbox.off.label;" xbl:inherits="value=offlabel"/>
    21         <xul:description anonid="onlabel" class="onlabel" value="&checkbox.on.label;" xbl:inherits="value=onlabel"/>
    22         <xul:radiogroup anonid="group" xbl:inherits="disabled">
    23           <xul:radio type="toggle" anonid="off" class="checkbox-radio-off"/>
    24           <xul:radio type="toggle" anonid="on" class="checkbox-radio-on"/>
    25         </xul:radiogroup>
    26       </xul:hbox>
    27     </content>
    28     <implementation>
    29       <constructor><![CDATA[
    30         this.setChecked(this.checked);
    31       ]]></constructor>
    33       <field name="_group">
    34         document.getAnonymousElementByAttribute(this, "anonid", "group");
    35       </field>
    37       <field name="_on">
    38         document.getAnonymousElementByAttribute(this, "anonid", "on");
    39       </field>
    41       <field name="_onlabel">
    42         document.getAnonymousElementByAttribute(this, "anonid", "onlabel");
    43       </field>
    45       <field name="_off">
    46         document.getAnonymousElementByAttribute(this, "anonid", "off");
    47       </field>
    49       <field name="_offlabel">
    50         document.getAnonymousElementByAttribute(this, "anonid", "offlabel");
    51       </field>
    53       <property name="onlabel"
    54         onget="return this._onlabel.value"
    55         onset="this._offlabel.value=val"/>
    57       <property name="offlabel"
    58         onget="return this._offlabel.value"
    59         onset="this._offlabel.value=val"/>
    61       <method name="setChecked">
    62         <parameter name="aValue"/>
    63         <body>
    64         <![CDATA[
    65           let change = (aValue != this.checked);
    67           if (aValue) {
    68             this.setAttribute("checked", "true");
    69             this._group.selectedItem = this._on;
    70           } else {
    71             this.removeAttribute("checked");
    72             this._group.selectedItem = this._off;
    73           }
    75           if (change) {
    76             this.fireEvent("CheckboxStateChange");
    77             this.fireEvent("command");
    78           }
    80           return aValue;
    81         ]]>
    82         </body>
    83       </method>
    85       <method name="fireEvent">
    86         <parameter name="aName"/>
    87         <body>
    88           <![CDATA[
    89             var event = document.createEvent("Events");
    90             event.initEvent(aName, true, true);
    91             this.dispatchEvent(event);
    92           ]]>
    93         </body>
    94       </method>
    96       <method name="_onClickOrTap">
    97         <parameter name="aEvent"/>
    98         <body>
    99           <![CDATA[
   100             aEvent.stopPropagation();
   101             this.setChecked(!this.checked);
   102           ]]>
   103         </body>
   104       </method>
   105     </implementation>
   106     <handlers>
   107       <handler event="click" button="0" phase="capturing">
   108         <![CDATA[
   109           this._onClickOrTap(event);
   110         ]]>
   111       </handler>
   112     </handlers>
   113   </binding>
   115   <binding id="setting-fulltoggle-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-bool">
   116     <implementation>
   117       <constructor>
   118         <![CDATA[
   119           this.input.classList.add("toggleswitch");
   120         ]]>
   121       </constructor>
   122     </implementation>
   123   </binding>
   125   <binding id="setting-fulltoggle-boolint" extends="chrome://mozapps/content/extensions/setting.xml#setting-boolint">
   126     <implementation>
   127       <constructor>
   128         <![CDATA[
   129           this.input.classList.add("toggleswitch");
   130         ]]>
   131       </constructor>
   132     </implementation>
   133   </binding>
   135   <binding id="setting-fulltoggle-localized-bool" extends="chrome://mozapps/content/extensions/setting.xml#setting-localized-bool">
   136     <implementation>
   137       <constructor>
   138         <![CDATA[
   139           this.input.classList.add("toggleswitch");
   140         ]]>
   141       </constructor>
   142     </implementation>
   143   </binding>
   144 </bindings>

mercurial