2016-04-19 18:50:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-25 18:34:31 +03:00
|
|
|
import {Component, EventEmitter, ElementRef, Output} from '@angular/core';
|
2016-05-05 11:05:02 +03:00
|
|
|
import {CORE_DIRECTIVES} from '@angular/common';
|
2016-05-25 18:34:31 +03:00
|
|
|
import DropKick from 'dropkickjs';
|
2016-04-19 18:50:01 +03:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'dropdown',
|
|
|
|
template: `
|
|
|
|
<select (change)=onChange($event.target.value)>
|
|
|
|
<ng-content></ng-content>
|
|
|
|
</select>
|
|
|
|
`,
|
|
|
|
directives: [CORE_DIRECTIVES],
|
2016-05-25 18:34:31 +03:00
|
|
|
styleUrls: ['./drop-down.css']
|
2016-04-19 18:50:01 +03:00
|
|
|
})
|
|
|
|
export class DropDown {
|
2016-05-25 18:34:31 +03:00
|
|
|
@Output() change = new EventEmitter();
|
|
|
|
elem: any;
|
|
|
|
inst: any;
|
|
|
|
constructor(elem:ElementRef) {
|
2016-04-19 18:50:01 +03:00
|
|
|
this.elem = elem.nativeElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngAfterContentInit() {
|
2016-06-06 19:32:20 +03:00
|
|
|
this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true});
|
2016-04-19 18:50:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
onChange(value) {
|
|
|
|
this.change.next(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
this.inst.dispose();
|
|
|
|
}
|
|
|
|
}
|