Skip to content

Commit 6dc1df0

Browse files
authored
Reinstate aoColumns so that we have proper sorting in percent columns (#80)
* Reinstate aoColumns so that we have proper sorting in percent columns Regression from first release. See: bc11506#r36735556 Thanks @dmitry Fixes #79 Sorry for the noise of the slight changes in the other parts of the JS, VSCode made a decision and I was too lazy to go back and make it a separate commit. :see-no-evil: Relevant code is in layout.erb and the top of application.js (where there's new code) * expand comment on column and sorting handling
1 parent 7c32a40 commit 6dc1df0

File tree

4 files changed

+67
-42
lines changed

4 files changed

+67
-42
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.11.0.beta2 (unreleased)
2+
=======
3+
4+
## Bugfixes
5+
* Fixed sorting of percent column (regression in previous release)
6+
17
0.11.0.beta1 (2020-01-05)
28
========
39

assets/javascripts/application.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,36 @@
22
//= require_directory ./plugins/
33
//= require_self
44

5-
$(document).ready(function() {
5+
$(document).ready(function () {
6+
branchCoverageActivated = $("body").data("branch-coverage") == true;
7+
68
// Configuration for fancy sortable tables for source file groups
9+
// For what these columns are, cecl out file_list.erb - null basically
10+
// does normal/number style sorting which fine for hit/missed lines only
11+
// percentages like "covered percent" need special sorting arguments.
12+
lineColumns = [null, { "sType": "percent" }, null, null, null, null, null];
13+
branchColumns = [{ "sType": "percent" }, null, null, null];
14+
15+
dataColumns = branchCoverageActivated ? lineColumns.concat(branchColumns) : lineColumns;
16+
717
$('.file_list').dataTable({
8-
"aaSorting": [[ 1, "asc" ]],
18+
"aaSorting": [[1, "asc"]],
919
"bPaginate": false,
10-
"bJQueryUI": true
20+
"bJQueryUI": true,
21+
"aoColumns": dataColumns
1122
});
1223

1324
// Syntax highlight all files up front - deactivated
1425
// $('.source_table pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
1526

1627
// Syntax highlight source files on first toggle of the file view popup
17-
$("a.src_link").click(function() {
28+
$("a.src_link").click(function () {
1829
// Get the source file element that corresponds to the clicked element
1930
var source_table = $($(this).attr('href'));
2031

2132
// If not highlighted yet, do it!
2233
if (!source_table.hasClass('highlighted')) {
23-
source_table.find('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
34+
source_table.find('pre code').each(function (i, e) { hljs.highlightBlock(e, ' ') });
2435
source_table.addClass('highlighted');
2536
};
2637
});
@@ -35,14 +46,14 @@ $(document).ready(function() {
3546
opacity: 1,
3647
width: "95%",
3748
height: "95%",
38-
onLoad: function() {
49+
onLoad: function () {
3950
prev_anchor = curr_anchor ? curr_anchor : jQuery.url.attr('anchor');
4051
curr_anchor = this.href.split('#')[1];
4152
window.location.hash = curr_anchor;
4253
},
43-
onCleanup: function() {
54+
onCleanup: function () {
4455
if (prev_anchor && prev_anchor != curr_anchor) {
45-
$('a[href="#'+prev_anchor+'"]').click();
56+
$('a[href="#' + prev_anchor + '"]').click();
4657
curr_anchor = prev_anchor;
4758
} else {
4859
$('.group_tabs a:first').click();
@@ -53,13 +64,13 @@ $(document).ready(function() {
5364
}
5465
});
5566

56-
window.onpopstate = function(event){
57-
if (location.hash.substring(0,2) == "#_") {
67+
window.onpopstate = function (event) {
68+
if (location.hash.substring(0, 2) == "#_") {
5869
$.colorbox.close();
5970
curr_anchor = jQuery.url.attr('anchor');
6071
} else {
6172
if ($('#colorbox').is(':hidden')) {
62-
$('a.src_link[href="'+location.hash+'"]').colorbox({ open: true });
73+
$('a.src_link[href="' + location.hash + '"]').colorbox({ open: true });
6374
}
6475
}
6576
};
@@ -69,23 +80,23 @@ $(document).ready(function() {
6980
$('.file_list_container').hide();
7081

7182
// Add tabs based upon existing file_list_containers
72-
$('.file_list_container h2').each(function(){
83+
$('.file_list_container h2').each(function () {
7384
var container_id = $(this).parent().attr('id');
7485
var group_name = $(this).find('.group_name').first().html();
7586
var covered_percent = $(this).find('.covered_percent').first().html();
7687

77-
$('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name + ' ('+ covered_percent +')</a></li>');
88+
$('.group_tabs').append('<li><a href="#' + container_id + '">' + group_name + ' (' + covered_percent + ')</a></li>');
7889
});
7990

80-
$('.group_tabs a').each( function() {
91+
$('.group_tabs a').each(function () {
8192
$(this).addClass($(this).attr('href').replace('#', ''));
8293
});
8394

8495
// Make sure tabs don't get ugly focus borders when active
85-
$('.group_tabs a').live('focus', function() { $(this).blur(); });
96+
$('.group_tabs a').live('focus', function () { $(this).blur(); });
8697

8798
var favicon_path = $('link[rel="shortcut icon"]').attr('href');
88-
$('.group_tabs a').live('click', function(){
99+
$('.group_tabs a').live('click', function () {
89100
if (!$(this).parent().hasClass('active')) {
90101
$('.group_tabs a').parent().removeClass('active');
91102
$(this).parent().addClass('active');
@@ -96,7 +107,7 @@ $(document).ready(function() {
96107
// Force favicon reload - otherwise the location change containing anchor would drop the favicon...
97108
// Works only on firefox, but still... - Anyone know a better solution to force favicon on local file?
98109
$('link[rel="shortcut icon"]').remove();
99-
$('head').append('<link rel="shortcut icon" type="image/png" href="'+ favicon_path +'" />');
110+
$('head').append('<link rel="shortcut icon" type="image/png" href="' + favicon_path + '" />');
100111
};
101112
return false;
102113
});
@@ -106,7 +117,7 @@ $(document).ready(function() {
106117
if (anchor.length == 40) {
107118
$('a.src_link[href=#' + anchor + ']').click();
108119
} else {
109-
$('.group_tabs a.'+anchor.replace('_', '')).click();
120+
$('.group_tabs a.' + anchor.replace('_', '')).click();
110121
}
111122
} else {
112123
$('.group_tabs a:first').click();

public/application.js

Lines changed: 26 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

views/layout.erb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<title>Code coverage for <%= SimpleCov.project_name %></title>
55
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
6-
<script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
6+
<script src='<%= assets_path('application.js') %>' type='text/javascript'></script>
77
<link href='<%= assets_path('application.css') %>' media='screen, projection, print' rel='stylesheet' type='text/css'>
88
<link rel="shortcut icon" type="image/png" href="<%= assets_path("favicon_#{coverage_css_class(result.source_files.covered_percent)}.png") %>" />
99
<link rel="icon" type="image/png" href="<%= assets_path('favicon.png') %>" />
1010
</head>
11-
12-
<body>
11+
12+
<body<%= ' data-branch-coverage=true' if branchable_result? %>>
1313
<div id="loading">
1414
<img src="<%= assets_path('loading.gif') %>" alt="loading"/>
1515
</div>
@@ -24,13 +24,13 @@
2424
<%= formatted_file_list(name, files) %>
2525
<% end %>
2626
</div>
27-
27+
2828
<div id="footer">
29-
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v<%= SimpleCov::VERSION %>
29+
Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v<%= SimpleCov::VERSION %>
3030
and simplecov-html v<%= SimpleCov::Formatter::HTMLFormatter::VERSION %><br/>
3131
using <%= result.command_name %>
3232
</div>
33-
33+
3434
<div class="source_files">
3535
<% result.source_files.each do |source_file| %>
3636
<%= formatted_source_file(source_file) %>

0 commit comments

Comments
 (0)