/
app.js
45 lines (40 loc) · 1.28 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**
* app.js: Main application JS file.
*/
(function ($) {
var App = {};
// DOMContentLoaded event handler.
App.onReady = function () {
$('.main .cv .wrapper .row i').each(function () {
$(this).click(App.onToggleSection);
});
}
// Toggle section click event handler.
App.onToggleSection = function (clickEvent) {
var buttonClass, blockClass;
var block = $(this).closest('.wrapper').find('.block');
var button = this;
var currentClass = block.attr('class');
if (currentClass.indexOf('hidden') > -1) {
blockClass = 'block visible';
buttonClass = 'fa fa-chevron-up open';
} else {
blockClass = 'block hidden';
buttonClass = 'fa fa-chevron-down closed';
}
$(block).attr('class', blockClass);
$(this).attr('class', buttonClass);
// Update the other blocks and buttons
$('.main .cv .wrapper .row i').each(function (index, element) {
if ($(element).attr('class') === $(button).attr('class') && element !== button) {
$(element).attr('class', 'fa fa-chevron-down closed');
}
});
$('.main .cv .wrapper .row .block').each(function (index, element) {
if ($(element).attr('class') === $(block).attr('class') && element !== block[0]) {
$(element).attr('class', 'block hidden');
}
});
}
$(document).ready(App.onReady);
}).call(this, jQuery);