Skip to content

Commit

Permalink
Fixed #2413
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Mar 29, 2017
1 parent 64797a5 commit ec06e44
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 49 deletions.
45 changes: 12 additions & 33 deletions components/dialog/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,OnDestroy,Input,Output,EventEmitter,Renderer,ContentChild,ViewChild} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,Renderer,ContentChild,ViewChild} from '@angular/core';
import {trigger,state,style,transition,animate} from '@angular/animations';
import {CommonModule} from '@angular/common';
import {DomHandler} from '../dom/domhandler';
Expand All @@ -15,7 +15,7 @@ import {Header,SharedModule} from '../common/shared';
<span class="ui-dialog-title" *ngIf="headerFacet">
<ng-content select="p-header"></ng-content>
</span>
<a *ngIf="closable" [ngClass]="{'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all':true}" href="#" role="button" (click)="onCloseClick($event)">
<a *ngIf="closable" [ngClass]="{'ui-dialog-titlebar-icon ui-dialog-titlebar-close ui-corner-all':true}" href="#" role="button" (click)="close($event)">
<span class="fa fa-fw fa-close"></span>
</a>
</div>
Expand All @@ -41,7 +41,7 @@ import {Header,SharedModule} from '../common/shared';
],
providers: [DomHandler]
})
export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {
export class Dialog implements AfterViewInit,OnDestroy {

@Input() header: string;

Expand Down Expand Up @@ -85,13 +85,9 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {

@ViewChild('content') contentViewChild: ElementRef;

@Output() onBeforeShow: EventEmitter<any> = new EventEmitter();
@Output() onShow: EventEmitter<any> = new EventEmitter();

@Output() onAfterShow: EventEmitter<any> = new EventEmitter();

@Output() onBeforeHide: EventEmitter<any> = new EventEmitter();

@Output() onAfterHide: EventEmitter<any> = new EventEmitter();
@Output() onHide: EventEmitter<any> = new EventEmitter();

@Output() visibleChange:EventEmitter<any> = new EventEmitter();

Expand All @@ -118,11 +114,7 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {
lastPageY: number;

mask: HTMLDivElement;

shown: boolean;

hidden: boolean;


container: HTMLDivElement;

contentContainer: HTMLDivElement;
Expand All @@ -143,21 +135,9 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {
else
this.hide();
}

ngAfterViewChecked() {
if(this.shown) {
this.onAfterShow.emit({});
this.shown = false;
}
else if(this.hidden) {
this.onAfterHide.emit(event);
this.hidden = false;
}
}


show() {
this.shown = true;
this.onBeforeShow.emit({});
this.onShow.emit({});

if(!this.positionInitialized) {
this.center();
Expand All @@ -172,16 +152,15 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {
}

hide() {
this.hidden = true;
this.onBeforeHide.emit(event);
this.onHide.emit({});
this.unbindMaskClickListener();

if(this.modal) {
this.disableModality();
}
}

onCloseClick(event?: Event) {
close(event: Event) {
this.hide();
this.visibleChange.emit(false);
event.preventDefault();
Expand Down Expand Up @@ -219,7 +198,7 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {
this.documentEscapeListener = this.renderer.listenGlobal('body', 'keydown', (event) => {
if(event.which == 27) {
if(parseInt(this.container.style.zIndex) == DomHandler.zindex) {
this.hide(event);
this.close(event);
}
}
});
Expand Down Expand Up @@ -260,7 +239,7 @@ export class Dialog implements AfterViewInit,AfterViewChecked,OnDestroy {

if(this.closable && this.dismissableMask) {
this.maskClickListener = this.renderer.listen(this.mask, 'click', (event: any) => {
this.hide(event);
this.close(event);
});
}
document.body.appendChild(this.mask);
Expand Down
18 changes: 4 additions & 14 deletions showcase/demo/dialog/dialogdemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,14 @@ <h3>Events</h3>
</thead>
<tbody>
<tr>
<td>onBeforeShow</td>
<td>onShow</td>
<td>event: Event object</td>
<td>Callback to invoke before dialog is shown.</td>
<td>Callback to invoke when dialog is shown.</td>
</tr>
<tr>
<td>onAfterShow</td>
<td>onHide</td>
<td>event: Event object</td>
<td>Callback to invoke after dialog is shown.</td>
</tr>
<tr>
<td>onBeforeHide</td>
<td>event: Event object</td>
<td>Callback to invoke before dialog is hidden.</td>
</tr>
<tr>
<td>onAfterHide</td>
<td>event: Event object</td>
<td>Callback to invoke after dialog is hidden.</td>
<td>Callback to invoke when dialog is hidden.</td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 2 additions & 2 deletions showcase/demo/tree/treedemo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export class TreeDemo implements OnInit {
}

expandAll(){
this.filesTree6.forEach( node => {
this.filesTree10.forEach( node => {
this.expandRecursive(node, true);
} );
}

collapseAll(){
this.filesTree6.forEach( node => {
this.filesTree10.forEach( node => {
this.expandRecursive(node, false);
} );
}
Expand Down

0 comments on commit ec06e44

Please sign in to comment.