Last active
May 24, 2016 14:56
-
-
Save Kukks/9ea882e33471784ce2a12c5ddc1baa23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { autoinject } from "aurelia-dependency-injection"; | |
import { Router } from "aurelia-router"; | |
import { ObserverLocator } from "aurelia-binding"; | |
declare var $: any; | |
@autoinject() | |
export class ModalService { | |
constructor( private router: Router, private observerLocator: ObserverLocator ) { | |
this.observeRouterNavigation(); | |
} | |
public closeModal() { | |
$(".lean-overlay").trigger("click"); | |
} | |
private observeRouterNavigation() { | |
this.observerLocator | |
.getObserver(this.router, "isNavigating") | |
.subscribe(( newValue: boolean, oldValue: boolean ) => { | |
if ( !newValue ) { | |
this.closeModal(); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment