framework/ember/app/components/ui/controls/action-button.js

28 lines
701 B
JavaScript
Raw Normal View History

2014-12-20 14:26:46 +08:00
import Ember from 'ember';
2015-01-03 19:21:47 +08:00
export default Ember.Component.extend({
label: '',
2014-12-20 14:26:46 +08:00
icon: '',
className: '',
action: null,
divider: false,
2015-01-03 09:56:14 +08:00
active: false,
2014-12-20 14:26:46 +08:00
classNames: [],
2015-01-03 19:21:47 +08:00
2014-12-20 14:26:46 +08:00
tagName: 'a',
attributeBindings: ['href', 'title'],
2014-12-20 14:26:46 +08:00
classNameBindings: ['className'],
href: '#',
layout: Ember.Handlebars.compile('{{#if icon}}{{fa-icon icon class="fa-fw icon-glyph"}} {{/if}}<span>{{label}}</span>'),
2014-12-20 14:26:46 +08:00
click: function(e) {
e.preventDefault();
var action = this.get('action');
2015-01-21 11:59:00 +08:00
if (typeof action === 'string') {
this.sendAction('action');
2015-01-21 11:59:00 +08:00
} else if (typeof action === 'function') {
action();
}
2014-12-20 14:26:46 +08:00
}
2015-01-03 19:21:47 +08:00
});