From aab9035ccd1b30cd94370f53d03dc86863154652 Mon Sep 17 00:00:00 2001 From: Marcin Lulek Date: Mon, 4 Jul 2016 17:41:42 +0200 Subject: [PATCH] frontend: remove unused chat code and convert it to topics --- rhodecode/public/js/src/rhodecode.js | 24 +++++-------------- rhodecode/public/js/src/rhodecode/comments.js | 17 ++++--------- rhodecode/public/js/topics_list.txt | 3 +++ 3 files changed, 13 insertions(+), 31 deletions(-) create mode 100644 rhodecode/public/js/topics_list.txt diff --git a/rhodecode/public/js/src/rhodecode.js b/rhodecode/public/js/src/rhodecode.js index 9621d149..1d547f1a 100644 --- a/rhodecode/public/js/src/rhodecode.js +++ b/rhodecode/public/js/src/rhodecode.js @@ -385,29 +385,17 @@ $(document).ready(function() { if (lineno.length > 0){ var tr = lineno.parents('tr.line'); tr.addClass('selected'); + $.Topic('/ui/plugins/code/anchor_focus').prepare({ + tr:tr, + remainder:remainder}); - // once we scrolled into our line, trigger chat app - if (remainder){ - tr.find('.add-comment-line a').trigger( "click" ); - setTimeout(function(){ - var nextNode = $(tr).next(); - if(nextNode.hasClass('inline-comments')){ - nextNode.next().find('.switch-to-chat').trigger( "click" ); - } - else{ - nextNode.find('.switch-to-chat').trigger( "click" ); - } - // trigger scroll into, later so all elements are already loaded - tr[0].scrollIntoView(); - }, 250); - - } - else{ + if (!remainder){ tr[0].scrollIntoView(); } } } - }; + } collapsableContent(); + $.Topic('/plugins/__REGISTER__').prepare({}); }); diff --git a/rhodecode/public/js/src/rhodecode/comments.js b/rhodecode/public/js/src/rhodecode/comments.js index c3b3ebfb..789fc06b 100644 --- a/rhodecode/public/js/src/rhodecode/comments.js +++ b/rhodecode/public/js/src/rhodecode/comments.js @@ -150,19 +150,6 @@ var injectInlineForm = function(tr){ var _form = $(f).find('.inline-form').get(0); - $('.switch-to-chat', _form).on('click', function(evt){ - var fParent = $(_parent).closest('.injected_diff').parent().prev('*[fid]'); - var fid = fParent.attr('fid'); - - // activate chat and trigger subscription to channels - $.Topic('/chat_controller').publish({ - action:'subscribe_to_channels', - data: ['/chat${0}$/fid/{1}/{2}'.format(templateContext.repo_name, fid, lineno)] - }); - $(_form).closest('td').find('.comment-inline-form').addClass('hidden'); - $(_form).closest('td').find('.chat-holder').removeClass('hidden'); - }); - var pullRequestId = templateContext.pull_request_data.pull_request_id; var commitId = templateContext.commit_data.commit_id; @@ -224,6 +211,10 @@ var injectInlineForm = function(tr){ } }, 10); + $.Topic('/ui/plugins/code/comment_form_built').prepare({ + form:_form, + parent:_parent} + ); }; var deleteComment = function(comment_id) { diff --git a/rhodecode/public/js/topics_list.txt b/rhodecode/public/js/topics_list.txt new file mode 100644 index 00000000..8994299d --- /dev/null +++ b/rhodecode/public/js/topics_list.txt @@ -0,0 +1,3 @@ +/plugins/__REGISTER__ - launched after the onDomReady() code from rhodecode.js is executed +/ui/plugins/code/anchor_focus - launched when rc starts to scroll on load to anchor on PR/Codeview +/ui/plugins/code/comment_form_built - launched when injectInlineForm() is executed and the form object is created