mirror of
https://github.com/redmine/redmine.git
synced 2025-11-07 13:55:52 +01:00
Fix code copying in common browsers (#36580).
Patch by Vitaly vit9696. git-svn-id: http://svn.redmine.org/redmine/trunk@21415 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<% diff.each do |table_file| -%>
|
<% diff.each do |table_file| -%>
|
||||||
<div class="autoscroll">
|
<div class="autoscroll">
|
||||||
<% if diff.diff_type == 'sbs' -%>
|
<% if diff.diff_type == 'sbs' -%>
|
||||||
<table class="filecontent">
|
<table class="filecontent diffcontent">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4" class="filename">
|
<th colspan="4" class="filename">
|
||||||
@@ -21,17 +21,17 @@
|
|||||||
<% table_file.each_line do |spacing, line| -%>
|
<% table_file.each_line do |spacing, line| -%>
|
||||||
<% if spacing -%>
|
<% if spacing -%>
|
||||||
<tr class="spacing">
|
<tr class="spacing">
|
||||||
<th class="line-num">...</th><td></td><th class="line-num">...</th><td></td>
|
<th class="line-num" data-txt="..."></th><td></td><th class="line-num" data-txt="..."></th><td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="line-num"><%= line.nb_line_left %></th>
|
<th class="line-num" data-txt="<%= line.nb_line_left %>"></th>
|
||||||
<td class="line-code <%= line.type_diff_left %>">
|
<td class="line-code <%= line.type_diff_left %>">
|
||||||
<pre><%= line.html_line_left.html_safe %></pre>
|
<div><%= line.html_line_left.html_safe %></div>
|
||||||
</td>
|
</td>
|
||||||
<th class="line-num"><%= line.nb_line_right %></th>
|
<th class="line-num" data-txt="<%= line.nb_line_right %>"></th>
|
||||||
<td class="line-code <%= line.type_diff_right %>">
|
<td class="line-code <%= line.type_diff_right %>">
|
||||||
<pre><%= line.html_line_right.html_safe %></pre>
|
<div><%= line.html_line_right.html_safe %></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<% else -%>
|
<% else -%>
|
||||||
<table class="filecontent">
|
<table class="filecontent diffcontent">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3" class="filename">
|
<th colspan="3" class="filename">
|
||||||
@@ -58,10 +58,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="line-num"><%= line.nb_line_left %></th>
|
<th class="line-num" data-txt="<%= line.nb_line_left %>"></th>
|
||||||
<th class="line-num"><%= line.nb_line_right %></th>
|
<th class="line-num" data-txt="<%= line.nb_line_right %>"></th>
|
||||||
<td class="line-code <%= line.type_diff %>">
|
<td class="line-code <%= line.type_diff %>">
|
||||||
<pre><%= line.html_line.html_safe %></pre>
|
<div><%= line.html_line.html_safe %></div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|||||||
@@ -4,11 +4,13 @@
|
|||||||
<% line_num = 1 %>
|
<% line_num = 1 %>
|
||||||
<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
|
<% syntax_highlight_lines(filename, Redmine::CodesetUtil.to_utf8_by_setting(content)).each do |line| %>
|
||||||
<tr id="L<%= line_num %>">
|
<tr id="L<%= line_num %>">
|
||||||
<th class="line-num">
|
<th class="line-num"><a href="#L<%= line_num %>" data-txt="<%= line_num %>"></a></th>
|
||||||
<a href="#L<%= line_num %>"><%= line_num %></a>
|
|
||||||
</th>
|
|
||||||
<td class="line-code">
|
<td class="line-code">
|
||||||
<pre><%= line.html_safe %></pre>
|
<% if line == "\n" or line == "\r\n" %>
|
||||||
|
<br>
|
||||||
|
<% else %>
|
||||||
|
<div><%= line.html_safe %></div>
|
||||||
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<% line_num += 1 %>
|
<% line_num += 1 %>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
|
<% syntax_highlight_lines(@path, Redmine::CodesetUtil.to_utf8_by_setting(@annotate.content)).each do |line| %>
|
||||||
<% revision = @annotate.revisions[line_num - 1] %>
|
<% revision = @annotate.revisions[line_num - 1] %>
|
||||||
<tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %> <%= previous_revision && revision && revision != previous_revision ? 'bloc-change' : nil%>">
|
<tr id="L<%= line_num %>" class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %> <%= previous_revision && revision && revision != previous_revision ? 'bloc-change' : nil%>">
|
||||||
<th class="line-num"><a href="#L<%= line_num %>"><%= line_num %></a></th>
|
<th class="line-num"><a href="#L<%= line_num %>" data-txt="<%= line_num %>"></a></th>
|
||||||
<td class="revision">
|
<td class="revision">
|
||||||
<% if revision && revision != previous_revision %>
|
<% if revision && revision != previous_revision %>
|
||||||
<%= revision.identifier ?
|
<%= revision.identifier ?
|
||||||
@@ -31,7 +31,11 @@
|
|||||||
<%= author.split('<').first %>
|
<%= author.split('<').first %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="line-code"><pre><%= line.html_safe %></pre></td>
|
<% if line == "\n" or line == "\r\n" %>
|
||||||
|
<td class="line-code"><br></td>
|
||||||
|
<% else %>
|
||||||
|
<td class="line-code"><div><%= line.html_safe %></div></td>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% line_num += 1; previous_revision = revision %>
|
<% line_num += 1; previous_revision = revision %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -61,8 +61,14 @@ table.filecontent th.line-num a {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
table.filecontent th.line-num a:after {
|
||||||
|
content: attr(data-txt);
|
||||||
|
}
|
||||||
|
table.diffcontent th.line-num:after {
|
||||||
|
content: attr(data-txt);
|
||||||
|
}
|
||||||
table.filecontent td.line-code {padding: 0 0 0 4px;}
|
table.filecontent td.line-code {padding: 0 0 0 4px;}
|
||||||
table.filecontent td.line-code pre {
|
table.filecontent td.line-code pre, table.filecontent td.line-code div {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-family:Consolas, Menlo, "Liberation Mono", Courier, monospace; font-size:12px;
|
font-family:Consolas, Menlo, "Liberation Mono", Courier, monospace; font-size:12px;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.media_type
|
assert_equal 'text/html', @response.media_type
|
||||||
assert_select 'tr#L1' do
|
assert_select 'tr#L1' do
|
||||||
assert_select 'th.line-num', :text => '1'
|
assert_select 'th.line-num a[data-txt=?]', '1'
|
||||||
assert_select 'td', :text => /日本語/
|
assert_select 'td', :text => /日本語/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -174,7 +174,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.media_type
|
assert_equal 'text/html', @response.media_type
|
||||||
assert_select 'tr#L7' do
|
assert_select 'tr#L7' do
|
||||||
assert_select 'th.line-num', :text => '7'
|
assert_select 'th.line-num a[data-txt=?]', '7'
|
||||||
assert_select 'td', :text => /Demande cr\?\?e avec succ\?s/
|
assert_select 'td', :text => /Demande cr\?\?e avec succ\?s/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -192,7 +192,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'text/html', @response.media_type
|
assert_equal 'text/html', @response.media_type
|
||||||
assert_select 'tr#L7' do
|
assert_select 'tr#L7' do
|
||||||
assert_select 'th.line-num', :text => '7'
|
assert_select 'th.line-num a[data-txt=?]', '7'
|
||||||
assert_select 'td', :text => /Demande créée avec succès/
|
assert_select 'td', :text => /Demande créée avec succès/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 11 removed
|
# Line 11 removed
|
||||||
assert_select 'th.line-num:contains(11) ~ td.diff_out', :text => /Display more information/
|
assert_select 'th.line-num[data-txt=11] ~ td.diff_out', :text => /Display more information/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -196,7 +196,8 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '2' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select 'a[data-txt=?]', '2'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '3'
|
assert_select "a", :text => '3'
|
||||||
assert_select "+ td.author", :text => "jsmith@" do
|
assert_select "+ td.author", :text => "jsmith@" do
|
||||||
@@ -226,7 +227,8 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select "a[data-txt=?]", '1'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '2'
|
assert_select "a", :text => '2'
|
||||||
assert_select "+ td.author", :text => "test &" do
|
assert_select "+ td.author", :text => "test &" do
|
||||||
@@ -262,7 +264,8 @@ class RepositoriesBazaarControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select 'a[data-txt=?]', '1'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '2'
|
assert_select "a", :text => '2'
|
||||||
assert_select "+ td.author", :text => "test Ü" do
|
assert_select "+ td.author", :text => "test Ü" do
|
||||||
|
|||||||
@@ -283,13 +283,13 @@ class RepositoriesCvsControllerTest < Redmine::RepositoryControllerTest
|
|||||||
|
|
||||||
# 1.1 line
|
# 1.1 line
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '21'
|
assert_select 'th.line-num a[data-txt=?]', '21'
|
||||||
assert_select 'td.revision', :text => /1.1/
|
assert_select 'td.revision', :text => /1.1/
|
||||||
assert_select 'td.author', :text => /LANG/
|
assert_select 'td.author', :text => /LANG/
|
||||||
end
|
end
|
||||||
# 1.2 line
|
# 1.2 line
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '32'
|
assert_select 'th.line-num a[data-txt=?]', '32'
|
||||||
assert_select 'td.revision', :text => /1.2/
|
assert_select 'td.revision', :text => /1.2/
|
||||||
assert_select 'td.author', :text => /LANG/
|
assert_select 'td.author', :text => /LANG/
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num[data-txt=22] ~ td.diff_out', :text => /def remove/
|
||||||
assert_select 'h2', :text => /2f9c0091/
|
assert_select 'h2', :text => /2f9c0091/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -403,7 +403,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num[data-txt=22] ~ td.diff_out', :text => /def remove/
|
||||||
assert_select 'h2', :text => /2f9c0091/
|
assert_select 'h2', :text => /2f9c0091/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -589,7 +589,7 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
|
|
||||||
# Line 23, changeset 2f9c0091
|
# Line 23, changeset 2f9c0091
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '23'
|
assert_select 'th.line-num a[data-txt=?]', '23'
|
||||||
assert_select 'td.revision', :text => /2f9c0091/
|
assert_select 'td.revision', :text => /2f9c0091/
|
||||||
assert_select 'td.author', :text => 'jsmith'
|
assert_select 'td.author', :text => 'jsmith'
|
||||||
assert_select 'td', :text => /remove_watcher/
|
assert_select 'td', :text => /remove_watcher/
|
||||||
@@ -673,7 +673,8 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
:rev => r1
|
:rev => r1
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select "a[data-txt=?]", '1'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '57ca437c'
|
assert_select "a", :text => '57ca437c'
|
||||||
assert_select "+ td.author", :text => "jsmith" do
|
assert_select "+ td.author", :text => "jsmith" do
|
||||||
@@ -698,7 +699,8 @@ class RepositoriesGitControllerTest < Redmine::RepositoryControllerTest
|
|||||||
:rev => r1
|
:rev => r1
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select "a[data-txt=?]", '1'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '83ca5fd5'
|
assert_select "a", :text => '83ca5fd5'
|
||||||
assert_select "+ td.author", :text => "Felix Schäfer" do
|
assert_select "+ td.author", :text => "Felix Schäfer" do
|
||||||
|
|||||||
@@ -396,7 +396,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
if @diff_c_support
|
if @diff_c_support
|
||||||
# Line 22 removed
|
# Line 22 removed
|
||||||
assert_select 'th.line-num:contains(22) ~ td.diff_out', :text => /def remove/
|
assert_select 'th.line-num[data-txt=22] ~ td.diff_out', :text => /def remove/
|
||||||
assert_select 'h2', :text => /4:def6d2f1254a/
|
assert_select 'h2', :text => /4:def6d2f1254a/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -492,7 +492,7 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
|
|||||||
|
|
||||||
# Line 22, revision 4:def6d2f1254a
|
# Line 22, revision 4:def6d2f1254a
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '22'
|
assert_select 'th.line-num a[data-txt=?]', '22'
|
||||||
assert_select 'td.revision', :text => '4:def6d2f1254a'
|
assert_select 'td.revision', :text => '4:def6d2f1254a'
|
||||||
assert_select 'td.author', :text => 'jsmith'
|
assert_select 'td.author', :text => 'jsmith'
|
||||||
assert_select 'td', :text => /remove_watcher/
|
assert_select 'td', :text => /remove_watcher/
|
||||||
@@ -548,7 +548,8 @@ class RepositoriesMercurialControllerTest < Redmine::RepositoryControllerTest
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_select "th.line-num", :text => '1' do
|
assert_select "th.line-num" do
|
||||||
|
assert_select "a[data-txt=?]", '1'
|
||||||
assert_select "+ td.revision" do
|
assert_select "+ td.revision" do
|
||||||
assert_select "a", :text => '20:709858aafd1b'
|
assert_select "a", :text => '20:709858aafd1b'
|
||||||
assert_select "+ td.author", :text => "jsmith" do
|
assert_select "+ td.author", :text => "jsmith" do
|
||||||
|
|||||||
@@ -557,14 +557,14 @@ class RepositoriesSubversionControllerTest < Redmine::RepositoryControllerTest
|
|||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '1'
|
assert_select 'th.line-num a[data-txt=?]', '1'
|
||||||
assert_select 'td.revision', :text => '4'
|
assert_select 'td.revision', :text => '4'
|
||||||
assert_select 'td.author', :text => 'jp'
|
assert_select 'td.author', :text => 'jp'
|
||||||
assert_select 'td', :text => /stdio.h/
|
assert_select 'td', :text => /stdio.h/
|
||||||
end
|
end
|
||||||
# Same revision
|
# Same revision
|
||||||
assert_select 'tr' do
|
assert_select 'tr' do
|
||||||
assert_select 'th.line-num', :text => '2'
|
assert_select 'th.line-num a[data-txt=?]', '2'
|
||||||
assert_select 'td.revision', :text => ''
|
assert_select 'td.revision', :text => ''
|
||||||
assert_select 'td.author', :text => ''
|
assert_select 'td.author', :text => ''
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user