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({ return Object.freeze({
show: show, show: show,
hide: hide hide: hide,
toggle: toggle
}) })
})(); })();
})(window); })(window);

View file

@ -64,19 +64,22 @@
<% end %> <% end %>
</li> </li>
<!-- arrow for opening/closing --> <!-- 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" <span id="sideBarLeft"
class="fas fa-chevron-left" class="fas fa-chevron-left"
aria-hidden="true" aria-hidden="false"
onclick="SideBarToggle.hide()"
></span> ></span>
<span id="sideBarRight" <span id="sideBarRight"
class="fas fa-chevron-right" class="fas fa-chevron-right"
aria-hidden="true" aria-hidden="true"
onclick="SideBarToggle.show()"
style="display:none;" style="display:none;"
></span> ></span>
</li> </li>
</ul> </ul>
</div> </div>