2016-12-19 17:12:42 -08:00
|
|
|
/* tslint:disable:no-unused-variable member-ordering */
|
|
|
|
// #docplaster
|
2015-11-19 16:59:22 -08:00
|
|
|
// #docregion
|
2016-12-02 19:54:27 -05:00
|
|
|
import { Directive, ElementRef, HostListener, Input } 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-12-02 19:54:27 -05:00
|
|
|
constructor(private el: ElementRef) { }
|
2015-11-19 16:59:22 -08:00
|
|
|
// #enddocregion ctor
|
2016-12-19 17:12:42 -08:00
|
|
|
// #enddocregion
|
|
|
|
|
|
|
|
// #docregion color
|
|
|
|
@Input() highlightColor: string;
|
|
|
|
// #enddocregion color
|
|
|
|
|
|
|
|
// #docregion color-2
|
|
|
|
@Input() myHighlight: string;
|
|
|
|
// #enddocregion color-2
|
|
|
|
|
|
|
|
// #docregion
|
2015-11-19 16:59:22 -08:00
|
|
|
|
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-12-19 17:12:42 -08:00
|
|
|
this.el.nativeElement.style.backgroundColor = color;
|
2015-11-19 16:59:22 -08:00
|
|
|
}
|
|
|
|
// #enddocregion mouse-methods
|
|
|
|
|
|
|
|
}
|
2016-05-03 14:06:32 +02:00
|
|
|
// #enddocregion
|