mirror of https://github.com/rancher/ui.git
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
import Component from '@ember/component';
|
|
import layout from './template';
|
|
import { inject as service } from '@ember/service'
|
|
import C from 'shared/utils/constants';
|
|
import { isAlternate } from 'shared/utils/platform';
|
|
|
|
export default Component.extend({
|
|
layout,
|
|
resourceActions : service('resource-actions'),
|
|
icon : 'icon-help',
|
|
label : '',
|
|
prefix : null,
|
|
enabled : true,
|
|
actionArg : null,
|
|
altActionArg : null,
|
|
|
|
tagName : 'a',
|
|
classNameBindings : ['enabled::hide'],
|
|
attributeBindings : ['tabindex'],
|
|
tabindex : 0,
|
|
|
|
|
|
click : function(event) {
|
|
if ( isAlternate(event) && this.get('altActionArg'))
|
|
{
|
|
this.sendAction('action', this.get('altActionArg'));
|
|
}
|
|
else
|
|
{
|
|
this.sendAction('action', this.get('actionArg'));
|
|
}
|
|
},
|
|
|
|
keyPress: function(event) {
|
|
if ( [C.KEY.CR,C.KEY.LF].indexOf(event.which) >= 0 ) {
|
|
this.click(event);
|
|
this.get('resourceActions').hide();
|
|
}
|
|
},
|
|
|
|
willRender: function() {
|
|
var icon = this.get('icon');
|
|
|
|
if ( icon.indexOf('icon-') === -1 )
|
|
{
|
|
this.set('prefix', 'icon icon-fw');
|
|
}
|
|
},
|
|
|
|
|
|
iconChanged: function() {
|
|
this.rerender();
|
|
}.observes('icon'),
|
|
});
|