Skip to content

Commit c670a2e

Browse files
author
Fabio Picheli
committed
regex fix
1 parent cc6ecbd commit c670a2e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

app/app.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function start() {
1414
if(location.origin + location.pathname != oldLocation) {
1515
oldLocation = location.origin + location.pathname;
1616

17-
urlRegex = /(http|https):\/\/(www\.)?github\.com\/[-a-zA-Z1-9]*\/[-a-zA-Z0-9]*\/pull\/[0-9]*\/(files|commits)/;
17+
urlRegex = /(http|https):\/\/(www\.)?github\.com\/[-a-zA-Z0-9]*\/[-a-zA-Z0-9]*\/pull\/[0-9]*\/(files|commits)/;
1818
if(location.href.match(urlRegex)) { // show only on PR files page
1919
initialSetup();
2020
}
@@ -38,6 +38,14 @@ function initialSetup() {
3838
$($($(obj.currentTarget).parent()[0])[0]).toggleClass('gct-folder-open');
3939
});
4040

41+
$('.gct-file-name').click(obj => {
42+
var href = $(obj.currentTarget)[0].getAttribute("href");
43+
var file = $(`.file-info > a[href="${href}"]`).parent().parent().parent();
44+
if ($(file).hasClass('open Details--on')) {
45+
$(file).removeClass('open Details--on');
46+
}
47+
});
48+
4149
$('#openAll').click(() => {
4250
$('.gct-folder').addClass('gct-folder-open');
4351
});
@@ -156,8 +164,7 @@ function mergeObjects(og, so) {
156164
return og;
157165
}
158166

159-
function areDiffBlocksCollapsed()
160-
{
167+
function areDiffBlocksCollapsed() {
161168
var numberOfDiffBlocksCollapsed = 0;
162169
var numberOfDiffBlocks = $('#files .file').length;
163170

@@ -170,8 +177,7 @@ function areDiffBlocksCollapsed()
170177
return numberOfDiffBlocksCollapsed === numberOfDiffBlocks;
171178
}
172179

173-
function expandAllDiffBlocks()
174-
{
180+
function expandAllDiffBlocks() {
175181
$('#expandAll').hide();
176182
$('#collapseAll').show();
177183
$('#files .file').each(function(){
@@ -181,8 +187,7 @@ function expandAllDiffBlocks()
181187
});
182188
}
183189

184-
function collapseAllDiffBlocks()
185-
{
190+
function collapseAllDiffBlocks() {
186191
$('#collapseAll').hide();
187192
$('#expandAll').show();
188193
$('#files .file').each(function(){

0 commit comments

Comments
 (0)