Use new search API when available
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -30,7 +30,19 @@ app.directive('search', function ($document, $location) {
|
|||||||
'onSearch': '='
|
'onSearch': '='
|
||||||
},
|
},
|
||||||
link: function (scope) {
|
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);
|
box.val($location.search().search);
|
||||||
|
|
||||||
var doSearch = function () {
|
var doSearch = function () {
|
||||||
@@ -41,11 +53,9 @@ app.directive('search', function ($document, $location) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
box.on('search keyup', function (event) {
|
box.on('search keyup', function (event) {
|
||||||
if (event.type === 'search' || event.keyCode === 13 ) {
|
|
||||||
doSearch();
|
doSearch();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user