Skip to content

Commit 860f0ab

Browse files
author
Fabio Picheli
committed
fix: collapse/expand
1 parent 0d2397a commit 860f0ab

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

app/app.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ function initialSetup(savedItems) {
4242
savedItems.collapsed ? collapseAllDiffBlocks() : expandAllDiffBlocks();
4343
savedItems.closed ? close() : open();
4444

45-
areDiffBlocksCollapsed() ? $('#collapseAll').hide() : $('#expandAll').hide();
46-
4745
// Click Functions
4846
$('.gct-folder-name').click(obj => {
4947
$($($(obj.currentTarget).parent()[0])[0]).toggleClass('gct-folder-open');
@@ -52,8 +50,8 @@ function initialSetup(savedItems) {
5250
$('.gct-file-name').click(obj => {
5351
var href = $(obj.currentTarget)[0].getAttribute("href");
5452
var file = $(`.file-info > a[href="${href}"]`).parent().parent().parent();
55-
if ($(file).hasClass('open Details--on')) {
56-
$(file).removeClass('open Details--on');
53+
if ($(file).hasClass('Details--on open')) {
54+
$(file).removeClass('Details--on open');
5755
}
5856
});
5957

@@ -236,7 +234,7 @@ function areDiffBlocksCollapsed() {
236234
var numberOfDiffBlocks = $('#files .file').length;
237235

238236
$('#files .file').each(function(){
239-
if ($(this).hasClass('open Details--on')) {
237+
if ($(this).hasClass('Details--on open')) {
240238
numberOfDiffBlocksCollapsed++;
241239
}
242240
});
@@ -245,11 +243,11 @@ function areDiffBlocksCollapsed() {
245243
}
246244

247245
function expandAllDiffBlocks() {
248-
$('#expandAll').hide();
249246
$('#collapseAll').show();
247+
$('#expandAll').hide();
250248
$('#files .file').each(function(){
251-
if ($(this).hasClass('open Details--on')) {
252-
$(this).removeClass('open Details--on')
249+
if (!$(this).hasClass('Details--on open')) {
250+
$(this).addClass('Details--on open')
253251
}
254252
});
255253
}
@@ -258,8 +256,8 @@ function collapseAllDiffBlocks() {
258256
$('#collapseAll').hide();
259257
$('#expandAll').show();
260258
$('#files .file').each(function(){
261-
if (!$(this).hasClass('open Details--on')) {
262-
$(this).addClass('open Details--on')
259+
if ($(this).hasClass('Details--on open')) {
260+
$(this).removeClass('Details--on open')
263261
}
264262
});
265263
}

0 commit comments

Comments
 (0)