From 32365fbc583f4d80d469bde268b5644218340a6d Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 17 Apr 2015 12:41:31 -0400 Subject: [PATCH] Composer Messages can be dismissed by Esc --- .../discourse/controllers/composer.js.es6 | 7 +++++++ .../discourse/views/composer-messages.js.es6 | 17 ++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 7a97eda7a91..2159633fcfc 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -83,6 +83,13 @@ export default DiscourseController.extend({ }, hitEsc() { + + const messages = this.get('controllers.composer-messages.model'); + if (messages.length) { + messages.popObject(); + return; + } + if (this.get('model.viewOpen')) { this.shrink(); } diff --git a/app/assets/javascripts/discourse/views/composer-messages.js.es6 b/app/assets/javascripts/discourse/views/composer-messages.js.es6 index beac06757dd..39f911ec784 100644 --- a/app/assets/javascripts/discourse/views/composer-messages.js.es6 +++ b/app/assets/javascripts/discourse/views/composer-messages.js.es6 @@ -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({ classNameBindings: [':composer-popup-container', 'hidden'], content: Em.computed.alias('controller.content'), @@ -16,19 +8,18 @@ export default Ember.CollectionView.extend({ classNames: ['composer-popup', 'hidden'], templateName: Em.computed.alias('content.templateName'), - init: function() { + _setup: function() { this._super(); this.set('context', this.get('content')); if (this.get('content.extraClass')) { this.get('classNames').pushObject(this.get('content.extraClass')); } - }, + }.on('init'), - didInsertElement: function() { + _initCss: function() { var composerHeight = $('#reply-control').height() || 0; this.$().css('bottom', composerHeight + "px").show(); - } + }.on('didInsertElement') }) }); -