Improve toggle

This commit is contained in:
Luka Murn 2018-05-24 13:39:04 +02:00
parent f972676f8d
commit c9f3de9f27
2 changed files with 21 additions and 6 deletions

View file

@ -27,9 +27,21 @@
});
}
function toggle() {
var btn = $('#sideBarButton');
if (btn.attr('data-shown')) {
btn.attr('data-shown', false);
hide();
} else {
btn.attr('data-shown', true);
show();
}
}
return Object.freeze({
show: show,
hide: hide
hide: hide,
toggle: toggle
})
})();
})(window);

View file

@ -64,19 +64,22 @@
<% end %>
</li>
<!-- arrow for opening/closing -->
<li class="text-center" style="padding: 5px;">
<li class="text-center"
style="padding: 5px;"
id="sideBarButton"
data-shown="true"
onclick="SideBarToggle.toggle()"
>
<span id="sideBarLeft"
class="fas fa-chevron-left"
aria-hidden="true"
onclick="SideBarToggle.hide()"
aria-hidden="false"
></span>
<span id="sideBarRight"
class="fas fa-chevron-right"
aria-hidden="true"
onclick="SideBarToggle.show()"
style="display:none;"
></span>
</li>
</li>
</ul>
</div>