removed properties, replaced with a getter method.

This commit is contained in:
Niels Lyngsø
2019-05-08 15:09:01 +02:00
parent e906808a9b
commit 4c23d7fec9
2 changed files with 11 additions and 6 deletions

View File

@@ -27,7 +27,7 @@
vm.focusSearch = focusSearch;
//we need to capture the focus before this element is initialized.
vm.focusBeforeOpening = focusService.lastKnownFocus;
vm.focusBeforeOpening = focusService.getLastKnownFocus();
function onInit() {
vm.searchQuery = "";

View File

@@ -13,14 +13,17 @@
function focusService() {
var currentFocus = null;
var lastKnownFocus = null;
function focusInApp(e) {
service.currentFocus = e.target;
currentFocus = e.target;
}
document.addEventListener('focusin', focusInApp);
var service = {
currentFocus: null,
/**
* @ngdoc property
@@ -32,7 +35,9 @@
* This variable is avaiable for directives that are not able to figure out the focused element on init, and there this service will help remembering it untill the directive is initialized.
*
*/
lastKnownFocus: null,
getLastKnownFocus: function() {
return lastKnownFocus;
},
/**
* @ngdoc function
@@ -45,7 +50,7 @@
*
*/
rememberFocus: function() {
service.lastKnownFocus = service.currentFocus;
lastKnownFocus = currentFocus;
},
/**
@@ -59,7 +64,7 @@
*
*/
setLastKnownFocus: function(element) {
service.lastKnownFocus = element;
lastKnownFocus = element;
}
};