support for toggling custom context menu (#1683)

* support for toggling custom context menu

* fix unit tests
This commit is contained in:
Denys Vuika
2017-03-03 09:25:08 +00:00
committed by Mario Romano
parent 0f718a56d7
commit a3cda4d958
8 changed files with 30 additions and 14 deletions

View File

@@ -25,18 +25,23 @@ export class ContextMenuDirective {
@Input('context-menu')
links: any[];
@Input('context-menu-enabled')
enabled: boolean = false;
constructor(private _contextMenuService: ContextMenuService) {
}
@HostListener('contextmenu', ['$event'])
onShowContextMenu(event?: MouseEvent) {
if (event) {
event.preventDefault();
}
if (this.enabled) {
if (event) {
event.preventDefault();
}
if (this.links && this.links.length > 0) {
if (this._contextMenuService) {
this._contextMenuService.show.next({event: event, obj: this.links});
if (this.links && this.links.length > 0) {
if (this._contextMenuService) {
this._contextMenuService.show.next({event: event, obj: this.links});
}
}
}
}