mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Only load the search results when the search form is submitted for the
first time
This commit is contained in:
parent
33666c459b
commit
8ace80c287
|
@ -73,7 +73,7 @@
|
|||
<div class="modal-body">
|
||||
<form role="form">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search..." id="mkdocs-search-query">
|
||||
</div>
|
||||
</form>
|
||||
<div id="mkdocs-search-results"></div>
|
||||
|
@ -167,9 +167,9 @@
|
|||
<script src="{{ base_url }}/js/jquery-1.8.1-min.js"></script>
|
||||
<script src="{{ base_url }}/js/prettify-1.0.js"></script>
|
||||
<script src="{{ base_url }}/js/bootstrap-2.1.1-min.js"></script>
|
||||
<script src="{{ base_url }}/js/theme.js"></script>
|
||||
<script>var base_url = '{{ base_url }}';</script>
|
||||
<script data-main="{{ base_url }}/mkdocs/js/search.js" src="{{ base_url }}/mkdocs/js/require.js"></script>
|
||||
<script src="{{ base_url }}/mkdocs/js/require.js"></script>
|
||||
<script src="{{ base_url }}/js/theme.js"></script>
|
||||
|
||||
<script>
|
||||
//$('.side-nav').scrollspy()
|
||||
|
|
|
@ -1,5 +1,35 @@
|
|||
function getSearchTerm()
|
||||
{
|
||||
var sPageURL = window.location.search.substring(1);
|
||||
var sURLVariables = sPageURL.split('&');
|
||||
for (var i = 0; i < sURLVariables.length; i++)
|
||||
{
|
||||
var sParameterName = sURLVariables[i].split('=');
|
||||
if (sParameterName[0] == 'q')
|
||||
{
|
||||
return sParameterName[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
var initialise_search = function(){
|
||||
require.config({"baseUrl":"/mkdocs/js"});
|
||||
require(["search",]);
|
||||
}
|
||||
|
||||
var search_term = getSearchTerm();
|
||||
if(search_term){
|
||||
$('#mkdocs_search_modal').modal();
|
||||
}
|
||||
|
||||
$('pre code').parent().addClass('prettyprint well');
|
||||
|
||||
$(document).on("submit", "#mkdocs_search_modal form", function (e) {
|
||||
$("#mkdocs-search-results").html("Searching...")
|
||||
initialise_search();
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<a class="repo-link btn btn-inverse btn-small {% if not previous_page %}disabled{% endif %}" rel="next" {% if previous_page %}href="{{ previous_page.url }}"{% endif %}>
|
||||
<i class="icon-arrow-left icon-white"></i> Previous
|
||||
</a>
|
||||
<a class="repo-link btn btn-inverse btn-small" href="#mkdocs_search_modal" data-toggle="modal" data-target="#mkdocs_search_modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
<a id="search_modal_show" class="repo-link btn btn-inverse btn-small" href="#mkdocs_search_modal" data-toggle="modal" data-target="#mkdocs_search_modal"><i class="icon-search icon-white"></i> Search</a>
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
|
|
Loading…
Reference in New Issue
Block a user