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({
|
2015-01-16 14:56:10 +08:00
|
|
|
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
|
|
|
|
2015-01-16 14:56:10 +08:00
|
|
|
classNames: [],
|
2015-01-03 19:21:47 +08:00
|
|
|
|
2014-12-20 14:26:46 +08:00
|
|
|
tagName: 'a',
|
2015-01-16 14:56:10 +08:00
|
|
|
attributeBindings: ['href', 'title'],
|
2014-12-20 14:26:46 +08:00
|
|
|
classNameBindings: ['className'],
|
|
|
|
href: '#',
|
2015-01-16 14:56:10 +08:00
|
|
|
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();
|
2015-01-16 14:56:10 +08:00
|
|
|
var action = this.get('action');
|
2015-01-21 11:59:00 +08:00
|
|
|
if (typeof action === 'string') {
|
2015-01-16 14:56:10 +08:00
|
|
|
this.sendAction('action');
|
2015-01-21 11:59:00 +08:00
|
|
|
} else if (typeof action === 'function') {
|
2015-01-16 14:56:10 +08:00
|
|
|
action();
|
|
|
|
}
|
2014-12-20 14:26:46 +08:00
|
|
|
}
|
2015-01-03 19:21:47 +08:00
|
|
|
});
|