修复BUG:前台页面跳转时菜单没有正确设置active样式

This commit is contained in:
Argo-Lenovo 2016-11-19 13:07:34 +08:00
parent 3dc3a8b435
commit 9f01d7a88a
7 changed files with 24 additions and 23 deletions

View File

@ -303,7 +303,6 @@
<Content Include="Views\Shared\UserConfig.cshtml" />
<Content Include="Views\Shared\GroupConfig.cshtml" />
<Content Include="Views\Admin\Logs.cshtml" />
<Content Include="Views\Shared\Content.cshtml" />
<Content Include="Views\Admin\Profiles.cshtml" />
<Content Include="Views\Shared\Footer.cshtml" />
<Content Include="Views\Shared\MenuTree.cshtml" />

View File

@ -514,10 +514,6 @@ a, a:hover, a:focus {
margin-bottom: 14px;
}
.dropdown-menu.menu .menu-submenu li p.active {
color: #FF6C60;
}
.dropdown-menu.menu .menu-submenu li a {
margin-bottom: 15px;
display: inline-block;
@ -525,12 +521,12 @@ a, a:hover, a:focus {
font-size: 13px;
}
.dropdown-menu.menu .menu-submenu li a.active {
color: #FF6C60;
.dropdown-menu.menu .menu-submenu li a.active, .dropdown-menu.menu .menu-submenu li p.active {
color: #0376d8;
}
.dropdown-menu.menu .menu-submenu li a:hover {
color: #FF6C60;
color: #2e6da4;
}
.dropdown-menu.menu .menu-submenu li a i {

View File

@ -1,6 +1,5 @@
$(function () {
$('#navbar').attr('data-toggle', "dropdown").addClass('dropdown-toggle');
function iframeResposive() {
try {
var fra = $('iframe').get(0);
@ -12,13 +11,22 @@
$(window).on('load', iframeResposive);
$(window).on('resize', iframeResposive);
$('.menu-submenu a').click(function (event) {
var act = $(this).attr("data-act");
var $subMenu = $('#submenu');
$subMenu.on('click', 'a', function (event) {
var $this = $(this);
var act = $this.attr("data-act");
if (act === "True") return true;
event.preventDefault();
$('.menu-submenu a, .menu-submenu p').removeClass('active');
$(this).addClass('active');
$(this).parents("ul").first().find('p').addClass('active');
$('iframe').attr('src', $(this).attr('href'));
$subMenu.find('p, a').removeClass('active');
setActive($this);
$('iframe').attr('src', $this.attr('href'));
});
$subMenu.find('a').each(function (index, ele) {
var $this = $(this);
if ($this.attr('href') == window.location.pathname) setActive($this);
});
function setActive(ele) {
ele.addClass('active');
ele.parents("ul").first().find('p').addClass('active');
}
});

View File

@ -8,4 +8,6 @@
@section header {
@Html.Partial("Header", Model)
}
@Html.Partial("Content", Model)
<div class="content-body">
<iframe src="@Model.Url"></iframe>
</div>

View File

@ -1,4 +0,0 @@
@model ContentModel
<div class="content-body">
<iframe src="@Model.Url"></iframe>
</div>

View File

@ -9,10 +9,10 @@
<!--logo end-->
@if (Model.Menus.Count() > 0 && Model.ShowMenu)
{
<ul class="dropdown-menu menu">
<ul id="menu" class="dropdown-menu menu">
<div class="arrow-up"></div>
<li>
<div class="menu-submenu">
<div id="submenu" class="menu-submenu">
@foreach (var menu in Model.Menus)
{
@Html.Partial("SubMenu", menu)

View File

@ -5,7 +5,7 @@
</li>
@foreach (var menu in Model.Menus)
{
<li><a href="@Url.Content(menu.Url)" data-act="@menu.Url.StartsWith("~")"><i class="@menu.Icon"></i><span>@menu.Name</span></a></li>
<li><a href="@Url.Content(menu.Url)" data-act="@menu.Url.StartsWith("~")"><i class="@menu.Icon"></i>@menu.Name</a></li>
}
</ul>