close on outside click and escape
This commit is contained in:
@@ -20,14 +20,12 @@
|
||||
vm.$onInit = onInit;
|
||||
vm.$onDestroy = onDestroy;
|
||||
vm.search = search;
|
||||
vm.handleKeyUp = handleKeyUp;
|
||||
vm.closeSearch = closeSearch;
|
||||
|
||||
function onInit() {
|
||||
|
||||
vm.searchResults = [];
|
||||
vm.hasResults = false;
|
||||
|
||||
console.log("init search thingy");
|
||||
backdropService.open();
|
||||
}
|
||||
|
||||
@@ -35,6 +33,13 @@
|
||||
backdropService.close();
|
||||
}
|
||||
|
||||
function handleKeyUp(event) {
|
||||
// esc
|
||||
if(event.keyCode === 27) {
|
||||
closeSearch();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to proxy a callback
|
||||
*/
|
||||
@@ -49,11 +54,9 @@
|
||||
* @param {string} searchQuery
|
||||
*/
|
||||
function search(searchQuery) {
|
||||
console.log(searchQuery);
|
||||
if(searchQuery.length > 0) {
|
||||
var search = {"term": searchQuery};
|
||||
searchService.searchAll(search).then(function(result){
|
||||
|
||||
//result is a dictionary of group Title and it's results
|
||||
var filtered = {};
|
||||
_.each(result, function (value, key) {
|
||||
@@ -61,12 +64,10 @@
|
||||
filtered[key] = value;
|
||||
}
|
||||
});
|
||||
|
||||
// bind to view model
|
||||
vm.searchResults = filtered;
|
||||
// check if search has results
|
||||
vm.hasResults = Object.keys(vm.searchResults).length > 0;
|
||||
console.log("results", vm.searchResults);
|
||||
console.log("has results", vm.hasResults);
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
@@ -43,6 +43,10 @@ function MainController($scope, $location, appState, treeService, notificationsS
|
||||
eventsService.emit("app.closeDialogs", event);
|
||||
};
|
||||
|
||||
$scope.closeSearch = function() {
|
||||
appState.setSearchState("show", false);
|
||||
};
|
||||
|
||||
var evts = [];
|
||||
|
||||
//when a user logs out or timesout
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
<div class="umb-search" on-outside-click="vm.closeSearch()">
|
||||
<div class="umb-search" on-outside-click="vm.closeSearch()" ng-keyup="vm.handleKeyUp($event)">
|
||||
|
||||
<div class="flex items-center">
|
||||
<i class="umb-search-input-icon icon-search"></i>
|
||||
|
||||
Reference in New Issue
Block a user