Skip to content

Commit

Permalink
use var and remove suggestions when needed
Browse files Browse the repository at this point in the history
Use variable for maximum number of suggestions for quicksearch.
And hide suggestions when search field is emptied, or when no suggestion are found.
  • Loading branch information
Klap-in committed Feb 3, 2013
1 parent d91a4ef commit 4860686
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/exe/ajax.php
Expand Up @@ -45,6 +45,8 @@ function ajax_qsearch(){
global $lang;
global $INPUT;

$maxnumbersuggestions = 50;

$query = $INPUT->post->str('q');
if(empty($query)) $query = $INPUT->get->str('q');
if(empty($query)) return;
Expand Down Expand Up @@ -72,7 +74,7 @@ function ajax_qsearch(){
echo '<li>' . html_wikilink(':'.$id,$name) . '</li>';

$counter ++;
if($counter > 50) {
if($counter > $maxnumbersuggestions) {
echo '<li>...</li>';
break;
}
Expand Down
6 changes: 5 additions & 1 deletion lib/scripts/qsearch.js
Expand Up @@ -37,6 +37,7 @@ var dw_qsearch = {
do_qsearch = function () {
var value = dw_qsearch.$inObj.val();
if (value === '') {
dw_qsearch.clear_results();
return;
}
jQuery.post(
Expand Down Expand Up @@ -83,7 +84,10 @@ var dw_qsearch = {
onCompletion: function(data) {
var max, $links, too_big;

if (data === '') { return; }
if (data === '') {
dw_qsearch.clear_results();
return;
}

dw_qsearch.$outObj
.html(data)
Expand Down

0 comments on commit 4860686

Please sign in to comment.