2018-02-10 15:18:01 +00:00
|
|
|
import ngModule from '../../module';
|
2018-04-19 12:46:06 +00:00
|
|
|
import './style.scss';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-04-19 12:46:06 +00:00
|
|
|
export default class IconButton {
|
|
|
|
constructor($element) {
|
|
|
|
$element[0].tabIndex = 0;
|
|
|
|
$element.on("keyup", event => this.onKeyDown(event, $element));
|
|
|
|
}
|
|
|
|
|
|
|
|
onKeyDown(event, $element) {
|
|
|
|
if (event.defaultPrevented) return;
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
event.preventDefault();
|
|
|
|
$element.triggerHandler('click');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
IconButton.$inject = ['$element'];
|
2018-02-10 15:18:01 +00:00
|
|
|
ngModule.component('vnIconButton', {
|
2018-04-19 12:46:06 +00:00
|
|
|
controller: IconButton,
|
2017-06-13 11:08:06 +00:00
|
|
|
template: require('./icon-button.html'),
|
|
|
|
bindings: {
|
|
|
|
icon: '@',
|
2018-05-08 07:59:49 +00:00
|
|
|
enabled: '<?'
|
2017-06-15 09:22:47 +00:00
|
|
|
}
|
2017-06-13 11:08:06 +00:00
|
|
|
});
|
|
|
|
|