Use new search API when available
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -30,22 +30,32 @@ app.directive('search', function ($document, $location) {
|
||||
'onSearch': '='
|
||||
},
|
||||
link: function (scope) {
|
||||
var box = $('#searchbox');
|
||||
box.val($location.search().search);
|
||||
|
||||
var doSearch = function() {
|
||||
var value = box.val();
|
||||
scope.$apply(function () {
|
||||
scope.onSearch(value);
|
||||
if (OCA.Search && OCA.Search.Core) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const search = new OCA.Search((term) => {
|
||||
scope.$apply(function () {
|
||||
scope.onSearch(term);
|
||||
});
|
||||
}, () => {
|
||||
scope.$apply(function () {
|
||||
scope.onSearch('');
|
||||
});
|
||||
});
|
||||
};
|
||||
} else {
|
||||
const box = $('#searchbox');
|
||||
box.val($location.search().search);
|
||||
|
||||
box.on('search keyup', function (event) {
|
||||
if (event.type === 'search' || event.keyCode === 13 ) {
|
||||
var doSearch = function () {
|
||||
var value = box.val();
|
||||
scope.$apply(function () {
|
||||
scope.onSearch(value);
|
||||
});
|
||||
};
|
||||
|
||||
box.on('search keyup', function (event) {
|
||||
doSearch();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user