1
0
mirror of https://github.com/flarum/core.git synced 2025-07-24 18:21:33 +02:00

Add alert messages

This commit is contained in:
Toby Zerner
2015-02-03 17:02:46 +10:30
parent b18534882b
commit 0552cae1ab
9 changed files with 166 additions and 61 deletions

View File

@@ -1,9 +1,44 @@
import Ember from 'ember';
export default Ember.Component.extend({
close: function() {
this.sendAction('closeAction');
}
import TaggedArray from '../utils/tagged-array';
import ActionButton from 'flarum/components/ui/controls/action-button';
export default Ember.Component.extend(Ember.Evented, {
message: '',
type: '',
dismissable: true,
layoutName: 'components/alert-message',
classNames: ['alert'],
classNameBindings: ['classForType'],
classForType: function() {
return 'alert-'+this.get('type');
}.property('type'),
didInsertElement: function() {
var controls = TaggedArray.create();
this.trigger('populateControls', controls);
this.set('controls', controls);
},
populateControls: function(controls) {
if (this.get('dismissable')) {
var component = this;
var dismiss = ActionButton.create({
icon: 'times',
className: 'btn btn-icon btn-link',
action: function() {
component.send('dismiss');
}
});
controls.pushObjectWithTag(dismiss, 'dismiss');
}
},
actions: {
dismiss: function() {
this.sendAction('dismiss', this);
}
}
});