FIX: Clicking an avatar in an expanded post should show the user
expansion popup.
This commit is contained in:
parent
0175ba000f
commit
4d354cff7e
|
@ -0,0 +1,17 @@
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
tagName: 'a',
|
||||||
|
attributeBindings: ['href'],
|
||||||
|
classNames: ['trigger-expansion'],
|
||||||
|
href: Em.computed.alias('post.usernameUrl'),
|
||||||
|
|
||||||
|
click: function(e) {
|
||||||
|
this.appEvents.trigger('poster:expand', $(e.target));
|
||||||
|
this.sendAction('action', this.get('post'));
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function(buffer) {
|
||||||
|
var avatar = Handlebars.helpers.avatar(this.get('post'), {hash: {imageSize: 'large'}});
|
||||||
|
buffer.push(avatar);
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
var PosterNameComponent = Em.Component.extend({
|
var PosterNameComponent = Em.Component.extend({
|
||||||
classNames: ['names'],
|
classNames: ['names', 'trigger-expansion'],
|
||||||
displayNameOnPosts: Discourse.computed.setting('display_name_on_posts'),
|
displayNameOnPosts: Discourse.computed.setting('display_name_on_posts'),
|
||||||
|
|
||||||
// sanitize name for comparison
|
// sanitize name for comparison
|
||||||
|
@ -67,6 +67,7 @@ var PosterNameComponent = Em.Component.extend({
|
||||||
if (!Em.isEmpty(href) && href !== '#') {
|
if (!Em.isEmpty(href) && href !== '#') {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
this.appEvents.trigger('poster:expand', $target);
|
||||||
this.sendAction('expandAction', this.get('post'));
|
this.sendAction('expandAction', this.get('post'));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
/**
|
|
||||||
A controller for expanding information about a poster.
|
|
||||||
|
|
||||||
@class PosterExpansion
|
|
||||||
@extends Discourse.ObjectController
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
export default Discourse.ObjectController.extend({
|
export default Discourse.ObjectController.extend({
|
||||||
needs: ['topic'],
|
needs: ['topic'],
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
|
@ -5,6 +5,7 @@ export default {
|
||||||
application.register('app-events:main', AppEvents, { singleton: true });
|
application.register('app-events:main', AppEvents, { singleton: true });
|
||||||
|
|
||||||
application.inject('controller', 'appEvents', 'app-events:main');
|
application.inject('controller', 'appEvents', 'app-events:main');
|
||||||
|
application.inject('component', 'appEvents', 'app-events:main');
|
||||||
application.inject('route', 'appEvents', 'app-events:main');
|
application.inject('route', 'appEvents', 'app-events:main');
|
||||||
application.inject('view', 'appEvents', 'app-events:main');
|
application.inject('view', 'appEvents', 'app-events:main');
|
||||||
application.inject('model', 'appEvents', 'app-events:main');
|
application.inject('model', 'appEvents', 'app-events:main');
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
<div class='topic-avatar'>
|
<div class='topic-avatar'>
|
||||||
<div class='contents'>
|
<div class='contents'>
|
||||||
<div>
|
<div>
|
||||||
<a href='/users/{{unbound username}}'>{{avatar this imageSize="large"}}</a>
|
{{poster-avatar action="showPosterExpansion" post=this classNames="main-avatar"}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class='topic-body'>
|
<div class='topic-body'>
|
||||||
<div class="topic-meta-data">
|
<div class="topic-meta-data">
|
||||||
<h5 {{bind-attr class="staff new_user"}}><a href='{{unbound usernameUrl}}'>{{{unbound username}}}</a></h5>
|
{{poster-name post=this expandAction="showPosterExpansion"}}
|
||||||
{{#if view.parentView.previousPost}}<a href='{{unbound url}}' class="post-info arrow" title="{{i18n topic.jump_reply_up}}"><i class='fa fa-arrow-up'></i></a>{{/if}}
|
{{#if view.parentView.previousPost}}<a href='{{unbound url}}' class="post-info arrow" title="{{i18n topic.jump_reply_up}}"><i class='fa fa-arrow-up'></i></a>{{/if}}
|
||||||
<div class='post-info post-date'>{{age-with-tooltip created_at}}</div>
|
<div class='post-info post-date'>{{age-with-tooltip created_at}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,9 +19,8 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<div class='topic-avatar'>
|
<div class='topic-avatar'>
|
||||||
{{#unless userDeleted}}
|
{{#unless userDeleted}}
|
||||||
<div {{bind-attr class=":contents byTopicCreator:topic-creator :trigger-expansion"}}>
|
<div {{bind-attr class=":contents byTopicCreator:topic-creator"}}>
|
||||||
<a class="main-avatar" href='{{unbound usernameUrl}}' {{action showPosterExpansion this}}>{{avatar this imageSize="large"}}</a>
|
{{poster-avatar action="showPosterExpansion" post=this classNames="main-avatar"}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="contents">
|
<div class="contents">
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
/**
|
|
||||||
This view handles rendering of post within another (such as a collapsed reply)
|
|
||||||
|
|
||||||
@class EmbeddedPostView
|
|
||||||
@extends Discourse.View
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
export default Discourse.GroupedView.extend({
|
export default Discourse.GroupedView.extend({
|
||||||
templateName: 'embedded_post',
|
templateName: 'embedded_post',
|
||||||
classNames: ['reply'],
|
classNames: ['reply'],
|
||||||
|
@ -18,5 +10,4 @@ export default Discourse.GroupedView.extend({
|
||||||
_stopTracking: function() {
|
_stopTracking: function() {
|
||||||
Discourse.ScreenTrack.current().stopTracking(this.get('elementId'));
|
Discourse.ScreenTrack.current().stopTracking(this.get('elementId'));
|
||||||
}.on('willDestroyElement')
|
}.on('willDestroyElement')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,40 +1,25 @@
|
||||||
/**
|
|
||||||
Shows expanded details for a poster
|
|
||||||
|
|
||||||
@class PosterExpansionView
|
|
||||||
@namespace Discourse
|
|
||||||
@module Discourse
|
|
||||||
**/
|
|
||||||
|
|
||||||
var clickOutsideEventName = "mousedown.outside-poster-expansion";
|
var clickOutsideEventName = "mousedown.outside-poster-expansion";
|
||||||
|
|
||||||
export default Discourse.View.extend({
|
export default Discourse.View.extend({
|
||||||
elementId: 'poster-expansion',
|
elementId: 'poster-expansion',
|
||||||
classNameBindings: ['controller.visible::hidden', 'controller.showBadges'],
|
classNameBindings: ['controller.visible::hidden', 'controller.showBadges'],
|
||||||
|
|
||||||
// Position the expansion when the post changes
|
_setup: function() {
|
||||||
_visibleChanged: function() {
|
|
||||||
var post = this.get('controller.model'),
|
|
||||||
div = this.$();
|
|
||||||
|
|
||||||
Em.run.schedule('afterRender', function() {
|
|
||||||
if (post) {
|
|
||||||
var $post = $('#' + post.get('postElementId')),
|
|
||||||
$avatar = $('.topic-avatar img.avatar', $post),
|
|
||||||
position = $avatar.offset();
|
|
||||||
|
|
||||||
if (position) {
|
|
||||||
position.left += $avatar.width() + 5;
|
|
||||||
div.css(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}.observes('controller.model'),
|
|
||||||
|
|
||||||
didInsertElement: function() {
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$('html').off(clickOutsideEventName).on(clickOutsideEventName, function(e) {
|
this.appEvents.on('poster:expand', function(target) {
|
||||||
|
if (!target) { return; }
|
||||||
|
Em.run.schedule('afterRender', function() {
|
||||||
|
if (target) {
|
||||||
|
var position = target.offset();
|
||||||
|
if (position) {
|
||||||
|
position.left += target.width() + 5;
|
||||||
|
self.$().css(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('html').off(clickOutsideEventName).on(clickOutsideEventName, function(e) {
|
||||||
if (self.get('controller.visible')) {
|
if (self.get('controller.visible')) {
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
if ($target.closest('.trigger-expansion').length > 0) { return; }
|
if ($target.closest('.trigger-expansion').length > 0) { return; }
|
||||||
|
@ -45,10 +30,11 @@ export default Discourse.View.extend({
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
},
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
willDestroyElement: function() {
|
_removeEvents: function() {
|
||||||
$('html').off(clickOutsideEventName);
|
$('html').off(clickOutsideEventName);
|
||||||
}
|
this.appEvents.off('poster:expand');
|
||||||
|
}.on('willDestroyElement')
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue