<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
/*
 * Copyright (c) OutWit Technologies 2007-2017.
 * All rights reserved.
 */
-->

<!DOCTYPE window [
  <!ENTITY % optionsDTD SYSTEM "chrome://outwit-modules-docs/locale/options.dtd">
  %optionsDTD;
  <!ENTITY % selectIfDTD SYSTEM "chrome://outwit-kernel/locale/widgets/selectIf.dtd">
  %selectIfDTD;
  <!ENTITY % directoryDTD SYSTEM "chrome://outwit-kernel/locale/widgets/directory.dtd" >
  %directoryDTD;
]>

<overlay 
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  xmlns:html="http://www.w3.org/1999/xhtml">
  
  <script src="Comparator.js" type="application/javascript" />


  <script>
    <![CDATA[

      function select( anEvent ){
        try {
        Comparator.column = anEvent.target.getAttribute('column');
        document.getElementById('cols').setAttribute('value', anEvent.target.getAttribute('label') );

      
        var type = anEvent.target.getAttribute('type');
        
        if( type == Comparator.type ) return;

        var selector = document.getElementById('selector');
        var selectorbis = document.getElementById('selector-bis');
        if( type == 'number' ){
          selector.setAttribute('popup', 'popup-options-number');
          selectorbis.setAttribute('popup', 'popup-options-number');
          selectRule( document.getElementById('popup-options-number').firstChild );
        }
        else{
          selector.setAttribute('popup', 'popup-options-string');
          selectorbis.setAttribute('popup', 'popup-options-string');
          selectRule( document.getElementById('popup-options-string').firstChild );
          }
          }
          catch(e) {
          dump("optionsOverlay::select error : " + e + "\n");
          }
      }

      function selectRule( aRule ){
      try {
        if( aRule.getAttribute('compar') == '' ) Comparator.type = Comparator.kRegexp;
        else Comparator.type = Comparator.kCompare;
        var selector = document.getElementById('selector');
        selector.setAttribute('value', aRule.getAttribute('label') );
        selector.setAttribute('beginReg', aRule.getAttribute('beginReg') );
        selector.setAttribute('endReg', aRule.getAttribute('endReg') );
        selector.setAttribute('invert', aRule.getAttribute('invert') );
        selector.setAttribute('compar', aRule.getAttribute('compar') );
        Comparator.apply();
        } catch(e) {
          dump("optionsOverlay::selectRule error : " + e + "\n");
        }
      }
    ]]>
  </script>


  <popupset>
    <popup id="popup-options" oncommand="select(event)">
      <menuitem label="&name;"             column="filename"          type="string" />
      <menuitem label="&size;"             column="docSize"       type="number" />
      <menuitem label="&type;"             column="type"          type="string" />
      <menuitem label="&modificationDate;" column="lastModified"  type="number" />
    </popup>

    <popup id="popup-options-number" oncommand="selectRule(event.target)">
      <menuitem label="&selectIf.menuitem.equal;"         beginReg=""   endReg=""   invert="0"  compar="=="     />
      <menuitem label="&selectIf.menuitem.greater;"       beginReg=""   endReg=""   invert="0"  compar="&gt;"   />
      <menuitem label="&selectIf.menuitem.greaterEqual;"  beginReg=""   endReg=""   invert="0"  compar="&gt;="  />
      <menuitem label="&selectIf.menuitem.less;"          beginReg=""   endReg=""   invert="0"  compar="&lt;"   />
      <menuitem label="&selectIf.menuitem.lessEqual;"     beginReg=""   endReg=""   invert="0"  compar="&lt;="  />
    </popup>

    <popup id="popup-options-string" oncommand="selectRule(event.target)">
      <menuitem label="&selectIf.menuitem.contains;"      beginReg=""   endReg=""   invert="0"  compar=""       />
      <menuitem label="&selectIf.menuitem.noContain;"     beginReg=""   endReg=""   invert="1" compar=""       />
      <menuitem label="&selectIf.menuitem.begin;"         beginReg="^(" endReg=")"  invert="0"  compar=""       />
      <menuitem label="&selectIf.menuitem.noBegin;"       beginReg="^(" endReg=")"  invert="1" compar=""       />
      <menuitem label="&selectIf.menuitem.end;"           beginReg="("  endReg=")$" invert="0"  compar=""       />
      <menuitem label="&selectIf.menuitem.noEnd;"         beginReg="("  endReg=")$" invert="1" compar=""       />
    </popup>
 </popupset>



  <hbox id="optionsOverlay">
    <vbox class="box">
      <box>
        <label  value="&options.autocatch.SelectIf;" class="header"/>

        <label id="cols"  value="&name;" class="underlineHeader" /> <!-- popup="popup-options" -->
        <!--
                onclick="document.getElementById(this.getAttribute('popup')).openPopup(this, 'after_start', '', '', true, false)"/>-->
        <!--<label id="cols-bis"  value="▼" class="popupSign" popup="popup-options"
                onclick="document.getElementById(this.getAttribute('popup')).openPopup(this, 'after_start', '', '', true, false)"/>-->

        <label id="selector"  value="&selectIf.menuitem.contains;" class="underlineHeader" popup="popup-options-string"
                onclick="document.getElementById(this.getAttribute('popup')).openPopup(this, 'after_start', '', '', true, false)"/>
        <label id="selector-bis"  value="▼" class="popupSign" popup="popup-options-string"
                onclick="document.getElementById(this.getAttribute('popup')).openPopup(this, 'after_start', '', '', true, false)"/>
      </box>
      <box>
        <textbox  id="urlpattern"   preftype="string" preference="oWDocs.autocatch.urlpattern" oninput="optionsCtrl.changePattern(this.value)" flex="1"/>
      </box>
    </vbox>
    <vbox class="box">
      <box>
        <deck id="fileFormatDeck" selectedIndex="0">
          <label value="&options.autocatch.ifFileFormat;" class="header"/>
          <label value="&options.autocatch.ifFileFormatAndQuery;" class="header"/>
        </deck>
      </box>
      <box>
        <!--<button type="menu" label="&options.autocatch.ifFileFormat;">
          <menupopup>-->
            <checkbox id="fileFormat_any" label="&options.all;" checked="true"
              preftype="bool" preference="oWDocs.autocatch.any"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />
            <!--<checkbox id="fileFormat_text" label="&options.text;"
              preftype="bool" preference="oWDocs.autocatch.text"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />-->
            <checkbox id="fileFormat_pdf" label="&options.pdf;" checked="true"
              preftype="bool" preference="oWDocs.autocatch.pdf"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />
            <checkbox id="fileFormat_documents" label="&options.documents;" checked="true"
              preftype="bool" preference="oWDocs.autocatch.documents"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />
            <checkbox id="fileFormat_datasheets" label="&options.datasheets;" checked="true"
              preftype="bool" preference="oWDocs.autocatch.datasheets"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />
            <checkbox id="fileFormat_presentations" label="&options.presentations;" checked="true"
              preftype="bool" preference="oWDocs.autocatch.presentations"
              oncommand="optionsCtrl.fileFormatChange(this)"
            />
        <!--  </menupopup>
        </button>-->
        </box>
    </vbox>
    <hbox align="center">
      <button id="selectbutton" label="&options.select;" oncommand="Comparator.apply(true)"/>
      <button id="catchbutton" label="&options.catch;" oncommand="gContainer.handleEnter()"/>
    </hbox>
    <spacer flex="1" />
    <vbox class="box">
      <box>
        <label  value="&options.queriesToPerform;" class="header"/>
      </box>
      <box>
        <menulist id="queriesToPerform" width="120px" type="menu-button" preference="oWDocs.queryTypesInQuery" oncommand="optionsCtrl.queryTypeChanged(this)">
          <menupopup>
	    	<menuitem label="&options.allTypes;" value="all" />
            <menuitem label="&options.onlySelectedTypes;" value="selectionPanel" />
          </menupopup>
         </menulist>
      </box>
    </vbox>



    <!--spacer flex="1" />
    <hbox align="center">
      <toolbarbutton class="tab-close-button" style="display:-moz-box" oncommand="menuCtrl.showOptions('false')"/>
    </hbox-->

    
  </hbox>
</overlay>

