diff --git a/src/main/webapp/app/directives/keyboardActivateDirective.js b/src/main/webapp/app/directives/keyboardActivateDirective.js new file mode 100644 index 0000000000..8d122dea75 --- /dev/null +++ b/src/main/webapp/app/directives/keyboardActivateDirective.js @@ -0,0 +1,34 @@ +vireo.directive('keyboardActivate', function() { + return { + restrict: 'A', + link: function($scope, element) { + + // Anything exposed as role="button" must also respond to Enter and + // Space. Native buttons and links already do, so leave those alone + // rather than activating them twice. + var nativelyActivated = ['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA']; + + if (nativelyActivated.indexOf(element[0].nodeName) > -1) { + return; + } + + // Bound natively instead of with ng-keydown. ng-keydown would run + // inside a digest, and the click dispatched below starts its own, + // which would throw "$apply already in progress". + element.on('keydown', function(event) { + + if (event.which !== 13 && event.which !== 32) { + return; + } + + // Space would otherwise scroll the page. + event.preventDefault(); + + // A real click rather than the scope expression, so it bubbles + // to whichever element owns the ng-click. For some of the edit + // icons that is an ancestor, not the icon itself. + element[0].click(); + }); + } + }; +}); diff --git a/src/main/webapp/app/resources/styles/sass/app.scss b/src/main/webapp/app/resources/styles/sass/app.scss index 1ba8ab43ed..2ac804a76a 100644 --- a/src/main/webapp/app/resources/styles/sass/app.scss +++ b/src/main/webapp/app/resources/styles/sass/app.scss @@ -672,6 +672,20 @@ h4 { cursor: pointer; } +// Revealed on row hover, but kept in the layout rather than removed, so that it +// stays focusable for keyboard users. Focus reveals it the same way hover does. +.edit-setting-icon.edit-setting-icon-hidden { + opacity: 0; + pointer-events: none; +} + +.edit-setting-icon:focus, +.edit-setting-icon.edit-setting-icon-hidden:focus { + opacity: 1; + outline: 1px dotted; + pointer-events: auto; +} + .td-center-middle { text-align: center; vertical-align: middle; @@ -1649,12 +1663,19 @@ input[type=color]:focus { cursor: pointer; } +// Hidden with opacity rather than visibility so the icon stays focusable; a +// visibility: hidden element is dropped from the tab order entirely. .email-workflow-rule-row span.glyphicon-pencil { - visibility: hidden; + opacity: 0; } -.email-workflow-rule-row:hover span.glyphicon-pencil { - visibility: visible; +.email-workflow-rule-row:hover span.glyphicon-pencil, +.email-workflow-rule-row span.glyphicon-pencil:focus { + opacity: 1; +} + +.email-workflow-rule-row span.glyphicon-pencil:focus { + outline: 1px dotted; } .submission-review-item { diff --git a/src/main/webapp/app/views/admin/settings/organization/emailWorkflowRule.html b/src/main/webapp/app/views/admin/settings/organization/emailWorkflowRule.html index 8dadb43446..99dca12281 100644 --- a/src/main/webapp/app/views/admin/settings/organization/emailWorkflowRule.html +++ b/src/main/webapp/app/views/admin/settings/organization/emailWorkflowRule.html @@ -21,7 +21,7 @@ ng-repeat="rule in getSelectedOrganizationEmailWorkflowRules()" class="email-workflow-rule-row"> - + {{rule.emailTemplate.name}} diff --git a/src/main/webapp/app/views/admin/settings/workflow/controlledVocabularyManagement.html b/src/main/webapp/app/views/admin/settings/workflow/controlledVocabularyManagement.html index ae3e7c0844..c7b05156a4 100644 --- a/src/main/webapp/app/views/admin/settings/workflow/controlledVocabularyManagement.html +++ b/src/main/webapp/app/views/admin/settings/workflow/controlledVocabularyManagement.html @@ -124,7 +124,7 @@ - +
diff --git a/src/main/webapp/app/views/admin/view.html b/src/main/webapp/app/views/admin/view.html index da3298c320..3391b93976 100644 --- a/src/main/webapp/app/views/admin/view.html +++ b/src/main/webapp/app/views/admin/view.html @@ -32,7 +32,7 @@

REVIEWER NOTES

- + {{submission.reviewerNotes || 'none'}}
@@ -82,7 +82,7 @@

ALL FILES

{{documentFieldValue.fileInfo.time | date : 'MM/dd/yyyy h:mm:ss a' }} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropControlledVocabulary.html b/src/main/webapp/app/views/directives/dragAndDropControlledVocabulary.html index 04b38cfe04..8000809350 100644 --- a/src/main/webapp/app/views/directives/dragAndDropControlledVocabulary.html +++ b/src/main/webapp/app/views/directives/dragAndDropControlledVocabulary.html @@ -3,5 +3,5 @@ {{ item[property] }} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropCustomAction.html b/src/main/webapp/app/views/directives/dragAndDropCustomAction.html index d74c9cf879..38533c781d 100644 --- a/src/main/webapp/app/views/directives/dragAndDropCustomAction.html +++ b/src/main/webapp/app/views/directives/dragAndDropCustomAction.html @@ -1,12 +1,18 @@
{{ item.position }}. + ng-mouseleave="isMouseHover=false" + ng-focus="isMouseHover=true" + ng-blur="isMouseHover=false"> {{item.label}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropDegree.html b/src/main/webapp/app/views/directives/dragAndDropDegree.html index 902adf8689..3ce018a4b4 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDegree.html +++ b/src/main/webapp/app/views/directives/dragAndDropDegree.html @@ -1,5 +1,5 @@
{{ item.position }}. {{item[properties[0]]}} ({{item[properties[1]].name}}) - +
diff --git a/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html b/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html index 23615c9ca7..6f193bcae1 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html +++ b/src/main/webapp/app/views/directives/dragAndDropDepositLocation.html @@ -1,5 +1,5 @@
{{ item.position }}. {{item[property]}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropDocumentType.html b/src/main/webapp/app/views/directives/dragAndDropDocumentType.html index b2ff8a094b..3e4ac4dc41 100644 --- a/src/main/webapp/app/views/directives/dragAndDropDocumentType.html +++ b/src/main/webapp/app/views/directives/dragAndDropDocumentType.html @@ -4,5 +4,5 @@ {{item[property]}} - +
diff --git a/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html b/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html index dce24e8a56..33ad7cac9c 100644 --- a/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html +++ b/src/main/webapp/app/views/directives/dragAndDropEmailTemplates.html @@ -3,5 +3,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html b/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html index 628c1b9562..22d52cf8a4 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldGloss.html @@ -4,5 +4,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html b/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html index 628c1b9562..22d52cf8a4 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldPredicate.html @@ -4,5 +4,5 @@ {{item[property]}} - + diff --git a/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html b/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html index a606c48c29..2a2566a05d 100644 --- a/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html +++ b/src/main/webapp/app/views/directives/dragAndDropFieldProfile.html @@ -3,6 +3,6 @@ {{ item[property] }}* - + diff --git a/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html b/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html index 491e2c399b..cfd6d05494 100644 --- a/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html +++ b/src/main/webapp/app/views/directives/dragAndDropGraduationMonth.html @@ -1,5 +1,5 @@
{{ item.position }}. {{toString({month:item[property]})}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropLanguage.html b/src/main/webapp/app/views/directives/dragAndDropLanguage.html index 2ff9c304bd..0e0a626f9e 100644 --- a/src/main/webapp/app/views/directives/dragAndDropLanguage.html +++ b/src/main/webapp/app/views/directives/dragAndDropLanguage.html @@ -4,5 +4,5 @@ {{ item[property] }} - + \ No newline at end of file diff --git a/src/main/webapp/app/views/directives/dragAndDropNote.html b/src/main/webapp/app/views/directives/dragAndDropNote.html index b4889dc057..08e1215a1e 100644 --- a/src/main/webapp/app/views/directives/dragAndDropNote.html +++ b/src/main/webapp/app/views/directives/dragAndDropNote.html @@ -1,6 +1,6 @@
{{ item.position }}. {{ item[property] }} - +
diff --git a/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html b/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html index ab73542b79..cdbff2ea6a 100644 --- a/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html +++ b/src/main/webapp/app/views/directives/dragAndDropOrganizationCategory.html @@ -1,4 +1,4 @@
{{item[property]}} - +
\ No newline at end of file diff --git a/src/main/webapp/app/views/directives/lockingTextArea.html b/src/main/webapp/app/views/directives/lockingTextArea.html index 7b0a509735..b01a41d2fd 100644 --- a/src/main/webapp/app/views/directives/lockingTextArea.html +++ b/src/main/webapp/app/views/directives/lockingTextArea.html @@ -7,7 +7,7 @@

{{ label }}
- This field is unlocked and may be edited. Leaving the editable area will save and re-lock the field. + This field is unlocked and may be edited. Leaving the editable area will save and re-lock the field.

diff --git a/src/main/webapp/app/views/directives/submissionInfo.html b/src/main/webapp/app/views/directives/submissionInfo.html index 9fed99683f..645700e293 100644 --- a/src/main/webapp/app/views/directives/submissionInfo.html +++ b/src/main/webapp/app/views/directives/submissionInfo.html @@ -70,7 +70,7 @@ - + diff --git a/src/main/webapp/app/views/myprofile.html b/src/main/webapp/app/views/myprofile.html index 886d9343aa..9db456e974 100644 --- a/src/main/webapp/app/views/myprofile.html +++ b/src/main/webapp/app/views/myprofile.html @@ -59,7 +59,7 @@

Personal Information

- + {{settings.user.displayName}} @@ -122,7 +122,7 @@

Phone & Address

- + {{settings.user.preferedEmail}} diff --git a/src/main/webapp/app/views/sideboxes/submissionStatus.html b/src/main/webapp/app/views/sideboxes/submissionStatus.html index 4a85431e37..10e5da5f23 100644 --- a/src/main/webapp/app/views/sideboxes/submissionStatus.html +++ b/src/main/webapp/app/views/sideboxes/submissionStatus.html @@ -3,7 +3,7 @@
  • Assignee:
  • - +
  • Last Action:
  • {{box.getLastActionDate() | date : 'short'}}
  • @@ -20,7 +20,7 @@ is-open="date" close-text="Close" stringtodate> - {{box.submission.submissionDate || "not submitted" | date: 'M/d/yyyy' : 'UTC'}} + {{box.submission.submissionDate || "not submitted" | date: 'M/d/yyyy' : 'UTC'}}
  • diff --git a/src/main/webapp/tests/unit/directives/keyboardActivateDirectiveTest.js b/src/main/webapp/tests/unit/directives/keyboardActivateDirectiveTest.js new file mode 100644 index 0000000000..8d1dc0bdfa --- /dev/null +++ b/src/main/webapp/tests/unit/directives/keyboardActivateDirectiveTest.js @@ -0,0 +1,135 @@ +describe('directive: keyboardActivate', function () { + var compile, directive, httpBackend, rootScope, scope, templateCache, window, MockedUser; + + var ENTER = 13; + var SPACE = 32; + + var initializeVariables = function () { + inject(function ($q, $compile, $httpBackend, $rootScope, $templateCache, $window) { + compile = $compile; + httpBackend = $httpBackend; + rootScope = $rootScope; + templateCache = $templateCache; + window = $window; + MockedUser = new mockUser($q); + }); + }; + + var initializeDirective = function (markup) { + inject(function () { + scope = rootScope.$new(); + scope.activate = jasmine.createSpy('activate'); + + directive = compile(markup || '')(scope); + + scope.$digest(); + }); + }; + + // The event object is extended onto whatever event the element library + // hands the handler, so a spy here is called in place of the real + // preventDefault whether jqLite or jQuery is in play. + var keydown = function (element, which) { + var event = { + type: 'keydown', + which: which, + preventDefault: jasmine.createSpy('preventDefault') + }; + + element.triggerHandler(event); + + return event; + }; + + beforeEach(function() { + module('core'); + module('vireo'); + module("mock.user", function ($provide) { + var User = function () { + return MockedUser; + }; + $provide.value("User", User); + }); + module("mock.userService"); + + installPromiseMatchers(); + initializeVariables(); + }); + + describe('Does the directive compile', function () { + it('should be defined', function () { + initializeDirective(); + expect(directive).toBeDefined(); + }); + }); + + describe('Is the element activated by the keyboard', function () { + it('should activate on enter', function () { + initializeDirective(); + + keydown(directive, ENTER); + + expect(scope.activate).toHaveBeenCalled(); + }); + + it('should activate on space', function () { + initializeDirective(); + + keydown(directive, SPACE); + + expect(scope.activate).toHaveBeenCalled(); + }); + + it('should not activate on any other key', function () { + initializeDirective(); + + keydown(directive, 65); + + expect(scope.activate).not.toHaveBeenCalled(); + }); + + it('should prevent the default action when activating', function () { + initializeDirective(); + + var event = keydown(directive, SPACE); + + expect(event.preventDefault).toHaveBeenCalled(); + }); + + it('should leave the default action alone for any other key', function () { + initializeDirective(); + + var event = keydown(directive, 65); + + expect(event.preventDefault).not.toHaveBeenCalled(); + }); + }); + + describe('Is an ancestor handler reached', function () { + it('should activate a handler on a parent element', function () { + initializeDirective('
    '); + + keydown(angular.element(directive[0].querySelector('span')), ENTER); + + expect(scope.activate).toHaveBeenCalled(); + }); + }); + + describe('Are natively activated elements left alone', function () { + it('should not bind to a button, which the browser already activates', function () { + initializeDirective(''); + + keydown(directive, ENTER); + + expect(scope.activate).not.toHaveBeenCalled(); + }); + + it('should not bind to an anchor, which the browser already activates', function () { + initializeDirective(''); + + keydown(directive, ENTER); + + expect(scope.activate).not.toHaveBeenCalled(); + }); + }); +});