Skip to content

Commit

Permalink
Merge branch 't/a571c9d2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolasburr committed Feb 1, 2019
2 parents a571c9d + b000297 commit d0e64d0
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/themes/nickolasburr/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* app.js: Main application JS file.
*/
(function ($) {
var CV_WRAPPER_ROW_SELECTOR = '.main .cv .wrapper .row';
var CV_WRAPPER_SELECTOR = '.main .cv .wrapper';

/**
* Main JS object.
Expand All @@ -11,17 +11,17 @@

// DOMContentLoaded event handler.
App.onReady = function () {
$('.main .cv .wrapper .row').each(function () {
$(this).find('i').click(App.onToggleSection);
$(this).find('.fieldname').click(App.onToggleSection);
$(CV_WRAPPER_SELECTOR).each(function (index, element) {
$(element).find('i').click(App.onToggleSection);
$(element).find('.fieldname').click(App.onToggleSection);
});
}

// Toggle section click event handler.
App.onToggleSection = function (clickEvent) {
var buttonClass, blockClass;
var block = $(this).closest('.wrapper').find('.block');
var button = $(clickEvent.target.parentNode).find('i');
var target = clickEvent.target;
var block = $(target).closest('.wrapper').find('.block')[0];
var button = $(target.parentNode).find('i')[0];

if ($(block).attr('class').indexOf('hidden') > -1) {
$(block).attr('class', 'block visible');
Expand All @@ -31,15 +31,15 @@
$(button).attr('class', 'fa fa-chevron-down closed');
}

$(CV_WRAPPER_ROW_SELECTOR).each(function (index, element) {
var thisArrow = $(element).find('i');
var thisBlock = $(element).find('.block');
$(CV_WRAPPER_SELECTOR).each(function (index, element) {
var thisArrow = $(element).find('i')[0];
var thisBlock = $(element).find('.block')[0];

if ($(thisArrow).attr('class') === $(button).attr('class') && thisArrow !== button) {
if (thisArrow && $(thisArrow).attr('class') === $(button).attr('class') && thisArrow !== button) {
$(thisArrow).attr('class', 'fa fa-chevron-down closed');
}

if ($(thisBlock).attr('class') === $(block).attr('class') && thisBlock !== block) {
if (thisBlock && $(thisBlock).attr('class') === $(block).attr('class') && thisBlock !== block) {
$(thisBlock).attr('class', 'block hidden');
}
});
Expand Down

0 comments on commit d0e64d0

Please sign in to comment.