diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-02-04 04:13:06 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-03-27 22:16:20 +0300 |
commit | 65c4dc19f77286374cbc93aa1e18dea8cd00dea5 (patch) | |
tree | c4697d79a26624becfa082d2e9c4451537c3b7ed /app/assets | |
parent | 3d4c2d0b510f15ac3f0abe6ba4468dd019b06278 (diff) |
Simplify toggle-nav-collapse JS
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/sidebar.js.coffee | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/app/assets/javascripts/sidebar.js.coffee b/app/assets/javascripts/sidebar.js.coffee index 7febcba0e94..2e3f5608257 100644 --- a/app/assets/javascripts/sidebar.js.coffee +++ b/app/assets/javascripts/sidebar.js.coffee @@ -3,12 +3,7 @@ $(document).on("click", '.toggle-nav-collapse', (e) -> collapsed = 'page-sidebar-collapsed' expanded = 'page-sidebar-expanded' - if $('.page-with-sidebar').hasClass(collapsed) - $('.page-with-sidebar').removeClass(collapsed).addClass(expanded) - $('.toggle-nav-collapse i').removeClass('fa-angle-right').addClass('fa-angle-left') - $.cookie("collapsed_nav", "false", { path: '/' }) - else - $('.page-with-sidebar').removeClass(expanded).addClass(collapsed) - $('.toggle-nav-collapse i').removeClass('fa-angle-left').addClass('fa-angle-right') - $.cookie("collapsed_nav", "true", { path: '/' }) + $('.page-with-sidebar').toggleClass("#{collapsed} #{expanded}") + $('.toggle-nav-collapse i').toggleClass("fa-angle-right fa-angle-left") + $.cookie("collapsed_nav", $('.page-with-sidebar').hasClass(collapsed), { path: '/' }) ) |