30 lines
745 B
JavaScript
30 lines
745 B
JavaScript
import ngModule from '../../module';
|
|
import './style.scss';
|
|
|
|
export default class IconFocusable {
|
|
constructor($element) {
|
|
$element[0].tabIndex = 0;
|
|
$element.on("keyup", event => this.onKeyDown(event, $element));
|
|
}
|
|
|
|
onKeyDown(event, $element) {
|
|
if (event.defaultPrevented) return;
|
|
if (event.keyCode == 32 || event.keyCode == 13) {
|
|
event.preventDefault();
|
|
$element.triggerHandler('click');
|
|
}
|
|
}
|
|
}
|
|
|
|
IconFocusable.$inject = ['$element'];
|
|
ngModule.component('vnIconFocusable', {
|
|
controller: IconFocusable,
|
|
template: require('./icon-focusable.html'),
|
|
bindings: {
|
|
icon: '@',
|
|
className: '@?',
|
|
enabled: '<?',
|
|
label: '@?'
|
|
}
|
|
});
|