Skip to content

Commit

Permalink
Merge branch 'bugfix/SHIBUI-354' of bitbucket.org:unicon/shib-idp-ui …
Browse files Browse the repository at this point in the history
…into a11y/SHIBUI-354
  • Loading branch information
Jodie Muramoto committed Oct 11, 2018
2 parents 97a87f4 + 7b85342 commit 2b21fe9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
10 changes: 8 additions & 2 deletions ui/src/app/shared/component/info-icon.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<ng-template #tooltipContent>
<span #content>{{ description }}</span>
<span #content [attr.aria-label]="description" [id]="id">{{ description }}</span>
</ng-template>
<button class="btn btn-nostyle info-icon"
#toggle="ngbPopover"
[attr.aria-label]="'tooltip.instruction' | translate"
[attr.aria-expanded]="toggle.isOpen()"
[ngbPopover]="tooltipContent"
aria-haspopup="true">
(keydown.space)="toggle.open()"
(keyup.space)="toggle.close()"
[triggers]="triggers"
[placement]="placement"
aria-haspopup="true"
[attr.aria-flowto]="id"
role="button">
<i class="fa fa-fw fa-info-circle text-primary fa-lg"></i>
<span class="sr-only" translate="tooltip.instruction"></span>
</button>
17 changes: 16 additions & 1 deletion ui/src/app/shared/component/info-icon.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, Input, ChangeDetectionStrategy, ElementRef, ViewChild } from '@angular/core';
import { Component, Input, ChangeDetectionStrategy, Renderer } from '@angular/core';
import { NgbPopover, NgbPopoverConfig } from '@ng-bootstrap/ng-bootstrap';

@Component({
selector: 'info-icon',
Expand All @@ -8,4 +9,18 @@ import { Component, Input, ChangeDetectionStrategy, ElementRef, ViewChild } from
})
export class InfoIconComponent {
@Input() description: string;

id: string = String.fromCharCode(65 + Math.floor(Math.random() * 26)) + Date.now().toString();

triggers = 'mouseenter:mouseleave';
container = 'body';
placement = ['top'];

constructor(
private renderer: Renderer
) { }
focus(element): void {
console.log(element.elementRef.nativeElement);
this.renderer.invokeElementMethod(element.elementRef.nativeElement, 'focus');
}
}
11 changes: 1 addition & 10 deletions ui/src/app/shared/directive/info-label.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@ import { NgbPopover } from '@ng-bootstrap/ng-bootstrap';
providers: [NgbPopover]
})
export class InfoLabelDirective {
@HostListener('keydown.space') onSpaceDown() {
this.config.open();
}
@HostListener('keyup.space') onSpaceUp() {
this.config.close();
}
constructor(
private config: NgbPopover,
private element: ElementRef
) {
config.triggers = 'mouseenter:mouseleave';
config.placement = ['top', 'left'];
config.container = 'body';
element.nativeElement.setAttribute('tabindex', 0);

}
}

0 comments on commit 2b21fe9

Please sign in to comment.