diff --git a/ui/src/app/layout/home.controller.js b/ui/src/app/layout/home.controller.js index 5091da8415..520cfb5ae9 100644 --- a/ui/src/app/layout/home.controller.js +++ b/ui/src/app/layout/home.controller.js @@ -56,6 +56,8 @@ export default function HomeController(types, loginService, userService, deviceS vm.searchTextUpdated = searchTextUpdated; vm.sidenavClicked = sidenavClicked; vm.toggleFullscreen = toggleFullscreen; + vm.openSearch = openSearch; + vm.closeSearch = closeSearch; $scope.$on('$stateChangeSuccess', function (evt, to, toParams, from) { watchEntitySubtype(false); @@ -128,6 +130,25 @@ export default function HomeController(types, loginService, userService, deviceS } } + function openSearch() { + if ($scope.searchConfig.searchEnabled) { + $scope.searchConfig.showSearch = true; + $timeout(() => { + angular.element('#tb-search-text-input', $element).focus(); + }); + } + } + + function closeSearch() { + if ($scope.searchConfig.searchEnabled) { + $scope.searchConfig.showSearch = false; + if ($scope.searchConfig.searchText.length) { + $scope.searchConfig.searchText = ''; + searchTextUpdated(); + } + } + } + function searchTextUpdated() { $scope.$broadcast('searchTextUpdated'); } diff --git a/ui/src/app/layout/home.tpl.html b/ui/src/app/layout/home.tpl.html index 8e642eb7b0..7b6d9c4e4e 100644 --- a/ui/src/app/layout/home.tpl.html +++ b/ui/src/app/layout/home.tpl.html @@ -49,7 +49,7 @@ class="md-icon-button" aria-label="{{ 'action.back' | translate }}" ng-click="vm.goBack()" ng-class="{'tb-invisible': vm.displaySearchMode()}"> arrow_back - + arrow_back
@@ -64,10 +64,10 @@
- + - + search