diff --git a/Bootstrap.Admin/Content/css/admin-responsive.css b/Bootstrap.Admin/Content/css/admin-responsive.css index 2869a06d..ebc2e2c0 100644 --- a/Bootstrap.Admin/Content/css/admin-responsive.css +++ b/Bootstrap.Admin/Content/css/admin-responsive.css @@ -26,6 +26,10 @@ margin-left: 0; } + #main-content.open { + display: none; + } + .modal-dialog { width: 540px; margin: 20px auto; diff --git a/Bootstrap.Admin/Content/css/admin.css b/Bootstrap.Admin/Content/css/admin.css index 1c186598..118dbafb 100644 --- a/Bootstrap.Admin/Content/css/admin.css +++ b/Bootstrap.Admin/Content/css/admin.css @@ -131,13 +131,9 @@ text-align: left; } -.sidebar-closed #main-content { - margin-left: 0; -} - -.sidebar-closed #sidebar { - display: none !important; -} + #main-content.closed { + margin-left: 0; + } #sidebar { width: 210px; diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js index c128d876..8091455a 100644 --- a/Bootstrap.Admin/Content/js/common-scripts.js +++ b/Bootstrap.Admin/Content/js/common-scripts.js @@ -1,4 +1,7 @@ $(function () { + var $sidebar = $("#sidebar"); + var $main = $('#main-content'); + $('#nav-accordion').dcAccordion({ eventType: 'click', autoClose: true, @@ -20,21 +23,22 @@ $('#websiteFooter').text($('#footer').val()); - $('#sidebar').on('click', 'a', function () { + $sidebar.on('click', 'a', function () { var o = ($(this).offset()); diff = 300 - o.top; if (diff > 0) - $("#sidebar").scrollTo("-=" + Math.abs(diff), 500); + $sidebar.scrollTo("-=" + Math.abs(diff), 500); else - $("#sidebar").scrollTo("+=" + Math.abs(diff), 500); + $sidebar.scrollTo("+=" + Math.abs(diff), 500); }); - $('.sidebar-toggle-box').click(function () { - if ($('#sidebar').is(":visible") === true) { - $(".sidebar").addClass("sidebar-closed"); + $('.sidebar-toggle-box').on('click', function () { + if ($sidebar.is(":visible") === true) { + $sidebar.hide(); + $main.addClass('closed').removeClass('open'); } else { - $(".sidebar").removeClass("sidebar-closed"); - $("#sidebar").show(); + $sidebar.show(); + $main.addClass('open').removeClass('closed'); } }); diff --git a/Bootstrap.Admin/Views/Shared/_Admin.cshtml b/Bootstrap.Admin/Views/Shared/_Admin.cshtml index 197ac043..3c2d22d5 100644 --- a/Bootstrap.Admin/Views/Shared/_Admin.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Admin.cshtml @@ -18,7 +18,7 @@ @RenderSection("Javascript", false) } -