const RowExpand = (function (){ const $status_expand_all = $("#js-row-expand-all"); let track_open_rows = []; function open_child_row(child_class_name){ const $children = $(`.${child_class_name}`); if(!track_open_rows.includes(child_class_name)) { $children.css('display', 'table-row'); track_open_rows.push(child_class_name); }else{ $children.css('display', 'none'); track_open_rows = [...Util.removeItemFromArray(track_open_rows, child_class_name)]; } } function open_all_row(){ if(!track_open_rows.includes('expand_all')) { $(".row").css('display', 'table-row'); track_open_rows.push('expand_all'); $status_expand_all.html("[-]"); }else{ // collapse all $(".row").css('display', 'none'); // open only first parent $(".parent_0").css('display', 'table-row'); track_open_rows = []; $status_expand_all.html("[+]"); } } return { open_child: open_child_row, open_all: open_all_row } })();