Benoit Boissinot avatar Benoit Boissinot committed 9f1caf6

fix #30: disable the search box when javascript isn't available

Comments (0)

Files changed (2)

sphinx/templates/layout.html

           {% include customsidebar %}
           {%- endif %}
           {%- block sidebarsearch %}
-          {%- if pagename != "search" %}
-          <h3>{{ _('Quick search') }}</h3>
-            <form class="search" action="{{ pathto('search') }}" method="get">
-              <input type="text" name="q" size="18" /> <input type="submit" value="{{ _('Go') }}" />
-              <input type="hidden" name="check_keywords" value="yes" />
-              <input type="hidden" name="area" value="default" />
-            </form>
-            <p style="font-size: 90%">{{ _('Enter search terms or a module, class or function name.') }}</p>
+	  {%- if pagename != "search" %}
+	  <div id="searchbox" style="display: none">
+            <h3>{{ _('Quick search') }}</h3>
+              <form class="search" action="{{ pathto('search') }}" method="get">
+                <input type="text" name="q" size="18" /> <input type="submit" value="{{ _('Go') }}" />
+                <input type="hidden" name="check_keywords" value="yes" />
+                <input type="hidden" name="area" value="default" />
+              </form>
+	      <p style="font-size: 90%">{{ _('Enter search terms or a module, class or function name.') }}</p>
+          </div>
+          <script type="text/javascript">
+            $(function () { $('#searchbox').show(0); });
+          </script>
           {%- endif %}
           {%- endblock %}
         </div>

sphinx/templates/search.html

 {% set script_files = script_files + ['_static/searchtools.js'] %}
 {% block body %}
   <h1 id="search-documentation">{{ _('Search') }}</h1>
+  <div id ="fallback" class="admonition warning">
+  <script type="text/javascript">$('#fallback').hide();</script>
+  <p>
+    {% trans %}Please activate Javascript to enable the search functionality.{% endtrans %}
+  </p>
+  </div>
   <p>
     {% trans %}From here you can search these documents. Enter your search
     words into the box below and click "search". Note that the search
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.