<?xml version="1.0"?>

<bindings id="bdsTitledSplitter"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:xbl="http://www.mozilla.org/xbl"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

  <binding id="titledSplitter" extends="chrome://global/content/bindings/splitter.xml#splitter">
    <content>
      <xul:vbox class="titledsplitter-container" flex="1">
        <xul:spacer class="titledsplitter-dragbar"/>
        <xul:box class="titledsplitter-titlebox" flex="1" onmousedown="event.stopPropagation()">
          <xul:box align="center">
            <xul:label class="titledsplitter-text" xbl:inherits="value=label"/>
          </xul:box>
          <xul:spacer flex="1"/>
          <xul:button class="titledsplitter-closebutton" align="center" pack="center"
                   onclick="this.parentNode.parentNode.parentNode.close();">
            <xul:image class="titledsplitter-closeimage"/>
          </xul:button>
        </xul:box>
      </xul:vbox>
    </content>

    <implementation>
      <property name="isOpened">
        <getter><![CDATA[
          return this.mOpened;
        ]]></getter>
      </property>

      <property name="collapsee">
        <getter><![CDATA[
          var collapse = this.getAttribute("collapse");
          return collapse == "before" ? this.previousSibling : this.nextSibling;
        ]]></getter>
      </property>

      <method name="open">
        <body><![CDATA[
          var collapsee = this.collapsee;
          if (collapsee) {
            this.removeAttribute("closed");
            this.removeAttribute("collapsed");
            collapsee.removeAttribute("collapsed");
            this.mOpened = true;
            this.onopen();
          }
        ]]></body>
      </method>

      <method name="close">
        <body><![CDATA[
          var collapsee = this.collapsee;
          if (collapsee) {
            this.setAttribute("closed", "true");
            this.setAttribute("collapsed", "true");
            collapsee.setAttribute("collapsed", "true");
            this.mOpened = false;
            this.onopen();
          }
        ]]></body>
      </method>
      
      <method name="onopen">
        <body><![CDATA[
          if (!this.mOnOpen) {
            var js = this.getAttribute("onopen");
            if (js)
              this.mOnOpen = new Function(js);
          }          

          return this.mOnOpen ? this.mOnOpen() : null;
        ]]></body>
      </method>
    
	  <constructor><![CDATA[
        this.mOpened = false;
      ]]></constructor>
    </implementation>
    
  </binding>

</bindings>
