| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  | /* tslint:disable:no-unused-variable */ | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | // #docregion
 | 
					
						
							| 
									
										
										
										
											2016-08-22 11:35:22 +02:00
										 |  |  | import { Directive, ElementRef, HostListener, Input, Renderer } from '@angular/core'; | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Directive({ | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  |   selector: '[myHighlight]' | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-16 19:38:07 -08:00
										 |  |  | export class HighlightDirective { | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   // #docregion ctor
 | 
					
						
							| 
									
										
										
										
											2016-08-22 11:35:22 +02:00
										 |  |  |   constructor(private el: ElementRef, private renderer: Renderer) { } | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   // #enddocregion ctor
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-13 00:41:33 +02:00
										 |  |  |   // #docregion mouse-methods, host
 | 
					
						
							|  |  |  |   @HostListener('mouseenter') onMouseEnter() { | 
					
						
							|  |  |  |     // #enddocregion host
 | 
					
						
							|  |  |  |     this.highlight('yellow'); | 
					
						
							|  |  |  |     // #docregion host
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   @HostListener('mouseleave') onMouseLeave() { | 
					
						
							|  |  |  |     // #enddocregion host
 | 
					
						
							|  |  |  |     this.highlight(null); | 
					
						
							|  |  |  |     // #docregion host
 | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion host
 | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  |   private highlight(color: string) { | 
					
						
							| 
									
										
										
										
											2016-08-22 11:35:22 +02:00
										 |  |  |     this.renderer.setElementStyle(this.el.nativeElement, 'backgroundColor', color); | 
					
						
							| 
									
										
										
										
											2015-11-19 16:59:22 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   // #enddocregion mouse-methods
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-05-03 14:06:32 +02:00
										 |  |  | // #enddocregion
 |