Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 4 additions & 42 deletions web-app/js/rwgsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ function addSelectCategories() {
}));

jQuery("#allCategory").after(jQuery("<option></option>").attr("value", "text").text("Free Text"));

jQuery("#search-categories").val(sessionSearchCategory);
jQuery('#search-ac').autocomplete('option', 'source', sourceURL + "?category=" + jQuery('#search-categories').val());

jQuery("#search-categories").val(sessionSearchCategory);
});

}
Expand Down Expand Up @@ -82,42 +79,8 @@ function addFilterCategories() {

//Method to add the autocomplete for the search keywords
function addSearchAutoComplete() {
jQuery("#search-ac").autocomplete({
position:{my:"left top",at:"left bottom",collision:"none"},
source: sourceURL,
minLength:1,
select: function(event, ui) {
if (ui.item != null && ui.item != "") {
searchParam={id:ui.item.id,display:ui.item.category,keyword:ui.item.label,category:ui.item.categoryId};
addSearchTerm(searchParam);
}

//If category is ALL, add this as free text as well
var category = jQuery("#search-categories").val();
return false;
}
}).data("ui-autocomplete")._renderItem = function( ul, item ) {
var resulta = '<a><span class="category-' + item.category.toLowerCase() + '">' + item.category + '&gt;</span>&nbsp;<b>' + item.label + '</b>&nbsp;';
if (item.synonyms != null) {
resulta += (item.synonyms + '</a>');
}
else {
resulta += '</a>';
}

return jQuery('<li></li>')
.data("item.autocomplete", item )
.append(resulta)
.appendTo(ul);
};

// Capture the enter key on the slider and fire off the search event on the autocomplete
jQuery("#search-categories").keypress(function(event) {
if (event.which == 13) {
jQuery("#search-ac").autocomplete('search');
}
});

// Autocomplete code removed. The below portion was left becuase it submits the search on enter

jQuery('#search-ac').keypress(function(event) {
var category = jQuery("#search-categories").val();
var categoryText = jQuery('#search-categories option:selected').text();
Expand Down Expand Up @@ -530,7 +493,6 @@ function clearSearch() {

// Change the category picker back to ALL and set autocomplete to not have a category (ALL by default)
document.getElementById("search-categories").selectedIndex = 0;
jQuery('#search-ac').autocomplete('option', 'source', sourceURL);

showSearchTemplate();
showSearchResults(); //reload the full search results
Expand Down Expand Up @@ -1388,4 +1350,4 @@ function findChildByParent(parent, callFunc){
callFunc(hasChildred);
}
});
}
}