I have this code:
function setSidebar(visible) {
"use strict"
if (visible === "show") {
$("#sidebar-width-switch").prop('title', 'Hide Sidebar');
$("#sidebar").show();
} else {
$("#sidebar-width-switch").prop('title', 'Show Sidebar');
$("#sidebar").hide();
}
}
With typescript I have seen a lot more use of classes. In this case would it be more easy to maintain if functions like this were implemented as classes and if so then how would I do this and how would I call the class?
Here is how I call this now:
$('#sidebar-width-switch')
.click(function (e) {
if ($("#sidebar").is(':hidden')) {
setSidebar("show");
localStorage.setItem('Sidebar', 'show');
} else {
setSidebar("hide");
localStorage.setItem('Sidebar', 'hide');
}
});