django-rest-framework/js/theme.js

36 lines
932 B
JavaScript
Raw Normal View History

2015-08-06 16:31:52 +03:00
var getSearchTerm = function() {
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];
2015-06-04 17:37:22 +03:00
}
2015-08-06 16:31:52 +03:00
}
};
2015-06-04 17:37:22 +03:00
2015-08-06 16:31:52 +03:00
var initilizeSearch = function() {
require.config({ baseUrl: '/mkdocs/js' });
require(['search']);
};
2015-06-04 17:37:22 +03:00
2015-08-06 16:31:52 +03:00
$(function() {
var searchTerm = getSearchTerm(),
$searchModal = $('#mkdocs_search_modal'),
$searchQuery = $searchModal.find('#mkdocs-search-query'),
$searchResults = $searchModal.find('#mkdocs-search-results');
2014-12-10 17:29:33 +03:00
2015-08-06 16:31:52 +03:00
$('pre code').parent().addClass('prettyprint well');
2014-12-10 17:29:33 +03:00
2015-08-06 16:31:52 +03:00
if (searchTerm) {
$searchQuery.val(searchTerm);
$searchResults.text('Searching...');
$searchModal.modal();
}
2015-06-04 17:37:22 +03:00
2015-08-06 16:31:52 +03:00
$searchModal.on('shown', function() {
$searchQuery.focus();
initilizeSearch();
});
2014-12-10 17:29:33 +03:00
});