toolkit/content/widgets/expander.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/widgets/expander.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     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 +<bindings id="expanderBindings"
    1.10 +          xmlns="http://www.mozilla.org/xbl"
    1.11 +          xmlns:xbl="http://www.mozilla.org/xbl"
    1.12 +          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    1.13 +
    1.14 +  <binding id="expander" display="xul:vbox">
    1.15 +    <resources>
    1.16 +      <stylesheet src="chrome://global/skin/expander.css"/>
    1.17 +    </resources>
    1.18 +    <content>
    1.19 +      <xul:hbox align="center">
    1.20 +        <xul:button type="disclosure" class="expanderButton" anonid="disclosure" xbl:inherits="disabled" mousethrough="always"/>
    1.21 +        <xul:label class="header expanderButton" anonid="label" xbl:inherits="value=label,disabled" mousethrough="always" flex="1"/>
    1.22 +        <xul:button anonid="clear-button" xbl:inherits="label=clearlabel,disabled=cleardisabled,hidden=clearhidden" mousethrough="always" icon="clear"/>
    1.23 +      </xul:hbox>
    1.24 +      <xul:vbox flex="1" anonid="settings" class="settingsContainer" collapsed="true" xbl:inherits="align">
    1.25 +        <children/>
    1.26 +      </xul:vbox>
    1.27 +    </content>
    1.28 +    <implementation>
    1.29 +      <constructor><![CDATA[
    1.30 +        var settings = document.getAnonymousElementByAttribute(this, "anonid", "settings");
    1.31 +        var expander = document.getAnonymousElementByAttribute(this, "anonid", "disclosure");
    1.32 +        var open = this.getAttribute("open") == "true";
    1.33 +        settings.collapsed = !open;
    1.34 +        expander.open = open;
    1.35 +      ]]></constructor>
    1.36 +      <property name="open">
    1.37 +        <setter>
    1.38 +          <![CDATA[
    1.39 +            var settings = document.getAnonymousElementByAttribute(this, "anonid", "settings");
    1.40 +            var expander = document.getAnonymousElementByAttribute(this, "anonid", "disclosure");
    1.41 +            settings.collapsed = !val;
    1.42 +            expander.open = val;
    1.43 +            if (val)
    1.44 +              this.setAttribute("open", "true");
    1.45 +            else
    1.46 +              this.setAttribute("open", "false");
    1.47 +            return val;
    1.48 +          ]]>
    1.49 +        </setter>
    1.50 +        <getter>
    1.51 +          return this.getAttribute("open");
    1.52 +        </getter>
    1.53 +      </property>        
    1.54 +      <method name="onCommand">
    1.55 +        <parameter name="aEvent"/>
    1.56 +        <body><![CDATA[
    1.57 +          var element = aEvent.originalTarget;
    1.58 +          var button = element.getAttribute("anonid");
    1.59 +          switch (button) {
    1.60 +          case "disclosure":
    1.61 +          case "label":
    1.62 +            if (this.open == "true")
    1.63 +              this.open = false;
    1.64 +            else
    1.65 +              this.open = true;
    1.66 +            break;
    1.67 +          case "clear-button":
    1.68 +            var event = document.createEvent("Events");
    1.69 +            event.initEvent("clear", true, true);
    1.70 +            this.dispatchEvent(event);
    1.71 +            break;
    1.72 +          }
    1.73 +        ]]></body>
    1.74 +      </method>
    1.75 +    </implementation>
    1.76 +    <handlers>
    1.77 +      <handler event="command"><![CDATA[
    1.78 +        this.onCommand(event);
    1.79 +      ]]></handler>
    1.80 +      <handler event="click"><![CDATA[
    1.81 +        if (event.originalTarget.localName == "label")
    1.82 +          this.onCommand(event);
    1.83 +      ]]></handler>
    1.84 +    </handlers>
    1.85 +  </binding>
    1.86 +          
    1.87 +</bindings>
    1.88 +
    1.89 +          

mercurial