Skip to content

Commit

Permalink
Fixed #2764
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed May 29, 2017
1 parent fdc52bf commit 69edcf6
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 73 deletions.
6 changes: 3 additions & 3 deletions components/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ViewChild,ElementRef,AfterViewInit,AfterContentInit,AfterViewChecked,Input,Output,EventEmitter,ContentChildren,QueryList,TemplateRef,Renderer,forwardRef,ChangeDetectorRef} from '@angular/core';
import {NgModule,Component,ViewChild,ElementRef,AfterViewInit,AfterContentInit,AfterViewChecked,Input,Output,EventEmitter,ContentChildren,QueryList,TemplateRef,Renderer2,forwardRef,ChangeDetectorRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {InputTextModule} from '../inputtext/inputtext';
import {ButtonModule} from '../button/button';
Expand Down Expand Up @@ -154,7 +154,7 @@ export class AutoComplete implements AfterViewInit,AfterViewChecked,ControlValue

noResults: boolean;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, public objectUtils: ObjectUtils, public cd: ChangeDetectorRef) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2, public objectUtils: ObjectUtils, public cd: ChangeDetectorRef) {}

@Input() get suggestions(): any[] {
return this._suggestions;
Expand Down Expand Up @@ -486,7 +486,7 @@ export class AutoComplete implements AfterViewInit,AfterViewChecked,ControlValue

bindDocumentClickListener() {
if(!this.documentClickListener) {
this.documentClickListener = this.renderer.listenGlobal('document', 'click', (event) => {
this.documentClickListener = this.renderer.listen('document', 'click', (event) => {
if(event.which === 3) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions components/calendar/calendar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,OnDestroy,OnInit,Input,Output,SimpleChange,EventEmitter,forwardRef,Renderer,ViewChild,ChangeDetectorRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,OnDestroy,OnInit,Input,Output,SimpleChange,EventEmitter,forwardRef,Renderer2,ViewChild,ChangeDetectorRef} from '@angular/core';
import {trigger,state,style,transition,animate} from '@angular/animations';
import {CommonModule} from '@angular/common';
import {ButtonModule} from '../button/button';
Expand Down Expand Up @@ -330,7 +330,7 @@ export class Calendar implements AfterViewInit,AfterViewChecked,OnInit,OnDestroy
this.createMonth(this.currentMonth, this.currentYear);
}

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, public cd: ChangeDetectorRef) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2, public cd: ChangeDetectorRef) {}

ngOnInit() {
let date = this.defaultDate||new Date();
Expand Down Expand Up @@ -1243,7 +1243,7 @@ export class Calendar implements AfterViewInit,AfterViewChecked,OnInit,OnDestroy

bindDocumentClickListener() {
if(!this.documentClickListener) {
this.documentClickListener = this.renderer.listenGlobal('document', 'click', () => {
this.documentClickListener = this.renderer.listen('document', 'click', () => {
if(this.closeOverlay) {
this.overlayVisible = false;
}
Expand Down
6 changes: 3 additions & 3 deletions components/carousel/carousel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,AfterContentInit,EventEmitter,OnDestroy,Input,Output,TemplateRef,ContentChildren,QueryList,Renderer,ViewChild} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterViewChecked,AfterContentInit,EventEmitter,OnDestroy,Input,Output,TemplateRef,ContentChildren,QueryList,Renderer2,ViewChild} from '@angular/core';
import {DomHandler} from '../dom/domhandler';
import {SharedModule,PrimeTemplate} from '../common/shared';
import {CommonModule} from '@angular/common';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class Carousel implements AfterViewChecked,AfterViewInit,OnDestroy{

differ: any;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2) {}

ngAfterContentInit() {
this.templates.forEach((item) => {
Expand Down Expand Up @@ -153,7 +153,7 @@ export class Carousel implements AfterViewChecked,AfterViewInit,OnDestroy{
this.itemsContainer = this.domHandler.findSingle(this.el.nativeElement, 'ul.ui-carousel-items');

if(this.responsive) {
this.documentResponsiveListener = this.renderer.listenGlobal('window', 'resize', (event) => {
this.documentResponsiveListener = this.renderer.listen('window', 'resize', (event) => {
this.updateState();
});
}
Expand Down
8 changes: 4 additions & 4 deletions components/confirmdialog/confirmdialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,Renderer,ContentChild} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,Renderer2,ContentChild} from '@angular/core';
import {trigger,state,style,transition,animate} from '@angular/animations';
import {CommonModule} from '@angular/common';
import {DomHandler} from '../dom/domhandler';
Expand Down Expand Up @@ -100,7 +100,7 @@ export class ConfirmDialog implements AfterViewInit,OnDestroy {
subscription: Subscription;

constructor(public el: ElementRef, public domHandler: DomHandler,
public renderer: Renderer, private confirmationService: ConfirmationService) {
public renderer: Renderer2, private confirmationService: ConfirmationService) {
this.subscription = confirmationService.requireConfirmation$.subscribe(confirmation => {
if(confirmation.key === this.key) {
this.confirmation = confirmation;
Expand Down Expand Up @@ -151,13 +151,13 @@ export class ConfirmDialog implements AfterViewInit,OnDestroy {
this.contentContainer = this.domHandler.findSingle(this.el.nativeElement, '.ui-dialog-content');

if(this.responsive) {
this.documentResponsiveListener = this.renderer.listenGlobal('window', 'resize', (event) => {
this.documentResponsiveListener = this.renderer.listen('window', 'resize', (event) => {
this.center();
});
}

if(this.closeOnEscape && this.closable) {
this.documentEscapeListener = this.renderer.listenGlobal('document', 'keydown', (event) => {
this.documentEscapeListener = this.renderer.listen('document', 'keydown', (event) => {
if(event.which == 27) {
if(this.el.nativeElement.children[0].style.zIndex == DomHandler.zindex) {
this.hide(event);
Expand Down
8 changes: 4 additions & 4 deletions components/contextmenu/contextmenu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,Renderer,EventEmitter,Inject,forwardRef,ViewChild} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,Renderer2,EventEmitter,Inject,forwardRef,ViewChild} from '@angular/core';
import {CommonModule} from '@angular/common';
import {DomHandler} from '../dom/domhandler';
import {MenuItem} from '../common/api';
Expand Down Expand Up @@ -151,17 +151,17 @@ export class ContextMenu implements AfterViewInit,OnDestroy {

rightClickListener: any;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2) {}

ngAfterViewInit() {
this.container = <HTMLDivElement> this.containerViewChild.nativeElement;

this.documentClickListener = this.renderer.listenGlobal('document', 'click', () => {
this.documentClickListener = this.renderer.listen('document', 'click', () => {
this.hide();
});

if(this.global) {
this.rightClickListener = this.renderer.listenGlobal('document', 'contextmenu', (event) => {
this.rightClickListener = this.renderer.listen('document', 'contextmenu', (event) => {
this.show(event);
event.preventDefault();
});
Expand Down
6 changes: 3 additions & 3 deletions components/datascroller/datascroller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,Input,Output,Renderer,ViewChild,EventEmitter,ContentChild,ContentChildren,QueryList,TemplateRef} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,AfterContentInit,OnDestroy,Input,Output,Renderer2,ViewChild,EventEmitter,ContentChild,ContentChildren,QueryList,TemplateRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {Header,Footer,PrimeTemplate,SharedModule} from '../common/shared';
import {DomHandler} from '../dom/domhandler';
Expand Down Expand Up @@ -64,7 +64,7 @@ export class DataScroller implements AfterViewInit,OnDestroy {

contentElement: HTMLDivElement;

constructor(public el: ElementRef, public renderer: Renderer, public domHandler: DomHandler) {}
constructor(public el: ElementRef, public renderer: Renderer2, public domHandler: DomHandler) {}

ngAfterViewInit() {
if(this.lazy) {
Expand Down Expand Up @@ -167,7 +167,7 @@ export class DataScroller implements AfterViewInit,OnDestroy {
});
}
else {
this.scrollFunction = this.renderer.listenGlobal('window', 'scroll', () => {
this.scrollFunction = this.renderer.listen('window', 'scroll', () => {
let docBody = document.body;
let docElement = document.documentElement;
let scrollTop = (window.pageYOffset||document.documentElement.scrollTop);
Expand Down
22 changes: 11 additions & 11 deletions components/datatable/datatable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgModule,Component,ElementRef,AfterContentInit,AfterViewInit,AfterViewChecked,OnInit,OnDestroy,Input,ViewContainerRef,ViewChild,
Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,Renderer,QueryList,TemplateRef,ChangeDetectorRef,Inject,forwardRef} from '@angular/core';
Output,SimpleChange,EventEmitter,ContentChild,ContentChildren,Renderer2,QueryList,TemplateRef,ChangeDetectorRef,Inject,forwardRef} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms'
import {SharedModule} from '../common/shared';
Expand Down Expand Up @@ -252,7 +252,7 @@ export class TableBody {
})
export class ScrollableView implements AfterViewInit,AfterViewChecked,OnDestroy {

constructor(@Inject(forwardRef(() => DataTable)) public dt:DataTable, public domHandler: DomHandler, public el: ElementRef, public renderer: Renderer) {}
constructor(@Inject(forwardRef(() => DataTable)) public dt:DataTable, public domHandler: DomHandler, public el: ElementRef, public renderer: Renderer2) {}

@Input("pScrollableView") columns: Column[];

Expand Down Expand Up @@ -704,7 +704,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
columnsSubscription: Subscription;

constructor(public el: ElementRef, public domHandler: DomHandler,
public renderer: Renderer, public changeDetector: ChangeDetectorRef, public objectUtils: ObjectUtils) {
public renderer: Renderer2, public changeDetector: ChangeDetectorRef, public objectUtils: ObjectUtils) {
}

ngOnInit() {
Expand Down Expand Up @@ -763,7 +763,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
}

if(this.editable) {
this.documentClickListener = this.renderer.listenGlobal('document', 'click', (event) => {
this.documentClickListener = this.renderer.listen('document', 'click', (event) => {
if(!this.editorClick) {
this.closeCell();
}
Expand Down Expand Up @@ -1535,7 +1535,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
this.domHandler.addClass(cell, 'ui-cell-editing');
let focusable = this.domHandler.findSingle(cell, '.ui-cell-editor input');
if(focusable) {
setTimeout(() => this.renderer.invokeElementMethod(focusable, 'focus'), 50);
setTimeout(() => this.domHandler.invokeElementMethod(focusable, 'focus'), 50);
}
}
}
Expand All @@ -1561,15 +1561,15 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
//enter
if(event.keyCode == 13) {
this.onEditComplete.emit({column: column, data: rowData, index: rowIndex});
this.renderer.invokeElementMethod(event.target, 'blur');
this.domHandler.invokeElementMethod(event.target, 'blur');
this.switchCellToViewMode(event.target);
event.preventDefault();
}

//escape
else if(event.keyCode == 27) {
this.onEditCancel.emit({column: column, data: rowData, index: rowIndex});
this.renderer.invokeElementMethod(event.target, 'blur');
this.domHandler.invokeElementMethod(event.target, 'blur');
this.switchCellToViewMode(event.target);
event.preventDefault();
}
Expand All @@ -1592,7 +1592,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
let targetCell = this.findPreviousEditableColumn(currentCell);

if(targetCell) {
this.renderer.invokeElementMethod(targetCell, 'click');
this.domHandler.invokeElementMethod(targetCell, 'click');
event.preventDefault();
}
}
Expand All @@ -1603,7 +1603,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
let targetCell = this.findNextEditableColumn(currentCell);

if(targetCell) {
this.renderer.invokeElementMethod(targetCell, 'click');
this.domHandler.invokeElementMethod(targetCell, 'click');
event.preventDefault();
}
}
Expand Down Expand Up @@ -1672,13 +1672,13 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni
this.resizerHelper = this.domHandler.findSingle(this.el.nativeElement, 'div.ui-column-resizer-helper');
this.fixColumnWidths();

this.documentColumnResizeListener = this.renderer.listenGlobal('document', 'mousemove', (event) => {
this.documentColumnResizeListener = this.renderer.listen('document', 'mousemove', (event) => {
if(this.columnResizing) {
this.onColumnResize(event);
}
});

this.documentColumnResizeEndListener = this.renderer.listenGlobal('document', 'mouseup', (event) => {
this.documentColumnResizeEndListener = this.renderer.listen('document', 'mouseup', (event) => {
if(this.columnResizing) {
this.columnResizing = false;
this.onColumnResizeEnd(event);
Expand Down
6 changes: 3 additions & 3 deletions components/defer/defer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgModule,Directive,ElementRef,AfterViewInit,OnDestroy,Input,TemplateRef,EmbeddedViewRef,
ViewContainerRef,Renderer,EventEmitter,Output,ContentChild} from '@angular/core';
ViewContainerRef,Renderer2,EventEmitter,Output,ContentChild} from '@angular/core';
import {CommonModule} from '@angular/common';
import {DomHandler} from '../dom/domhandler';

Expand All @@ -19,14 +19,14 @@ export class DeferredLoader implements AfterViewInit,OnDestroy {

view: EmbeddedViewRef<any>;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer, public viewContainer: ViewContainerRef) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2, public viewContainer: ViewContainerRef) {}

ngAfterViewInit() {
if(this.shouldLoad()) {
this.load();
}

this.documentScrollListener = this.renderer.listenGlobal('window', 'scroll', () => {
this.documentScrollListener = this.renderer.listen('window', 'scroll', () => {
if(this.shouldLoad()) {
this.load();
this.documentScrollListener();
Expand Down
14 changes: 7 additions & 7 deletions components/dialog/dialog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,Renderer,ContentChild,ViewChild} from '@angular/core';
import {NgModule,Component,ElementRef,AfterViewInit,OnDestroy,Input,Output,EventEmitter,Renderer2,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 Down Expand Up @@ -125,7 +125,7 @@ export class Dialog implements AfterViewInit,OnDestroy {

closeIconMouseDown: boolean;

constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer) {}
constructor(public el: ElementRef, public domHandler: DomHandler, public renderer: Renderer2) {}

@Input() get visible(): boolean {
return this._visible;
Expand Down Expand Up @@ -185,31 +185,31 @@ export class Dialog implements AfterViewInit,OnDestroy {
this.contentContainer = <HTMLDivElement> this.contentViewChild.nativeElement;

if(this.draggable) {
this.documentDragListener = this.renderer.listenGlobal('document', 'mousemove', (event) => {
this.documentDragListener = this.renderer.listen('document', 'mousemove', (event) => {
this.onDrag(event);
});
}

if(this.resizable) {
this.documentResizeListener = this.renderer.listenGlobal('document', 'mousemove', (event) => {
this.documentResizeListener = this.renderer.listen('document', 'mousemove', (event) => {
this.onResize(event);
});

this.documentResizeEndListener = this.renderer.listenGlobal('document', 'mouseup', (event) => {
this.documentResizeEndListener = this.renderer.listen('document', 'mouseup', (event) => {
if(this.resizing) {
this.resizing = false;
}
});
}

if(this.responsive) {
this.documentResponsiveListener = this.renderer.listenGlobal('window', 'resize', (event) => {
this.documentResponsiveListener = this.renderer.listen('window', 'resize', (event) => {
this.positionOverlay();
});
}

if(this.closeOnEscape && this.closable) {
this.documentEscapeListener = this.renderer.listenGlobal('document', 'keydown', (event) => {
this.documentEscapeListener = this.renderer.listen('document', 'keydown', (event) => {
if(event.which == 27) {
if(parseInt(this.container.style.zIndex) == DomHandler.zindex) {
this.close(event);
Expand Down
4 changes: 4 additions & 0 deletions components/dom/domhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,8 @@ export class DomHandler {

return scrollbarWidth;
}

public invokeElementMethod(element: any, methodName: string, args?: any[]): void {
(element as any)[methodName].apply(element, args);
}
}
Loading

0 comments on commit 69edcf6

Please sign in to comment.