Merge pull request #1089 from almasaeed2010/revert-1084-master

Revert "Fixed loss of "active" class after collapsing menu"
pull/1007/head
Abdullah Almsaeed 9 years ago committed by GitHub
commit d003040ddc

@ -541,8 +541,7 @@ a:focus {
margin-right: 10px; margin-right: 10px;
margin-top: 3px; margin-top: 3px;
} }
.sidebar-menu > li.open > a > .fa-angle-left, .sidebar-menu li.active > a > .fa-angle-left {
.sidebar-menu .treeview-menu > li.open > a > .fa-angle-left {
-webkit-transform: rotate(-90deg); -webkit-transform: rotate(-90deg);
-ms-transform: rotate(-90deg); -ms-transform: rotate(-90deg);
-o-transform: rotate(-90deg); -o-transform: rotate(-90deg);

31
dist/js/app.js vendored

@ -53,8 +53,6 @@ $.AdminLTE.options = {
//This option is forced to true if both the fixed layout and sidebar mini //This option is forced to true if both the fixed layout and sidebar mini
//are used together //are used together
sidebarExpandOnHover: false, sidebarExpandOnHover: false,
//Do not close menu after opening
sidebarKeepMenuOpen: false,
//BoxRefresh Plugin //BoxRefresh Plugin
enableBoxRefresh: true, enableBoxRefresh: true,
//Bootstrap.js tooltip //Bootstrap.js tooltip
@ -390,17 +388,10 @@ function _init() {
$.AdminLTE.tree = function (menu) { $.AdminLTE.tree = function (menu) {
var _this = this; var _this = this;
var animationSpeed = $.AdminLTE.options.animationSpeed; var animationSpeed = $.AdminLTE.options.animationSpeed;
var keepMenuOpen = $.AdminLTE.options.sidebarKeepMenuOpen;
//Find active li and set open class
$(menu + ' .sidebar-menu').find('li.active').addClass('open');
$(document).on('click', menu + ' li a', function (e) { $(document).on('click', menu + ' li a', function (e) {
//Get the clicked link and the next element //Get the clicked link and the next element
var $this = $(this); var $this = $(this);
var checkElement = $this.next(); var checkElement = $this.next();
//Get the parent li
var parent_li = $this.parent("li");
//Check if the next element is a menu and is visible //Check if the next element is a menu and is visible
if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) { if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
@ -410,27 +401,25 @@ function _init() {
//Fix the layout in case the sidebar stretches over the height of the window //Fix the layout in case the sidebar stretches over the height of the window
//_this.layout.fix(); //_this.layout.fix();
}); });
parent_li.removeClass('open'); checkElement.parent("li").removeClass("active");
} }
//If the menu is not visible //If the menu is not visible
else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) { else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
//Get the parent menu //Get the parent menu
var parent = $this.parents('ul').first(); var parent = $this.parents('ul').first();
// //Close all open menus within the parent
var ul = parent.find('ul:visible').not(':has(".active")'); var ul = parent.find('ul:visible').slideUp(animationSpeed);
if (!keepMenuOpen) { //Remove the menu-open class from the parent
//Close all open menus within the parent ul.removeClass('menu-open');
ul.slideUp(animationSpeed); //Get the parent li
//Remove the menu-open class from the parent var parent_li = $this.parent("li");
ul.removeClass('menu-open');
//Remove all open classes except active
parent.find('.treeview').not(':has(".active")').removeClass('open');
}
parent_li.addClass('open');
//Open the target menu and add the menu-open class //Open the target menu and add the menu-open class
checkElement.slideDown(animationSpeed, function () { checkElement.slideDown(animationSpeed, function () {
//Add the class active to the parent li //Add the class active to the parent li
checkElement.addClass('menu-open'); checkElement.addClass('menu-open');
parent.find('li.active').removeClass('active');
parent_li.addClass('active');
//Fix the layout in case the sidebar stretches over the height of the window //Fix the layout in case the sidebar stretches over the height of the window
_this.layout.fix(); _this.layout.fix();
}); });

Loading…
Cancel
Save