Skip to content

Commit d40e446

Browse files
committed
use js control active status of siderbar-menu & body default fixed
1 parent 26af7a2 commit d40e446

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

adminlteui/templates/admin/base.html

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
{% block extrahead %} {% endblock %}
3131
</head>
32-
<body class="hold-transition skin-blue sidebar-mini">
32+
<body class="hold-transition skin-blue sidebar-mini fixed">
3333
<div class="wrapper">
3434

3535
<header class="main-header">
@@ -328,8 +328,8 @@ <h3>
328328
<!-- /.search form -->
329329
<!-- sidebar menu: : style can be found in sidebar.less -->
330330
<ul class="sidebar-menu">
331-
<li class="header">页面导航</li>
332-
<li class="active">
331+
<li class="header">{% trans 'MAIN NAVIGATION' %}</li>
332+
<li>
333333
<a href="/admin/">
334334
<i class="fa fa-dashboard"></i> <span>{% trans 'Dashboard' %}</span>
335335
</a>
@@ -338,7 +338,7 @@ <h3>
338338
{% if app_list %}
339339
{% for app in app_list %}
340340
<li class="treeview">
341-
<a href="#">
341+
<a href="javascript:void(0)">
342342
<i class="fa fa-database"></i>
343343
<span style="overflow: hidden; display: inline-block; vertical-align:top;">{{ app.name }}</span>
344344
<span class="pull-right-container">
@@ -607,11 +607,32 @@ <h3 class="control-sidebar-heading">Chat Settings</h3>
607607
<!-- AdminLTE for demo purposes -->
608608
<script src={% static "admin/dist/js/demo.js" %}></script>
609609
<script>
610-
// 用来控制iframe自适应行高
611-
$("#page_content").load(function () {
612-
var mainheight = $(this).contents().find("body").height() + 20;
613-
$(this).height(mainheight);
614-
});
610+
// use js control active status of siderbar-menu
611+
$(function() {
612+
var menuActions = document.querySelectorAll('.sidebar-menu a')
613+
for (var i in menuActions) {
614+
try {
615+
if (window.location.pathname === '/admin/') {
616+
menuActions[i].parentNode.setAttribute('class', 'active')
617+
break
618+
}
619+
620+
if (window.location.href.indexOf(menuActions[i].href) !== -1) {
621+
if (menuActions[i].href===window.location.origin + '/admin/') {
622+
continue
623+
}
624+
625+
console.log('menu matched.', window.location.href, menuActions[i].href);
626+
menuActions[i].parentNode.setAttribute('class', 'active');
627+
menuActions[i].parentNode.parentNode.setAttribute('class', 'treeview-menu menu-open');
628+
menuActions[i].parentNode.parentNode.parentNode.setAttribute('class', 'treeview active');
629+
// break
630+
}
631+
} catch (e) {
632+
console.log(window.location.href, menuActions[i].href, e)
633+
}
634+
}
635+
})
615636
</script>
616637

617638
{% block custom_js %}{% endblock %}

0 commit comments

Comments
 (0)