diff --git a/app/assets/javascripts/discourse/components/discourse-action-history.js.es6 b/app/assets/javascripts/discourse/components/discourse-action-history.js.es6 index a6c1a9cbf..d5cd675da 100644 --- a/app/assets/javascripts/discourse/components/discourse-action-history.js.es6 +++ b/app/assets/javascripts/discourse/components/discourse-action-history.js.es6 @@ -32,7 +32,7 @@ export default Em.Component.extend({ if (c.get('usersExpanded')) { var postUrl; c.get('users').forEach(function(u) { - iconsHtml += ""; + iconsHtml += ""; if (u.post_url) { postUrl = postUrl || u.post_url; } diff --git a/app/assets/javascripts/discourse/initializers/click-interceptor.js.es6 b/app/assets/javascripts/discourse/initializers/click-interceptor.js.es6 index 9934b3817..4cd97d711 100644 --- a/app/assets/javascripts/discourse/initializers/click-interceptor.js.es6 +++ b/app/assets/javascripts/discourse/initializers/click-interceptor.js.es6 @@ -18,6 +18,8 @@ export default { $currentTarget.data('ember-action') || $currentTarget.data('auto-route') || $currentTarget.data('share-url') || + $currentTarget.data('user-expand') || + $currentTarget.hasClass('mention') || $currentTarget.hasClass('ember-view') || $currentTarget.hasClass('lightbox') || href.indexOf("mailto:") === 0 || diff --git a/app/assets/javascripts/discourse/views/post_view.js b/app/assets/javascripts/discourse/views/post_view.js index bc7fe08f8..6e29dbacc 100644 --- a/app/assets/javascripts/discourse/views/post_view.js +++ b/app/assets/javascripts/discourse/views/post_view.js @@ -234,7 +234,6 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { _destroyedPostView: function() { Discourse.ScreenTrack.current().stopTracking(this.get('elementId')); - this._unbindExpandMentions(); }.on('willDestroyElement'), _postViewInserted: function() { @@ -262,23 +261,8 @@ Discourse.PostView = Discourse.GroupedView.extend(Ember.Evented, { Em.run.scheduleOnce('afterRender', this, '_insertQuoteControls'); this._applySearchHighlight(); - this._bindExpandMentions(); }.on('didInsertElement'), - _bindExpandMentions: function() { - var self = this; - this.$('.cooked').on('click.discourse-mention', 'a.mention', function(e) { - var $target = $(e.target); - self.appEvents.trigger('poster:expand', $target); - self.get('controller').send('expandPostUsername', $target.text()); - return false; - }); - }, - - _unbindExpandMentions: function() { - this.$('.cooked').off('click.discourse-mention'); - }, - _applySearchHighlight: function() { var highlight = this.get('controller.searchHighlight'); var cooked = this.$('.cooked'); diff --git a/app/assets/javascripts/discourse/views/topic-list-poster.js.es6 b/app/assets/javascripts/discourse/views/topic-list-poster.js.es6 index ac36366f6..caee5427d 100644 --- a/app/assets/javascripts/discourse/views/topic-list-poster.js.es6 +++ b/app/assets/javascripts/discourse/views/topic-list-poster.js.es6 @@ -2,18 +2,13 @@ import { renderAvatar } from 'discourse/helpers/user-avatar'; export default Ember.View.extend({ tagName: 'a', - attributeBindings: ['href'], + attributeBindings: ['href', 'data-user-expand'], classNameBindings: ['content.extras'], user: Em.computed.alias('content.user'), href: Em.computed.alias('user.path'), - click: function(e) { - var user = this.get('user'); - this.appEvents.trigger('poster:expand', $(e.target)); - this.get('controller').send('expandUser', user); - return false; - }, + 'data-user-expand': Em.computed.alias('user.username'), render: function(buffer) { var av = renderAvatar(this.get('content'), {usernamePath: 'user.username', imageSize: 'small'}); diff --git a/app/assets/javascripts/discourse/views/user-expansion.js.es6 b/app/assets/javascripts/discourse/views/user-expansion.js.es6 index 186a0c4a6..69bcf9b73 100644 --- a/app/assets/javascripts/discourse/views/user-expansion.js.es6 +++ b/app/assets/javascripts/discourse/views/user-expansion.js.es6 @@ -1,6 +1,8 @@ import CleansUp from 'discourse/mixins/cleans-up'; -var clickOutsideEventName = "mousedown.outside-user-expansion"; +var clickOutsideEventName = "mousedown.outside-user-expansion", + clickDataExpand = "click.discourse-user-expand", + clickMention = "click.discourse-user-mention"; export default Discourse.View.extend(CleansUp, { elementId: 'user-expansion', @@ -21,6 +23,21 @@ export default Discourse.View.extend(CleansUp, { return true; }); + + $('#main-outlet').on(clickDataExpand, '[data-user-expand]', function(e) { + var $target = $(e.currentTarget); + self._posterExpand($target); + self.get('controller').show($target.data('user-expand')); + return false; + }); + + $('#main-outlet').on(clickMention, 'a.mention', function(e) { + var $target = $(e.target); + self._posterExpand($target); + var username = $target.text().replace(/^@/, ''); + self.get('controller').show(username); + return false; + }); }.on('didInsertElement'), _posterExpand: function(target) { @@ -50,6 +67,9 @@ export default Discourse.View.extend(CleansUp, { _removeEvents: function() { $('html').off(clickOutsideEventName); + $('#main').off(clickDataExpand); + $('#main').off(clickMention); + this.appEvents.off('poster:expand', this, '_posterExpand'); }.on('willDestroyElement') diff --git a/test/javascripts/integration/user-expansion-test.js.es6 b/test/javascripts/integration/user-expansion-test.js.es6 new file mode 100644 index 000000000..4e7be135b --- /dev/null +++ b/test/javascripts/integration/user-expansion-test.js.es6 @@ -0,0 +1,13 @@ +integration("User Expansion"); + +test("expansion", function() { + visit('/'); + + ok(find('#user-expansion:visible').length === 0, 'user expansion is invisible by default'); + click('a[data-user-expand=eviltrout]:first'); + + andThen(function() { + ok(find('#user-expansion:visible').length === 1, 'expansion should appear'); + }); + +});