Refactored Searchbox to menu.js

Signed-off-by: fnuesse <felix.nuesse@t-online.de>
This commit is contained in:
fnuesse 2018-11-14 20:54:10 +01:00
parent c109bad869
commit 2dd6adb2b4
No known key found for this signature in database
GPG key ID: 2089A3431243E819
2 changed files with 28 additions and 23 deletions

View file

@ -325,31 +325,12 @@
fields: ['label', 'username', 'email', 'custom_fields']
};
//searchboxfix
$scope.$on('nc_searchbox', function(event, args) {
$scope.filterOptions.filterText=args;
});
//searchboxfix
var native_search = document.getElementById("searchbox");
if(native_search !== null){
native_search.nextElementSibling.addEventListener('click', function (e) {
$scope.$apply(function () {
$scope.filterOptions.filterText="";
});
});
native_search.classList.remove('hidden');
native_search.addEventListener('keypress', function (e) {
if(e.keyCode === 13){
e.preventDefault();
}
});
native_search.addEventListener('keyup', function (e) {
$scope.$apply(function () {
$scope.filterOptions.filterText=native_search.value;
});
});
}
$scope.filtered_credentials = [];
$scope.$watch('[selectedtags, filterOptions, delete_time, active_vault.credentials]', function () {
if (!$scope.active_vault) {

View file

@ -118,6 +118,30 @@
}
};
//searchboxfix
var native_search = document.getElementById("searchbox");
if(native_search !== null){
native_search.nextElementSibling.addEventListener('click', function (e) {
$scope.$apply(function () {
$rootScope.$broadcast('nc_searchbox',"");
});
});
native_search.classList.remove('hidden');
native_search.addEventListener('keypress', function (e) {
if(e.keyCode === 13){
e.preventDefault();
}
});
native_search.addEventListener('keyup', function (e) {
$scope.$apply(function () {
$rootScope.$broadcast('nc_searchbox',native_search.value);
});
});
}
$scope.clickedNavigationItem="all";
$scope.filterCredentialBySpecial = function (string) {
$scope.clickedNavigationItem=string;