Use new search API when available

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-12-04 10:36:29 +01:00
parent 3b403d5576
commit 0296dc78f1

View File

@@ -30,7 +30,19 @@ app.directive('search', function ($document, $location) {
'onSearch': '='
},
link: function (scope) {
var box = $('#searchbox');
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);
var doSearch = function () {
@@ -41,11 +53,9 @@ app.directive('search', function ($document, $location) {
};
box.on('search keyup', function (event) {
if (event.type === 'search' || event.keyCode === 13 ) {
doSearch();
}
});
}
}
};
});