From 884a75ee4fdae2e7c8ce9a6cae2a2c7a98b7c3bf Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 2 Jan 2015 11:21:43 -0500 Subject: [PATCH] LP#1402797 patron search form focus repairs cont. Building on Mike's original work, use Angular ng-mouseover and the Angular $document built-in. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- .../templates/staff/circ/patron/t_search.tt2 | 8 ++++---- .../web/js/ui/default/staff/circ/patron/app.js | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 index b2034f98cf..bc4e92af19 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_search.tt2 @@ -26,23 +26,23 @@ ng-model="searchArgs.second_given_name" placeholder="[% l('Middle Name') %]"/> -
+
-
+
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 3ce36c5965..d8b373a814 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -716,9 +716,9 @@ function($scope , $location , egCore , egConfirmDialog , egUser , patronSvc) { */ .controller('PatronSearchCtrl', ['$scope','$q','$routeParams','$timeout','$window','$location','egCore', - '$filter','egUser', 'patronSvc','egGridDataProvider', + '$filter','egUser', 'patronSvc','egGridDataProvider','$document', function($scope, $q, $routeParams, $timeout, $window, $location, egCore, - $filter, egUser, patronSvc , egGridDataProvider) { + $filter, egUser, patronSvc , egGridDataProvider , $document) { $scope.initTab('search'); $scope.focusMe = true; @@ -727,6 +727,9 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, home_ou : egCore.org.tree() }; + // last used patron search form element + var lastFormElement; + $scope.gridControls = { activateItem : function(item) { $location.path('/circ/patron/' + item.id() + '/checkout'); @@ -886,7 +889,7 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, $scope.clearForm = function () { $scope.searchArgs={}; - window.prevElement.focus(); + if (lastFormElement) lastFormElement.focus(); } $scope.applyShowExtras = function($event, bool) { @@ -897,7 +900,7 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, $scope.showExtras = false; egCore.hatch.removeItem('eg.circ.patron.search.show_extras'); } - window.prevElement.focus(); + if (lastFormElement) lastFormElement.focus(); $event.preventDefault(); } @@ -960,12 +963,16 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, return sort; } + $scope.setLastFormElement = function() { + lastFormElement = $document[0].activeElement; + } + // search form submit action; tells the results grid to // refresh itself. $scope.search = function(args) { // args === $scope.searchArgs if (args && Object.keys(args).length) $scope.gridControls.refresh(); - window.prevElement.focus(); + if (lastFormElement) lastFormElement.focus(); } // TODO: move this into the (forthcoming) grid row activate action -- 2.43.2