Composer Messages can be dismissed by Esc

This commit is contained in:
Robin Ward 2015-04-17 12:41:31 -04:00
parent a61c202ac4
commit 32365fbc58
2 changed files with 11 additions and 13 deletions

View file

@ -83,6 +83,13 @@ export default DiscourseController.extend({
}, },
hitEsc() { hitEsc() {
const messages = this.get('controllers.composer-messages.model');
if (messages.length) {
messages.popObject();
return;
}
if (this.get('model.viewOpen')) { if (this.get('model.viewOpen')) {
this.shrink(); this.shrink();
} }

View file

@ -1,11 +1,3 @@
/**
Renders a popup messages on the composer
@class ComposerMessagesView
@extends Discourse.View
@namespace Discourse
@module Discourse
**/
export default Ember.CollectionView.extend({ export default Ember.CollectionView.extend({
classNameBindings: [':composer-popup-container', 'hidden'], classNameBindings: [':composer-popup-container', 'hidden'],
content: Em.computed.alias('controller.content'), content: Em.computed.alias('controller.content'),
@ -16,19 +8,18 @@ export default Ember.CollectionView.extend({
classNames: ['composer-popup', 'hidden'], classNames: ['composer-popup', 'hidden'],
templateName: Em.computed.alias('content.templateName'), templateName: Em.computed.alias('content.templateName'),
init: function() { _setup: function() {
this._super(); this._super();
this.set('context', this.get('content')); this.set('context', this.get('content'));
if (this.get('content.extraClass')) { if (this.get('content.extraClass')) {
this.get('classNames').pushObject(this.get('content.extraClass')); this.get('classNames').pushObject(this.get('content.extraClass'));
} }
}, }.on('init'),
didInsertElement: function() { _initCss: function() {
var composerHeight = $('#reply-control').height() || 0; var composerHeight = $('#reply-control').height() || 0;
this.$().css('bottom', composerHeight + "px").show(); this.$().css('bottom', composerHeight + "px").show();
} }.on('didInsertElement')
}) })
}); });