BigW Consortium Gitlab

Commit 254a63dc by Dmitriy Zaporozhets

Improve collapsing sidebar

parent ded30e3e
...@@ -27,10 +27,15 @@ $(window).resize -> ...@@ -27,10 +27,15 @@ $(window).resize ->
$(document).on("click", '.toggle-nav-collapse', (e) -> $(document).on("click", '.toggle-nav-collapse', (e) ->
e.preventDefault() e.preventDefault()
if $('.page-with-sidebar').hasClass('collapsed') collapsed = 'page-sidebar-collapsed'
$('.page-with-sidebar').removeClass('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: '/' }) $.cookie("collapsed_nav", "false", { path: '/' })
else else
$('.page-with-sidebar').addClass('collapsed') $('.page-with-sidebar').removeClass(expanded).addClass(collapsed)
$('.toggle-nav-collapse i').removeClass('fa-angle-left').addClass('fa-angle-right')
$.cookie("collapsed_nav", "true", { path: '/' }) $.cookie("collapsed_nav", "true", { path: '/' })
) )
.page-with-sidebar { .page-with-sidebar {
background: #F5F5F5; background: #F5F5F5;
...@@ -101,16 +99,14 @@ ...@@ -101,16 +99,14 @@
} }
@mixin expanded-sidebar { @mixin expanded-sidebar {
.page-with-sidebar { padding-left: $sidebar_width;
padding-left: $sidebar_width;
}
.sidebar-wrapper { .sidebar-wrapper {
width: $sidebar_width; width: $sidebar_width;
.nav-sidebar { .nav-sidebar {
margin-top: 20px; margin-top: 20px;
position: relative; position: fixed;
top: 45px; top: 45px;
width: $sidebar_width; width: $sidebar_width;
} }
...@@ -122,9 +118,7 @@ ...@@ -122,9 +118,7 @@
} }
@mixin folded-sidebar { @mixin folded-sidebar {
.page-with-sidebar { padding-left: 50px;
padding-left: 50px;
}
.sidebar-wrapper { .sidebar-wrapper {
width: 52px; width: 52px;
...@@ -150,47 +144,33 @@ ...@@ -150,47 +144,33 @@
} }
} }
.collapse-nav { .collapse-nav a {
position: relative; position: fixed;
top: 50px; bottom: 15px;
width: 230px; padding: 10px;
text-align: right; background: #DDD;
padding-right: 21px;
} }
.page-with-sidebar.collapsed { @media (max-width: $screen-md-max) {
.page-sidebar-collapsed {
.collapse-nav { @include folded-sidebar;
width: 53px;
} }
padding-left: 50px; .page-sidebar-expanded {
@include folded-sidebar;
.sidebar-wrapper {
width: 52px;
overflow-x: hidden;
.nav-sidebar {
width: 52px;
}
.nav-sidebar li a > span {
display: none;
}
} }
}
.collapse-nav {
@media (max-width: $screen-md-max) { display: none;
@include folded-sidebar; }
} }
@media(min-width: $screen-md-max) { @media(min-width: $screen-md-max) {
@include expanded-sidebar; .page-sidebar-collapsed {
} @include folded-sidebar;
}
@media (max-width: $screen-md-max) { .page-sidebar-expanded {
.collapse-nav { @include expanded-sidebar;
display: none;
} }
} }
...@@ -315,4 +315,12 @@ module ApplicationHelper ...@@ -315,4 +315,12 @@ module ApplicationHelper
profile_key_path(key) profile_key_path(key)
end end
end end
def nav_sidebar_class
if nav_menu_collapsed?
"page-sidebar-collapsed"
else
"page-sidebar-expanded"
end
end
end end
- if nav_menu_collapsed? - if nav_menu_collapsed?
= link_to icon('plus-square'), '#', class: 'toggle-nav-collapse' = link_to icon('angle-right'), '#', class: 'toggle-nav-collapse'
- else - else
= link_to icon('minus-square'), '#', class: 'toggle-nav-collapse' = link_to icon('angle-left'), '#', class: 'toggle-nav-collapse'
- if defined?(sidebar) - if defined?(sidebar)
.page-with-sidebar{:class => ("collapsed" if nav_menu_collapsed?)} .page-with-sidebar{ class: nav_sidebar_class }
= render "layouts/broadcast" = render "layouts/broadcast"
.sidebar-wrapper .sidebar-wrapper
= render(sidebar) = render(sidebar)
.collapse-nav .collapse-nav
= render :partial => 'layouts/collapse_button' = render partial: 'layouts/collapse_button'
.content-wrapper .content-wrapper
.container-fluid .container-fluid
.content .content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment