Skip to content

Commit ebe7bd6

Browse files
committed
au-tab-panel tests
1 parent f0935e5 commit ebe7bd6

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

au-modal/src/app/app.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ <h1>Modal Examples</h1>
6666
</ng-template>
6767

6868

69-
<au-modal class="auth-modal" [body]="authModalBody"
69+
<au-modal [hideOnClickOutside]="true" [hideOnEscape]="true" class="auth-modal" [body]="authModalBody"
7070
*auModalOpenOnClick="[loginButton, signUpButton]">
7171

7272
</au-modal>

au-modal/src/app/au-modal/au-modal.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="modal-overlay" (click)="closeModal()">
1+
<div class="modal-overlay" (click)="onClickOutsideModal()">
22

33
<div class="modal-body" (click)="cancelClick($event)">
44

au-modal/src/app/au-modal/au-modal.component.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Component, Input, OnInit, TemplateRef} from '@angular/core';
22
import {AuModalService} from "./modal.service";
3+
import {EventManager} from '@angular/platform-browser';
34

45
@Component({
56
selector: 'au-modal',
@@ -11,16 +12,35 @@ export class AuModalComponent implements OnInit {
1112
@Input()
1213
body: TemplateRef<any>;
1314

14-
constructor(private modalService: AuModalService) {
15+
@Input()
16+
hideOnClickOutside = true;
17+
18+
@Input()
19+
hideOnEscape = true;
20+
21+
22+
constructor(private modalService: AuModalService, private eventManager: EventManager) {
23+
this.eventManager.addGlobalEventListener('window', 'keyup.esc', () => {
24+
if (this.hideOnEscape) {
25+
this.closeModal();
26+
}
27+
});
1528
}
1629

1730
ngOnInit() {
1831
}
1932

33+
onClickOutsideModal() {
34+
if (this.hideOnClickOutside) {
35+
this.closeModal();
36+
}
37+
}
38+
2039
closeModal() {
2140
this.modalService.close();
2241
}
2342

43+
2444
cancelClick(evt: KeyboardEvent) {
2545
evt.preventDefault();
2646
evt.stopPropagation();

0 commit comments

Comments
 (0)