enhance judgement of active menu

This commit is contained in:
printempw 2016-12-17 19:02:56 +08:00
parent 58014e9b1e
commit 2807c3ce6d
2 changed files with 15 additions and 2 deletions

View File

@ -151,7 +151,16 @@ if (! function_exists('bs_menu')) {
$content = "";
foreach ($data as $key => $value) {
$content .= (app('request')->is(@$value['link'])) ? '<li class="active">' : '<li>';
$active = app('request')->is(@$value['link']);
// also set parent as active if any child is active
foreach ((array) @$value['children'] as $childKey => $childValue) {
if (app('request')->is(@$childValue['link'])) {
$active = true;
}
}
$content .= $active ? '<li class="active">' : '<li>';
if (isset($value['children'])) {
$content .= '<a href="#"><i class="fa '.$value['icon'].'"></i> <span>'.trans($value['title']).'</span><span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span></a>';

View File

@ -2,7 +2,7 @@
* @Author: printempw
* @Date: 2016-09-15 10:39:41
* @Last Modified by: printempw
* @Last Modified time: 2016-12-10 21:57:23
* @Last Modified time: 2016-12-17 18:47:02
*/
'use strict';
@ -44,3 +44,7 @@ function do_logout(callback) {
error: showAjaxError
});
}
$(document).ready(function() {
$('li.active > ul').show();
});