Skip to content

Commit

Permalink
feat(bootstrap): support bootstrap 4
Browse files Browse the repository at this point in the history
Fixes #280
  • Loading branch information
Shlomi Assaf (shlassaf) committed Aug 11, 2017
1 parent f96c12c commit 23cb2a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/angular2-modal/plugins/bootstrap/src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export {
PromptPreset,
PromptPresetBuilder
} from './presets/two-button-preset';
export { Modal } from './modal';
export { Modal, bootstrap4Mode } from './modal';

export { BootstrapModalModule, providers } from './bootstrap.module';
17 changes: 13 additions & 4 deletions src/angular2-modal/plugins/bootstrap/src/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ import { TwoButtonPresetBuilder, PromptPresetBuilder } from './presets/two-butto
// TODO: consolidate dup code
const isDoc: boolean = !(typeof document === 'undefined' || !document);

let animationClass: string = 'in';

/**
* Execute this method to flag that you are working with Bootstrap version 4.
*/
export function bootstrap4Mode(): void {
animationClass = 'show';
}

@Injectable()
export class Modal extends Modal_ {
constructor(overlay: Overlay) {
Expand Down Expand Up @@ -66,17 +75,17 @@ export class Modal extends Modal_ {
}
backdrop.addClass('modal-backdrop fade', true);

backdrop.addClass('in');
container.addClass('in');
backdrop.addClass(animationClass);
container.addClass(animationClass);

if (containerRef.location.nativeElement) {
containerRef.location.nativeElement.focus();
}

overlay.beforeDestroy(() => {
const completer = new PromiseCompleter<void>();
backdrop.removeClass('in');
container.removeClass('in');
backdrop.removeClass(animationClass);
container.removeClass(animationClass);

combineLatest.call(backdrop.myAnimationEnd$(), container.myAnimationEnd$(), (s1, s2) => [s1,s2])
.subscribe( sources => {
Expand Down

0 comments on commit 23cb2a0

Please sign in to comment.