From 7a6669d926c0ad67c8722544543b1a39b3320fd6 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sat, 15 Aug 2015 02:17:17 +0500 Subject: [PATCH] add `click to post citation to open related conversation` --- js/interface_common.js | 5 +++-- js/twister_formatpost.js | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 12b3a75..5e26403 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -293,7 +293,7 @@ function openConversationClick(e) { e.stopPropagation(); e.preventDefault(); - var postData = $(this).parents('.module.post.original.open .module.post.original .post-data'); + var postData = $(this).closest(e.data.feeder); window.location.hash = '#conversation?post=' + postData.attr('data-screen-name') + ':post' + postData.attr('data-id'); @@ -1427,7 +1427,8 @@ function initInterfaceCommon() { ; $('.post-submit').on('click', postSubmit); $('.modal-propagate').on('click', retweetSubmit); - $('.expanded-content .show-more').on('click', openConversationClick); + $('.expanded-content .show-more').on('click', + {feeder: '.module.post.original.open .module.post.original .post-data'}, openConversationClick); if ($.Options.unicodeConversion.val === 'disable') $('.undo-unicode').on('click', undoLastUnicode).css('display', 'none'); diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index bafbf2c..9c2db86 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -12,6 +12,8 @@ var _htmlFormatMsgLinkTemplateHashtag; $(document).ready(function() { // we're setting it here for perfomance improvement purpose // to not search and prepare it for for every post every time _templatePostRtReference = $('#post-rt-reference-template').children().clone(true); + _templatePostRtReference.find('.post-text') + .on('click', {feeder: '.post-rt-reference'}, openConversationClick); _templatePostRtBy = $('#post-retransmited-by-template').children().clone(true); _htmlFormatMsgLinkTemplateExternal = $('#external-page-link-template') if (_htmlFormatMsgLinkTemplateExternal.length) { @@ -165,9 +167,12 @@ function postToElem(post, kind, promoted) { var postContext = elem.find('.post-context'); if (userpost.msg) { postContext.append(_templatePostRtReference.clone(true)) - .find('.post-text').html(htmlFormatMsg(rt.msg).html); + .find('.post-rt-reference') + .attr('data-screen-name', rt.n) + .attr('data-id', rt.k) + .find('.post-text').html(htmlFormatMsg(rt.msg).html) ; - setPostCommon(postContext, rt.n, rt.time) + setPostCommon(postContext, rt.n, rt.time); } else { postContext.append(_templatePostRtBy.clone(true)) .find('.post-retransmited-by')