Skip to content

Commit 731f652

Browse files
authored
Merge pull request #344 from kakirastern/add-filter-search-warning
Try and add filter search warning when no results is returned
2 parents 6b919d8 + ebe87b8 commit 731f652

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

tutorials/themes/tutorials-theme/static/searchtools.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
*
1010
*/
1111

12+
// Set ajaxSetup to synchronous to make a synchronous $.get call (but could be bad form).
13+
// See https://stackoverflow.com/a/25489055/9959073 for details.
14+
jQuery.ajaxSetup({async:false});
1215

1316
/* Non-minified version JS is _stemmer.js if file is provided */
1417
/**
@@ -346,7 +349,7 @@ var Search = {
346349
if (textstatus != "success") {
347350
document.getElementById("searchindexloader").src = url;
348351
}
349-
}});
352+
}, async: false});
350353
},
351354

352355
setIndex : function(index) {
@@ -577,7 +580,7 @@ var Search = {
577580
listItem.slideDown(5, function() {
578581
displayNextItem();
579582
});
580-
}});
583+
}, async: false});
581584
} else {
582585
// no source available, just display title
583586
Search.output.append(listItem);
@@ -854,4 +857,4 @@ var Search = {
854857

855858
$(document).ready(function() {
856859
Search.init();
857-
});
860+
});

tutorials/themes/tutorials-theme/tutorialfilters.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
//checking the active filters
99
var activeFilters = $.getQueryParameters();
1010
var filters = document.getElementsByClassName('custom-control-input');
11-
for(var f=0; filters[f]; ++f){
12-
if(activeFilters.q[0].search(filters[f].value)!=-1)
11+
for (var f=0; filters[f]; ++f){
12+
if (activeFilters.q[0].search(filters[f].value)!=-1)
1313
filters[f].checked = true;
1414
}
1515
document.getElementById("search-bar-input").value = '';
1616
});
1717

1818
//no results found
19-
$(window).on("load", function(){
20-
if(!document.getElementsByClassName('result-card').length)
21-
{document.getElementById('search-results').innerHTML += '<h3>No tutorials found!</h3>'}
19+
$(window).on('load', function() {
20+
if (!document.getElementsByClassName('result-card').length)
21+
{document.getElementById('search-results').innerHTML += '<h3>No tutorials found!</h3>';}
2222
});
2323

2424
//update filters
@@ -237,4 +237,4 @@ <h3 style="font-size: 1rem; font-weight: 500; text-decoration: none; padding-top
237237
</span>
238238

239239
</a>
240-
</form>
240+
</form>

0 commit comments

Comments
 (0)