Skip to content

Commit e3ea49e

Browse files
TheoChevalierpascalchevrel
authored andcommitted
Highlight columns in Channel Comparizon for quick grammar checking
1 parent b80dfaf commit e3ea49e

4 files changed

Lines changed: 60 additions & 10 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
22
require_once INC . 'l10n-init.php';
33

4+
// Include JS lib after $javascript_include gets reset in l10n-init.php.
5+
$javascript_include = ['/js/select_column.js'];
6+
47
include MODELS . 'channelcomparison.php';
58
include VIEWS . 'channelcomparison.php';

app/views/channelcomparison.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// Helper anonymous variable to output a formatted table cell
55
$td = function ($key, $value) {
66
return "<td><span class=\"celltitle\">{$key}</span>"
7-
. "<div class=²\"string\">{$value}</div></td>";
7+
. "<div class=\"string\">{$value}</div></td>";
88
};
99

1010
?>
@@ -37,15 +37,13 @@
3737
<p class='subtitle'>There are no string differences for this locale between the <?=$repos_nice_names[$chan1]?> and <?=$repos_nice_names[$chan2]?> channels.</p>
3838

3939
<?php else: ?>
40-
<table class='collapsable'>
40+
<h3>Locale: <?=$locale?></h3>
41+
<table class='collapsable' id='modified_strings_table'>
4142
<thead>
42-
<tr class='column_headers'>
43-
<th colspan='3'>Locale: <?=$locale?></th>
44-
</tr>
4543
<tr class='column_headers'>
4644
<th>Key</th>
47-
<th><?=$chan1?></th>
48-
<th><?=$chan2?></th>
45+
<th class='select_header'><?=$chan1?><span>Select column</span></th>
46+
<th class='select_header'><?=$chan2?><span>Select column</span></th>
4947
</tr>
5048
</thead>
5149
<tbody>
@@ -65,12 +63,12 @@
6563

6664
<?php else : ?>
6765
<h3 id="new_strings">New strings added in <em><?=$locale?></em> between <?=$repos_nice_names[$chan1]?> and <?=$repos_nice_names[$chan2]?></h3>
68-
<table class="collapsable">
66+
<table class='collapsable' id='new_strings_table'>
6967
<thead>
7068
<tr class='column_headers'>
7169
<th>Entity</th>
72-
<th>en-US</th>
73-
<th><?=$locale?></th>
70+
<th class='select_header'>en-US<span>Select column</span></th>
71+
<th class='select_header'><?=$locale?><span>Select column</span></th>
7472
</tr>
7573
</thead>
7674
<tbody>

web/js/select_column.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
function selectColumn(index, tableID) {
2+
var columnSelector = '#' + tableID + ' tbody > tr > td:nth-child(' + (index + 1) + ')';
3+
var cells = $(columnSelector);
4+
5+
// Clear existing selections
6+
if (window.getSelection) { // all browsers, except IE before version 9
7+
window.getSelection().removeAllRanges();
8+
}
9+
10+
if (document.createRange) {
11+
cells.each(function(i, cell) {
12+
var rangeObj = document.createRange();
13+
rangeObj.selectNodeContents(cell);
14+
window.getSelection().addRange(rangeObj);
15+
});
16+
17+
} else { // Internet Explorer before version 9
18+
cells.each(function(i, cell) {
19+
var rangeObj = document.body.createTextRange();
20+
rangeObj.moveToElementText(cell);
21+
rangeObj.select();
22+
});
23+
}
24+
}
25+
26+
$(document).ready(function() {
27+
$('.select_header').click(function() {
28+
var columnNumber = $(this).index();
29+
var tableID = $(this).closest('table').attr('id');
30+
selectColumn(columnNumber, tableID);
31+
});
32+
});

web/style/transvision.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ th {
296296
padding: 0.5em;
297297
}
298298

299+
th.select_header {
300+
position: relative;
301+
}
302+
303+
th.select_header span {
304+
position: absolute;
305+
color: #fff;
306+
background-color: #1c75bc;
307+
right: 5px;
308+
top: 8px;
309+
font-weight: normal;
310+
font-size: 11px;
311+
padding: 2px 5px;
312+
border-radius: 3px;
313+
cursor: pointer;
314+
}
315+
299316
td {
300317
padding: 0.5em;
301318
border: 1px solid rgba(0, 0, 0, 0.05);

0 commit comments

Comments
 (0)