ng-model="searchArgs.second_given_name" placeholder="[% l('Middle Name') %]"/>
</div>
- <div class="col-md-2" onmouseover="window.prevElement=document.activeElement">
+ <div class="col-md-2" ng-mouseover="setLastFormElement()">
<input type="submit" class="btn btn-default" value="[% l('Search') %]"/>
</div>
- <div class="col-md-2" onmouseover="window.prevElement=document.activeElement">
+ <div class="col-md-2" ng-mouseover="setLastFormElement()">
<input type="reset" class="btn btn-default" ng-click="clearForm()"
value="[% l('Clear Form') %]"/>
</div>
<div class="col-md-2">
<button class="btn btn-default" ng-click="applyShowExtras($event, true)"
- onmouseover="window.prevElement=document.activeElement"
+ ng-mouseover="setLastFormElement()"
title="[% l('Show More Fields') %]" ng-show="!showExtras">
<span class="glyphicon glyphicon-circle-arrow-down"></span>
</button>
<button class="btn btn-default" ng-click="applyShowExtras($event, false)"
- onmouseover="window.prevElement=document.activeElement"
+ ng-mouseover="setLastFormElement()"
title="[% l('Show Fewer Fields') %]" ng-show="showExtras">
<span class="glyphicon glyphicon-circle-arrow-up"></span>
</button>
*/
.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;
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');
$scope.clearForm = function () {
$scope.searchArgs={};
- window.prevElement.focus();
+ if (lastFormElement) lastFormElement.focus();
}
$scope.applyShowExtras = function($event, bool) {
$scope.showExtras = false;
egCore.hatch.removeItem('eg.circ.patron.search.show_extras');
}
- window.prevElement.focus();
+ if (lastFormElement) lastFormElement.focus();
$event.preventDefault();
}
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