Skip to content

Commit

Permalink
Automatic search removed
Browse files Browse the repository at this point in the history
Now it is necessary to click the search button or to press enter to start the search and when changing the search text or options.
  • Loading branch information
Ana06 committed Aug 7, 2016
1 parent 02aceb4 commit 7db6fa9
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions app/views/search/_find_form.html.erb
@@ -1,73 +1,9 @@
<script type="text/javascript">

var last_search = "<%= CGI::escape( @search_term || "" ) %>";

function afterDelayedKeyup(selector, action, delay){
jQuery(selector).keyup(function(){
if(typeof(window['inputTimeout']) != "undefined"){
clearTimeout(inputTimeout);
}
inputTimeout = setTimeout(action, delay);
});
}

function search() {
search_term = encodeURI( jQuery.trim( $("#search-form").val() ) );
if (search_term.length > 1 ) {
$('#search-messages').hide();
$('#msg').html("");
last_search = search_term;
parameters = {
q: search_term,
baseproject: $("#baseproject").val(),
search_devel: $("#search_devel_checkbox").is(':checked'),
search_unsupported: $("#search_unsupported_checkbox").is(':checked')
};

$.pjax({
cache: true,
url: '<%= url_for :controller => :search, :action => :searchresult %>',
data: parameters,
container: '#search_result_container',
timeout: 30000,
beforeSend: function() {
$('#search-form').addClass('search-form-busy');
},
complete: function(){
$('#search-form').removeClass('search-form-busy');
},
success: function(html){
$('#search-messages').hide();
},
error:function (jqXHR, textStatus, errorThrown) {
if (textStatus != 'abort') {
$('#msg').html("<%= _("An internal error happened :-(") %>");
$('#search-messages').show();
}
}
})

} else if (search_term.length > 0 ) {
$('#msg').html("<%= _("Please enter more than 1 character") %>");
$('#search-result-error').hide();
$('#search-messages').show();
} else {
$('#search-messages').hide();
}
}

$(function() {

$('#search-options').addClass('hidden');

afterDelayedKeyup('#search-form',"search()", 500);

$('#search_devel_checkbox, #search_unsupported_checkbox, #baseproject').change(function() {
if ($("#search-form").val().length > 1 ) {
search();
}
});

$("#search-options-link").click(function() {
$("#search-options").slideToggle();
});
Expand Down

0 comments on commit 7db6fa9

Please sign in to comment.