salix/client/core/src/components/icon-button/icon-button.js

31 lines
708 B
JavaScript
Raw Normal View History

2018-02-10 15:18:01 +00:00
import ngModule from '../../module';
import './style.scss';
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', {
controller: IconButton,
template: require('./icon-button.html'),
bindings: {
icon: '@',
className: '@?',
enabled: '<?',
label: '@?'
}
});