<?xml version="1.0"?>

<!-- This Source Code is subject to the terms of the Mozilla Public License
   - version 2.0 (the "License"). You can obtain a copy of the License at
   - http://mozilla.org/MPL/2.0/. -->

<!DOCTYPE overlay SYSTEM "chrome://adblockedge/locale/composer.dtd">

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://adblockedge/skin/composer.css" type="text/css"?>

<dialog id="abp-composer"
    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    title="&dialog.title;"
    onload="init()"
    ondialogaccept="return addFilter()"
    ondialogdisclosure="setAdvancedMode(!advancedMode)"
    buttons="accept,cancel,disclosure"
    width="800px"
    height="400px"
    persist="screenX screenY width height sizemode advancedMode"
    advancedMode="false"
    buttonlabelaccept="&accept.label;"
    buttonlabeldisclosure="&advanced.label;"
    buttonlabeldisclosure_on="&advanced.label;"
    buttonlabeldisclosure_off="&basic.label;"
    windowtype="abp:composer">

  <script type="application/x-javascript;version=1.7" src="utils.js"/>
  <script type="application/x-javascript;version=1.7" src="composer.js"/>  
  
  <popupset>
    <tooltip id="domainRestrictionHelp" label="&domainRestriction.help;"/>
  </popupset>

  <description id="disabledWarning" hidden="true" textTemplate="&disabled.warning;">
    <label class="text-link" onclick="doEnable()"/>
  </description>

  <hbox id="filterBox" align="center">
    <label control="filter" value="&filter.label;" accesskey="&filter.accesskey;"/>
    <textbox id="filter" flex="1" tabindex="-1" readonly="true"/>
    <button id="preferences" label="&preferences.label;" accesskey="&preferences.accesskey;" oncommand="openPreferences()"/>
  </hbox>

  <radiogroup orient="horizontal" id="filterType" oncommand="updateFilter()">
    <radio label="&type.filter.label;" accesskey="&type.filter.accesskey;" value="filterlist" flex="1"/>
    <radio label="&type.whitelist.label;" accesskey="&type.whitelist.accesskey;" value="whitelist" flex="1"/>
  </radiogroup>

  <hbox flex="1">
    <groupbox id="pattern" flex="1">
      <caption label="&pattern.label;"/>
      <radiogroup id="patternGroup" flex="1" oncommand="updatePatternSelection()" style="overflow: auto;">
        <description id="patternExplanation">&pattern.explanation;</description>
        <description id="regexpWarning" hidden="true">&regexp.warning;</description>
        <description id="shortpatternWarning" hidden="true">&shortpattern.warning;</description>
        <description id="matchWarning" hidden="true">&match.warning;</description>
        <hbox id="customPatternBox">
          <radio id="customPatternRadio" label="&custom.pattern.label;" accesskey="&custom.pattern.accesskey;" value="" control="customPattern"/>
          <textbox id="customPattern" flex="1" oninput="updateCustomPattern()"/>
        </hbox>
      </radiogroup>
      <hbox id="anchorGroup" pack="start" align="baseline">
        <label value="&anchors.label;"/>
        <description flex="1" style="margin: 0; padding: 0;">
          <checkbox id="anchorStart" labelRegular="&anchor.start.label;" accesskeyRegular="&anchor.start.accesskey;"
                                     labelFlexible="&anchor.start.flexible.label;" accesskeyFlexible="&anchor.start.flexible.accesskey;"
                                     oncommand="updateFilter()"/>
          <checkbox id="anchorEnd" label="&anchor.end.label;" accesskey="&anchor.end.accesskey;" oncommand="updateFilter()"/>
        </description>
      </hbox>
    </groupbox>
    <groupbox id="options">
      <caption label="&options.label;"/>
      <checkbox id="firstParty" label="&firstParty.label;" accesskey="&firstParty.accesskey;" oncommand="checkboxUpdated(this);"/>
      <checkbox id="thirdParty" label="&thirdParty.label;" accesskey="&thirdParty.accesskey;" oncommand="checkboxUpdated(this);"/>
      <checkbox id="matchCase" label="&matchCase.label;" accesskey="&matchCase.accesskey;" oncommand="checkboxUpdated(this);"/>
      <hbox align="baseline">
        <checkbox id="domainRestrictionEnabled" label="&domainRestriction.label;" accesskey="&domainRestriction.accesskey;" oncommand="checkboxUpdated(this);"/>
        <description class="help" value="?" tooltip="domainRestrictionHelp"/>
      </hbox>
      <textbox id="domainRestriction" oninput="updateFilter()"/>

      <label id="typeGroupLabel" value="&types.label;"/>
      <hbox>
        <label id="selectAllTypes" class="text-link" value="&selectAllTypes.label;" onclick="selectAllTypes(true)"/>
        <spacer flex="1"/>
        <label id="unselectAllTypes" class="text-link" value="&unselectAllTypes.label;" onclick="selectAllTypes(false)"/>
      </hbox>
      <vbox flex="1" id="typeGroup"/>

      <vbox>
        <label control="collapse" value="&collapse.label;" accesskey="&collapse.accesskey;"/>
        <menulist id="collapse" oncommand="updateFilter()">
          <menupopup>
            <menuitem id="collapseDefault" value="" label_yes="&collapse.default.yes.label;" label_no="&collapse.default.no.label;" selected="true"/>
            <menuitem label="&collapse.yes.label;" value="collapse"/>
            <menuitem label="&collapse.no.label;" value="~collapse"/>
          </menupopup>
        </menulist>
      </vbox>
    </groupbox>
  </hbox>
</dialog>
