#52: updated JS and rendering discussion in pull_request
This commit is contained in:
parent
274c4d39be
commit
4f40327293
|
@ -2,18 +2,16 @@ $(document).ready(function() {
|
|||
|
||||
jQuery(window).bind('hashchange', function(e) {
|
||||
var hash = location.hash;
|
||||
if (/^#diff-/.test(hash)) {
|
||||
if (/^#(diff|discussion)-F[0-9]+(L|R)[0-9]+/.test(hash)) {
|
||||
highlightDiff(hash);
|
||||
} else if (/^#L[0-9]+/.test(hash)) {
|
||||
highlightShow(hash);
|
||||
}
|
||||
});
|
||||
|
||||
$(window).load(function() {
|
||||
// this code will run after all other $(document).ready() scripts
|
||||
// have completely finished, AND all page elements are fully loaded.
|
||||
jQuery(window).trigger('hashchange');
|
||||
});
|
||||
// Since the event is only triggered when the hash changes, we need to trigger
|
||||
// the event now, to handle the hash the page may have loaded with.
|
||||
jQuery(window).trigger('hashchange');
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ module DiffHelper
|
|||
def prepare(args)
|
||||
@url, @diff_counter, @in_discussion = args[:url], args[:diff_counter], args[:in_discussion]
|
||||
@filepath, @line_comments = args[:filepath], args[:comments]
|
||||
@diff_prefix = args[:diff_prefix] || 'diff'
|
||||
@add_reply_id, @num_line = if @in_discussion
|
||||
[@line_comments[0].id, @line_comments[0].data[:line].to_i - @line_comments[0].data[:strings].lines.count.to_i-1]
|
||||
else
|
||||
|
@ -74,7 +75,7 @@ module DiffHelper
|
|||
set_line_number
|
||||
"<tr class='changes'>
|
||||
<td class='line_numbers'></td>
|
||||
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
<td class='code ins'>
|
||||
#{line_comment}
|
||||
<pre>#{render_line(line)}</pre>
|
||||
|
@ -86,7 +87,7 @@ module DiffHelper
|
|||
def remline(line)
|
||||
set_line_number
|
||||
"<tr class='changes'>
|
||||
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
<td class='line_numbers'></td>
|
||||
<td class='code del'>
|
||||
#{line_comment}
|
||||
|
@ -99,8 +100,8 @@ module DiffHelper
|
|||
def modline(line)
|
||||
set_line_number
|
||||
"<tr clas='chanes line'>
|
||||
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
<td class='code unchanged modline'>
|
||||
#{line_comment}
|
||||
<pre>#{render_line(line)}</pre>
|
||||
|
@ -112,8 +113,8 @@ module DiffHelper
|
|||
def unmodline(line)
|
||||
set_line_number
|
||||
"<tr class='changes unmodline'>
|
||||
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
<td class='code unchanged unmodline'>
|
||||
#{line_comment}
|
||||
<pre>#{render_line(line)}</pre>
|
||||
|
@ -133,8 +134,8 @@ module DiffHelper
|
|||
def nonewlineline(line)
|
||||
set_line_number
|
||||
"<tr class='changes'>
|
||||
#{td_line_link "diff-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "diff-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
|
||||
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
|
||||
<td class='code modline unmodline'>
|
||||
#{line_comment}
|
||||
<pre>#{render_line(line)}</pre>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
.hr
|
||||
-commits_queue = []
|
||||
- commits_queue = []
|
||||
- diff_counter = 0
|
||||
-merge_activity(@comments, @commits).each do |item| #
|
||||
-if item.is_a? Comment
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
|
@ -16,8 +17,9 @@
|
|||
=t '.show_outdated_diff'
|
||||
%span.data-expander.collapsed{:id => exp_id}
|
||||
.hidden{:id => "content-#{exp_id}"}
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :add_id => nil
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :diff_counter => diff_counter
|
||||
-else
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :add_id => nil
|
||||
=render 'projects/pull_requests/discussion_comments', :item => item, :diff_counter => diff_counter
|
||||
- diff_counter += 1
|
||||
=render 'projects/git/commits/commits_small', :commits => commits_queue if commits_queue.present?
|
||||
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
=t'projects.pull_requests.outdated_diff'
|
||||
=image_tag 'x.png'
|
||||
.clear
|
||||
.diff_data=render_diff(comment.inline_diff, :diff_counter => 0, :comments => item[1], :filepath => comment.data[:path])
|
||||
.diff_data=render_diff(comment.inline_diff, :diff_counter => diff_counter, :comments => item[1], :filepath => comment.data[:path], :diff_prefix => 'discussion')
|
||||
|
||||
|
|
Loading…
Reference in New Issue