2015-02-10 15:35:40 +08:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
var precompileTemplate = Ember.Handlebars.compile;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Button which sends an action when clicked.
|
|
|
|
*/
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
tagName: 'a',
|
|
|
|
attributeBindings: ['href', 'title'],
|
|
|
|
classNameBindings: ['className'],
|
|
|
|
href: '#',
|
2015-02-13 19:33:34 +08:00
|
|
|
layout: precompileTemplate('{{#if icon}}{{fa-icon icon class="fa-fw icon-glyph"}} {{/if}}<span class="label">{{label}}</span>'),
|
2015-02-10 15:35:40 +08:00
|
|
|
|
|
|
|
label: '',
|
|
|
|
icon: '',
|
|
|
|
className: '',
|
|
|
|
action: null,
|
|
|
|
|
|
|
|
click: function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var action = this.get('action');
|
|
|
|
if (typeof action === 'string') {
|
|
|
|
this.sendAction('action');
|
|
|
|
} else if (typeof action === 'function') {
|
|
|
|
action();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|