clear search results when clicking the x in type=search input field

This commit is contained in:
Jörn Friedrich Dreyer 2015-01-02 15:44:41 +01:00
parent 6f820b0209
commit d89733c859

View file

@ -30,6 +30,7 @@
* Initialize the search box
*
* @param $searchBox container element with existing markup for the #searchbox form
* @param $searchResults container element for results und status message
* @private
*/
initialize: function($searchBox, $searchResults) {
@ -117,8 +118,10 @@
lastPage = page;
lastSize = size;
//show spinner
$searchResults.removeClass('hidden');
$status.html(t('core', 'Searching other places')+'<img class="spinner" alt="search in progress" src="'+OC.webroot+'/core/img/loading-dark.gif" />');
// do the actual search query
$.getJSON(OC.generateUrl('search/ajax/search.php'), {query:query, inApps:inApps, page:page, size:size }, function(results) {
lastResults = results;
@ -260,6 +263,14 @@
event.preventDefault();
});
$searchBox.on('search', function (event) {
if($searchBox.val() === '') {
if(self.hasFilter(getCurrentApp())) {
self.getFilter(getCurrentApp())('');
}
self.hideResults();
}
});
$searchBox.keyup(function(event) {
if (event.keyCode === 13) { //enter
if(currentResult > -1) {