mirror of https://github.com/ColorlibHQ/AdminLTE
Fix isse #683
parent
1a29b58111
commit
db51bd8b98
|
@ -389,47 +389,47 @@ function _init() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var animationSpeed = $.AdminLTE.options.animationSpeed;
|
var animationSpeed = $.AdminLTE.options.animationSpeed;
|
||||||
$(document).off('click', menu + ' li a')
|
$(document).off('click', menu + ' li a')
|
||||||
.on('click', menu + ' li a', function (e) {
|
.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();
|
||||||
|
|
||||||
//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'))) {
|
||||||
//Close the menu
|
//Close the menu
|
||||||
checkElement.slideUp(animationSpeed, function () {
|
checkElement.slideUp(animationSpeed, function () {
|
||||||
checkElement.removeClass('menu-open');
|
checkElement.removeClass('menu-open');
|
||||||
//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();
|
||||||
});
|
});
|
||||||
checkElement.parent("li").removeClass("active");
|
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
|
//Close all open menus within the parent
|
||||||
var ul = parent.find('ul:visible').slideUp(animationSpeed);
|
var ul = parent.find('ul:visible').slideUp(animationSpeed);
|
||||||
//Remove the menu-open class from the parent
|
//Remove the menu-open class from the parent
|
||||||
ul.removeClass('menu-open');
|
ul.removeClass('menu-open');
|
||||||
//Get the parent li
|
//Get the parent li
|
||||||
var parent_li = $this.parent("li");
|
var parent_li = $this.parent("li");
|
||||||
|
|
||||||
//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.find('li.active').removeClass('active');
|
||||||
parent_li.addClass('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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//if this isn't a link, prevent the page from being redirected
|
//if this isn't a link, prevent the page from being redirected
|
||||||
if (checkElement.is('.treeview-menu')) {
|
if (checkElement.is('.treeview-menu')) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ControlSidebar
|
/* ControlSidebar
|
||||||
|
@ -502,9 +502,13 @@ function _init() {
|
||||||
if ($("body").hasClass('layout-boxed')) {
|
if ($("body").hasClass('layout-boxed')) {
|
||||||
sidebar.css('position', 'absolute');
|
sidebar.css('position', 'absolute');
|
||||||
sidebar.height($(".wrapper").height());
|
sidebar.height($(".wrapper").height());
|
||||||
|
if (_this.hasBindedResize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$(window).resize(function () {
|
$(window).resize(function () {
|
||||||
_this._fix(sidebar);
|
_this._fix(sidebar);
|
||||||
});
|
});
|
||||||
|
_this.hasBindedResize = true;
|
||||||
} else {
|
} else {
|
||||||
sidebar.css({
|
sidebar.css({
|
||||||
'position': 'fixed',
|
'position': 'fixed',
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue