');
+ this.$().append($preview);
+
+ const $parentPost = this.$();
+ const $this = this.$('.Post-mentionedBy');
+
+ const showPreview = () => {
+ if (!$preview.hasClass('in') && $preview.is(':visible')) return;
+
+ // When the user hovers their mouse over the list of people who have
+ // replied to the post, render a list of reply previews into a
+ // popup.
+ m.render($preview[0], replies.map(reply => (
+
+ )));
+
+ $preview.show()
+ .css('top', $this.offset().top - $parentPost.offset().top + $this.outerHeight(true))
+ .css('left', $this.offsetParent().offset().left - $parentPost.offset().left)
+ .css('max-width', $parentPost.width());
+
+ setTimeout(() => $preview.off('transitionend').addClass('in'));
+ }
+
+ $this.add($preview).hover(
+ () => {
+ clearTimeout(timeout);
+ timeout = setTimeout(showPreview, 250);
+ },
+ () => {
+ clearTimeout(timeout);
+ timeout = setTimeout(hidePreview, 250);
+ }
+ );
+
+ // Whenever the user hovers their mouse over a particular name in the
+ // list of repliers, highlight the corresponding post in the preview
+ // popup.
+ this.$().find('.Post-mentionedBy-summary a').hover(function() {
+ $preview.find('[data-number="' + $(this).data('number') + '"]').addClass('active');
+ }, function() {
+ $preview.find('[data-number]').removeClass('active');
+ });
+ }
+ });
+
extend(CommentPost.prototype, 'footerItems', function(items) {
const post = this.attrs.post;
const replies = post.mentionedBy();
if (replies && replies.length) {
- const hidePreview = () => {
- this.$('.Post-mentionedBy-preview')
- .removeClass('in')
- .one('transitionend', function() { $(this).hide(); });
- };
-
- const oncreate = function(vnode) {
- const $this = $(vnode.dom);
- let timeout;
-
- const $preview = $('
');
- $this.append($preview);
-
- $this.children().hover(function() {
- clearTimeout(timeout);
- timeout = setTimeout(function() {
- if (!$preview.hasClass('in') && $preview.is(':visible')) return;
-
- // When the user hovers their mouse over the list of people who have
- // replied to the post, render a list of reply previews into a
- // popup.
- m.render($preview[0], replies.map(reply => (
-