mirror of
https://github.com/flarum/framework.git
synced 2024-12-05 09:03:36 +08:00
80cc910175
Will be used by extensions
30 lines
701 B
JavaScript
30 lines
701 B
JavaScript
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: '#',
|
|
layout: precompileTemplate('{{#if icon}}{{fa-icon icon class="fa-fw icon-glyph"}} {{/if}}<span class="label">{{label}}</span>'),
|
|
|
|
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();
|
|
}
|
|
}
|
|
});
|