Skip to content
This repository has been archived by the owner on Sep 7, 2020. It is now read-only.

Commit

Permalink
Merge branch 'pr/6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Ludlow committed Mar 5, 2016
2 parents 8b55aca + ed6fef6 commit b995b26
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ Then import and include in your component's directives:
directives: [MODAL_DIRECTIVES]
})

## Example
## Examples

### Example: Default modal

<button type="button" class="btn btn-default" (click)="modal.open()">Open me!</button>

Expand All @@ -39,5 +41,20 @@ Then import and include in your component's directives:
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>

![Example](demo/images/modal.png)

### Example: Static modal
This will create a modal that cannot be closed with the escape key or by clicking outside of the modal.

<button type="button" class="btn btn-default" (click)="modal.open()">Open me!</button>

<modal #modal [keyboard]="false" [backdrop]="'static'">
<modal-header [show-close]="false">
<h4 class="modal-title">I'm a modal!</h4>
</modal-header>
<modal-body>
Hello World!
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>

18 changes: 17 additions & 1 deletion demo/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ <h1>Modal</h1>
<button type="button" class="btn btn-default" (click)="modal.open('lg')">Large modal</button>
<button type="button" class="btn btn-default" (click)="modal.open('sm')">Small modal</button>
<button type="button" class="btn btn-default" (click)="animationsEnabled = !animationsEnabled">Toggle Animation ({{ animationsEnabled }})</button>
<button type="button" class="btn btn-default" (click)="noKeyboardModal.open()">Static</button>
<div [hidden]="!selected">Selection from a modal: {{ selected }}</div>

<modal [animation]="animationsEnabled" (onClose)="onClose($event)" #modal>
Expand All @@ -22,4 +23,19 @@ <h4 class="modal-title">I'm a modal!</h4>
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>
</section>

<modal [animation]="animationsEnabled" [keyboard]="false" [backdrop]="'static'" (onClose)="onClose($event)" #noKeyboardModal>
<modal-header [show-close]="false">
<h4 class="modal-title">Can't close me with your keyboard!</h4>
</modal-header>
<modal-body>
<ul>
<li *ngFor="#item of items">
<a href="#" (click)="$event.preventDefault(); modalSelected = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ modalSelected }}</b>
</modal-body>
<modal-footer [show-default-buttons]="true"></modal-footer>
</modal>
</section>
7 changes: 5 additions & 2 deletions src/ng2-bs3-modal/components/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ declare var jQuery: any;
@Component({
selector: 'modal',
template: `
<div id="{{id}}" class="modal" [ngClass]="{ fade: animation }" tabindex="-1" role="dialog">
<div id="{{id}}" class="modal" [ngClass]="{ fade: animation }" tabindex="-1" role="dialog"
[attr.data-keyboard]="keyboard" [attr.data-backdrop]="backdrop">
<div class="modal-dialog" [ngClass]="{ 'modal-sm': isSmall(), 'modal-lg': isLarge() }">
<div class="modal-content">
<ng-content></ng-content>
Expand All @@ -22,6 +23,8 @@ export class ModalComponent implements AfterViewInit {
hiding: boolean = false;
overrideSize: string = null;
@Input() animation: boolean = true;
@Input() backdrop: string;
@Input() keyboard: boolean;
@Input() size: string;
@Output() onClose: EventEmitter<string> = new EventEmitter();

Expand Down Expand Up @@ -88,4 +91,4 @@ export enum ModalResult {
let id: number = 0;
export function uniqueId(prefix: string): string {
return prefix + ++id;
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"bundles",
"components"
]
}
}

0 comments on commit b995b26

Please sign in to comment.