diff --git a/app/assets/javascripts/discourse/views/topic-entrance.js.es6 b/app/assets/javascripts/discourse/views/topic-entrance.js.es6 index 3b9ff07c5..aadc5b7e3 100644 --- a/app/assets/javascripts/discourse/views/topic-entrance.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-entrance.js.es6 @@ -6,32 +6,31 @@ export default Ember.View.extend(CleansUp, { visible: Em.computed.notEmpty('controller.model'), _positionChanged: function() { - var pos = this.get('controller.position'); + const pos = this.get('controller.position'); if (!pos) { return; } - var $self = this.$(); + const $self = this.$(); // Move after we render so the height is correct Em.run.schedule('afterRender', function() { - var width = $self.width(), + const width = $self.width(), height = $self.height(); pos.left = (parseInt(pos.left) - (width / 2)); pos.top = (parseInt(pos.top) - (height / 2)); - var windowWidth = $(window).width(); + const windowWidth = $(window).width(); if (pos.left + width > windowWidth) { - pos.left = (windowWidth - width) - 5; + pos.left = (windowWidth - width) - 15; } $self.css(pos); }); - var self = this; - $('html').off('mousedown.topic-entrance').on('mousedown.topic-entrance', function(e) { - var $target = $(e.target); + $('html').off('mousedown.topic-entrance').on('mousedown.topic-entrance', e => { + const $target = $(e.target); if (($target.prop('id') === 'topic-entrance') || ($self.has($target).length !== 0)) { return; } - self.cleanUp(); + this.cleanUp(); }); }.observes('controller.position'), @@ -39,12 +38,12 @@ export default Ember.View.extend(CleansUp, { $('html').off('mousedown.topic-entrance'); }.on('willDestroyElement'), - cleanUp: function() { + cleanUp() { this.set('controller.model', null); $('html').off('mousedown.topic-entrance'); }, - keyDown: function(e) { + keyDown(e) { if (e.which === 27) { this.cleanUp(); }