<!-- This Source Code Form is subject to the terms of the Mozilla Public
  - License, v. 2.0. If a copy of the MPL was not distributed with this
  - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<bindings id="autocompleteBindings"
          xmlns="http://www.mozilla.org/xbl"
          xmlns:html="http://www.w3.org/1999/xhtml"
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
          xmlns:xbl="http://www.mozilla.org/xbl">
  <binding id="websearch" extends="chrome://gloda/content/glodacomplete.xml#glodacomplete-base-richlistitem">
    <content orient="horizontal">
      <xul:image anonid="icon"/>
      <xul:description anonid="explanation" class="explanation websearch"/>
    </content>
    <implementation implements="nsIDOMXULSelectControlItemElement">
      <constructor>
        <![CDATA[
          this._explanation = document.getAnonymousElementByAttribute(
            this, "anonid", "explanation");
          this.bundle = Services.strings.createBundle(
            "chrome://messenger/locale/glodaComplete.properties");
          this._adjustAcItem();
          ]]>
      </constructor>

      <property name="label" readonly="true">
        <getter>
          <![CDATA[
            return this.bundle
                       .GetStringFromName("glodaComplete.webSearch1.label")
                       .replace("#1", Services.search.currentEngine.name)
                       .replace("#2", this.row.item.tag);
          ]]>
        </getter>
      </property>

      <method name="_adjustAcItem">
        <body>
          <![CDATA[
            this._explanation.value =
              this.bundle.GetStringFromName("glodaComplete.webSearch1.label")
                         .replace("#1", Services.search.currentEngine.name)
                         .replace("#2", this.row.term);
          ]]>
        </body>
      </method>
    </implementation>
  </binding>
</bindings>
