Focus on the template selector dropdown when interface loads.
This removes the need to use the mouse, and speeds up using the
interface. Pressing tab, then enter will submit
the form with the default template selected.
If the template needs to be changed, then pressing the first letter
of the template will switch between the different options.
This adds a directive named autoFocus to staff/cat/catalog/app.js,
so adding "auto-focus" to an element will cause that element
to have focus on load.
Signed-off-by: Josh Stompro <stompro@stompro.org>
<div class="col-xs-6">
<div class="form-group">
<label for="select-marc-template" class="control-label">[% l('Select MARC template') %]</label>
- <select id="select-marc-template" class="form-control" ng-model="template_name" ng-options="name as name for name in template_list"></select>
+ <select id="select-marc-template" class="form-control" ng-model="template_name" ng-options="name as name for name in template_list" auto-focus></select>
</div>
<button class="btn btn-primary" ng-click="loadTemplate()">[% l('Load') %]</button>
<button class="btn btn-default" ng-click="setDefaultTemplate()">[% l('Set Workstation Default') %]</button>
}])
+
+.directive('autoFocus', function($timeout) {
+ return {
+ restrict: 'AC',
+ link: function(_scope, _element) {
+ $timeout(function(){
+ _element[0].focus();
+ }, 0);
+ }
+ };
+})
+
.controller('CatalogCtrl',
['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast',
'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc',