Skip to content

Commit 3746a79

Browse files
committed
Improved rendering of side menu categories
1 parent 6851227 commit 3746a79

File tree

8 files changed

+32
-25
lines changed

8 files changed

+32
-25
lines changed

css/stylesheet.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ button.indent {
156156
padding-left: 28px;
157157
}
158158

159-
button.collapse {
159+
.algorithms.collapse {
160160
display: none;
161161
}
162162

@@ -577,4 +577,4 @@ button[disabled] {
577577
@-o-keyframes line_highlight {
578578
from { background: rgba(255, 0, 0, .1); }
579579
to { background: rgba(255, 0, 0, .3); }
580-
}
580+
}

js/dom/add_categories.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const {
88
each
99
} = $;
1010

11-
const addAlgorithmToCategoryDOM = (category, subList, algorithm) => {
12-
const $algorithm = $('<button class="indent collapse">')
11+
const getAlgorithmDOM = (category, subList, algorithm) => {
12+
return $('<button class="indent collapse">')
1313
.append(subList[algorithm])
1414
.attr('data-algorithm', algorithm)
1515
.attr('data-category', category)
@@ -35,17 +35,21 @@ const addCategoryToDOM = (category) => {
3535
.attr('data-category', category);
3636

3737
$category.click(function () {
38-
$(`.indent[data-category="${category}"]`).toggleClass('collapse');
39-
$(this).find('i.fa').toggleClass('fa-caret-right fa-caret-down');
38+
const $self = $(this);
39+
$self.toggleClass('open');
40+
$self.next().toggleClass('collapse');
41+
$self.find('i.fa').toggleClass('fa-caret-right fa-caret-down');
4042
});
4143

42-
$('#list').append($category);
44+
const $algorithms = $('<div class="algorithms collapse">');
45+
$('#list').append($category).append($algorithms);
4346

4447
each(categorySubList, (algorithm) => {
45-
addAlgorithmToCategoryDOM(category, categorySubList, algorithm);
48+
const $algorithm = getAlgorithmDOM(category, categorySubList, algorithm);
49+
$algorithms.append($algorithm);
4650
});
4751
};
4852

4953
module.exports = () => {
5054
each(app.getCategories(), addCategoryToDOM);
51-
};
55+
};

public/algorithm_visualizer.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ button.indent {
273273
padding-left: 28px;
274274
}
275275

276-
button.collapse {
276+
.algorithms.collapse {
277277
display: none;
278278
}
279279

@@ -691,4 +691,4 @@ button[disabled] {
691691

692692
/* Internet Explorer */
693693

694-
/* Opera < 12.1 */
694+
/* Opera < 12.1 */

public/algorithm_visualizer.js

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

public/algorithm_visualizer.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/algorithm_visualizer.min.js

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

public/algorithm_visualizer.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)