2015-04-25 22:28:39 +09:30
|
|
|
import Component from 'flarum/component';
|
|
|
|
import icon from 'flarum/helpers/icon';
|
|
|
|
|
|
|
|
export default class Badge extends Component {
|
|
|
|
view(ctrl) {
|
|
|
|
var iconName = this.props.icon;
|
|
|
|
var label = this.props.title = this.props.label;
|
|
|
|
delete this.props.icon, this.props.label;
|
2015-06-25 15:35:11 +09:30
|
|
|
this.props.config = function(element, isInitialized) {
|
|
|
|
if (isInitialized) return;
|
2015-04-25 22:28:39 +09:30
|
|
|
$(element).tooltip();
|
|
|
|
};
|
|
|
|
this.props.className = 'badge '+(this.props.className || '');
|
2015-06-25 15:35:11 +09:30
|
|
|
this.props.key = this.props.className;
|
2015-04-25 22:28:39 +09:30
|
|
|
|
|
|
|
return m('span', this.props, [
|
|
|
|
icon(iconName+' icon-glyph'),
|
|
|
|
m('span.label', label)
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|