2015-04-25 20:58:39 +08:00
|
|
|
import Component from 'flarum/component';
|
|
|
|
import icon from 'flarum/helpers/icon';
|
|
|
|
|
|
|
|
export default class ActionButton extends Component {
|
|
|
|
view() {
|
|
|
|
var attrs = {};
|
|
|
|
for (var i in this.props) { attrs[i] = this.props[i]; }
|
|
|
|
|
|
|
|
var iconName = attrs.icon;
|
|
|
|
delete attrs.icon;
|
|
|
|
|
|
|
|
var label = attrs.label;
|
|
|
|
delete attrs.label;
|
|
|
|
|
2015-05-27 14:51:15 +08:00
|
|
|
if (attrs.disabled) {
|
|
|
|
attrs.className = (attrs.className || '')+' disabled';
|
|
|
|
delete attrs.onclick;
|
|
|
|
delete attrs.disabled;
|
|
|
|
}
|
|
|
|
|
2015-04-25 20:58:39 +08:00
|
|
|
attrs.href = attrs.href || 'javascript:;';
|
2015-05-14 20:54:59 +08:00
|
|
|
return m('a'+(iconName ? '.has-icon' : ''), attrs, [
|
2015-05-02 07:02:45 +08:00
|
|
|
iconName ? icon(iconName+' icon') : '',
|
2015-04-25 20:58:39 +08:00
|
|
|
m('span.label', label)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|