<!--
  Copyright 2011, The gwtquery team.

  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  use this file except in compliance with the License. You may obtain a copy of
  the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  License for the specific language governing permissions and limitations under
  the License.
-->

<!-- Include com.google.gwt.query.QueryMin instead of com.google.gwt.query.Query-->
<!-- if you want small javascript code and you are not using any of the selectors: -->
<!-- ".*(:contains|!=|:checked|:not|:nth-|:last-|:only-).*"-->
<!-- Note: that this will increase the number of total permutations. -->
<module>

    <!-- Inherit GQuery module -->
    <inherits name='com.google.gwt.query.Query'/>

    <!-- Detect whether querySelectorAll is available -->
    <define-property name="selectorCapability" values="native,js"/>
    <property-provider name="selectorCapability">
        <![CDATA[
         return !/_force_no_native/.test(document.location.search) &&
                document.querySelectorAll &&
                /native/.test(String(document.querySelectorAll)) ? "native" : "js";
        ]]>
    </property-provider>

    <set-property name="selectorCapability" value="js" >
        <when-property-is name="user.agent" value="ie6" />
    </set-property>
    <set-property name="selectorCapability" value="native" >
        <any>
            <when-property-is name="user.agent" value="safari" />
        </any>
    </set-property>
    
    <!-- JSNI Generator -->
    <generate-with class="com.google.gwt.query.rebind.JsniBundleGenerator">
        <when-type-assignable class="com.google.gwt.query.client.builders.JsniBundle"/>
    </generate-with>    

    <!-- Browser flags -->
    <generate-with class="com.google.gwt.query.rebind.BrowserGenerator">
        <when-type-assignable class="com.google.gwt.query.client.Browser"/>
    </generate-with>    

    <!-- GQuery.console -->
    <replace-with class="com.google.gwt.query.client.impl.ConsoleBrowser">
        <when-type-assignable class="com.google.gwt.query.client.Console"/>
    </replace-with>

    <!-- Selector Engines -->
    <replace-with class="com.google.gwt.query.client.impl.SelectorEngineNativeMin">
        <when-type-assignable class="com.google.gwt.query.client.impl.SelectorEngineImpl"/>
        <any>
            <when-property-is name="user.agent" value="gecko1_8"/>
            <when-property-is name="user.agent" value="opera"/>
            <when-property-is name="user.agent" value="safari"/>
        </any>
        <when-property-is name="selectorCapability" value="native"/>
    </replace-with>
    <replace-with class="com.google.gwt.query.client.impl.SelectorEngineCssToXPath">
        <when-type-assignable class="com.google.gwt.query.client.impl.SelectorEngineImpl"/>
        <any>
            <when-property-is name="user.agent" value="gecko1_8"/>
            <when-property-is name="user.agent" value="opera"/>
            <when-property-is name="user.agent" value="safari"/>
        </any>
        <when-property-is name="selectorCapability" value="js"/>
    </replace-with>
    <replace-with class="com.google.gwt.query.client.impl.SelectorEngineNativeMinIE8">
        <when-type-assignable class="com.google.gwt.query.client.impl.SelectorEngineImpl"/>
        <any>
            <when-property-is name="user.agent" value="ie8"/>
            <when-property-is name="user.agent" value="ie9"/>
        </any>
        <when-property-is name="selectorCapability" value="native"/>
    </replace-with>
</module>
