From ec88c96317321dd89f8acb3405c7efc7e473fad5 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Fri, 10 Apr 2015 12:33:26 -0400 Subject: [PATCH] webstaff: Teach access keys how to deal with ng-click actions and empty hrefs Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/web/js/ui/default/staff/services/navbar.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/navbar.js b/Open-ILS/web/js/ui/default/staff/services/navbar.js index 1d7f0adb07..6a32056bf4 100644 --- a/Open-ILS/web/js/ui/default/staff/services/navbar.js +++ b/Open-ILS/web/js/ui/default/staff/services/navbar.js @@ -17,7 +17,8 @@ angular.module('egCoreMod') scope.addHotkey( elm.attr('eg-accesskey'), elm.attr('href'), - elm.attr('eg-accesskey-desc') + elm.attr('eg-accesskey-desc'), + elm ); } angular.forEach(elm.children(), inspect); @@ -25,8 +26,8 @@ angular.module('egCoreMod') inspect(element); }, - controller:['$scope','$window','$location','hotkeys','egCore', - function($scope , $window , $location , hotkeys , egCore) { + controller:['$scope','$window','$location','$timeout','hotkeys','egCore', + function($scope , $window , $location , $timeout , hotkeys , egCore) { function navTo(path) { // $location.path() does not want a leading ".", @@ -41,12 +42,16 @@ angular.module('egCoreMod') // adds a keyboard shortcut // http://chieffancypants.github.io/angular-hotkeys/ - $scope.addHotkey = function(key, path, desc) { + $scope.addHotkey = function(key, path, desc, elm) { hotkeys.add({ combo: key, allowIn: ['INPUT','SELECT','TEXTAREA'], description: desc, - callback: function(e) { e.preventDefault(); navTo(path); } + callback: function(e) { + e.preventDefault(); + if (path) return navTo(path); + return $timeout(function(){$(elm).trigger('click')}); + } }); }; -- 2.11.0