diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html index 867feb5..e4688a0 100644 --- a/pagure/templates/issue.html +++ b/pagure/templates/issue.html @@ -231,29 +231,8 @@ $(document).ready(function() { }); }); {% endif %} - -$(document).ready(function() { - var cur_hash = null; - - highlight_comment = function() { - var _hash = window.location.hash; - if (_hash != cur_hash) { - $( cur_hash ).css( - "background", "linear-gradient(to bottom, #ededed 0%, #fff 100%)" - ); - }; - cur_hash = _hash; - if ( _hash ) { - $( _hash ).css( - "background", "linear-gradient(to bottom, #eded98 0%, #fff 100%)" - ); - }; - return false; - }; - - $(window.onload=highlight_comment()); - $(window).on('hashchange', highlight_comment); - +function setup_edit_btns() { + $(".edit_btn").unbind(); $(".edit_btn").click(function() { var commentid = $( this ).attr('data-comment'); var _url = '{{ request.base_url }}' + '/comment/' + commentid + '/edit'; @@ -275,17 +254,61 @@ $(document).ready(function() { }); return false; }); +}; + +function cancel_edit_btn() { + $("#comment_update_cancel").unbind(); + $("#comment_update_cancel").click( + function() { + $(this).closest('#comments').find('.issue_comment').show(); + $(this).closest('#comments').find('.issue_actions').show(); + $(this).closest('.edit_comment').remove(); + return false; + }); +}; - function cancel_edit_btn() { - $( "#comment_update_cancel" ).click( - function() { - $(this).closest('#comments').find('.issue_comment').show(); - $(this).closest('#comments').find('.issue_actions').show(); - $(this).closest('.edit_comment').remove(); - return false; - }); +function setup_reply_btns() { + $(".reply").unbind(); + $( ".reply" ).click( + function() { + var _section = $(this).parent().parent().parent(); + var _comment = _section.find('.comment_body'); + var _text = _comment.text().split("\n"); + var _output = new Array(); + for (cnt = 0; cnt < _text.length - 1; cnt ++) { + _output[cnt] = '> ' + jQuery.trim(_text[cnt + 1]); + } + $( "#comment" ).val(_output.join("\n")); + } + ); +}; + + +$(document).ready(function() { + var cur_hash = null; + + highlight_comment = function() { + var _hash = window.location.hash; + if (_hash != cur_hash) { + $( cur_hash ).css( + "background", "linear-gradient(to bottom, #ededed 0%, #fff 100%)" + ); + }; + cur_hash = _hash; + if ( _hash ) { + $( _hash ).css( + "background", "linear-gradient(to bottom, #eded98 0%, #fff 100%)" + ); + }; + return false; }; + $(window.onload=highlight_comment()); + $(window).on('hashchange', highlight_comment); + cancel_edit_btn(); + setup_edit_btns(); + setup_reply_btns(); + });