mirror of https://github.com/ColorlibHQ/AdminLTE
Return early.
parent
3528b6c1f8
commit
187a01a8ee
|
@ -134,6 +134,10 @@ const ControlSidebar = ($ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
_fixScrollHeight() {
|
_fixScrollHeight() {
|
||||||
|
if (!$('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const heights = {
|
const heights = {
|
||||||
scroll: $(document).height(),
|
scroll: $(document).height(),
|
||||||
window: $(window).height(),
|
window: $(window).height(),
|
||||||
|
@ -148,92 +152,92 @@ const ControlSidebar = ($ => {
|
||||||
let navbarFixed = false
|
let navbarFixed = false
|
||||||
let footerFixed = false
|
let footerFixed = false
|
||||||
|
|
||||||
if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
if (
|
||||||
if (
|
$('body').hasClass(ClassName.NAVBAR_FIXED) ||
|
||||||
$('body').hasClass(ClassName.NAVBAR_FIXED) ||
|
$('body').hasClass(ClassName.NAVBAR_SM_FIXED) ||
|
||||||
$('body').hasClass(ClassName.NAVBAR_SM_FIXED) ||
|
$('body').hasClass(ClassName.NAVBAR_MD_FIXED) ||
|
||||||
$('body').hasClass(ClassName.NAVBAR_MD_FIXED) ||
|
$('body').hasClass(ClassName.NAVBAR_LG_FIXED) ||
|
||||||
$('body').hasClass(ClassName.NAVBAR_LG_FIXED) ||
|
$('body').hasClass(ClassName.NAVBAR_XL_FIXED)
|
||||||
$('body').hasClass(ClassName.NAVBAR_XL_FIXED)
|
) {
|
||||||
) {
|
if ($(Selector.HEADER).css('position') === 'fixed') {
|
||||||
if ($(Selector.HEADER).css('position') === 'fixed') {
|
navbarFixed = true
|
||||||
navbarFixed = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$('body').hasClass(ClassName.FOOTER_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_SM_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_SM_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_MD_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_MD_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_LG_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_LG_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_XL_FIXED)
|
$('body').hasClass(ClassName.FOOTER_XL_FIXED)
|
||||||
) {
|
) {
|
||||||
if ($(Selector.FOOTER).css('position') === 'fixed') {
|
if ($(Selector.FOOTER).css('position') === 'fixed') {
|
||||||
footerFixed = true
|
footerFixed = true
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (positions.top === 0 && positions.bottom === 0) {
|
if (positions.top === 0 && positions.bottom === 0) {
|
||||||
|
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer)
|
||||||
|
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
||||||
|
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header + heights.footer))
|
||||||
|
} else if (positions.bottom <= heights.footer) {
|
||||||
|
if (footerFixed === false) {
|
||||||
|
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer - positions.bottom)
|
||||||
|
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.footer - positions.bottom))
|
||||||
|
} else {
|
||||||
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer)
|
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer)
|
||||||
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
}
|
||||||
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header + heights.footer))
|
} else if (positions.top <= heights.header) {
|
||||||
} else if (positions.bottom <= heights.footer) {
|
if (navbarFixed === false) {
|
||||||
if (footerFixed === false) {
|
$(Selector.CONTROL_SIDEBAR).css('top', heights.header - positions.top)
|
||||||
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer - positions.bottom)
|
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header - positions.top))
|
||||||
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.footer - positions.bottom))
|
|
||||||
} else {
|
|
||||||
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer)
|
|
||||||
}
|
|
||||||
} else if (positions.top <= heights.header) {
|
|
||||||
if (navbarFixed === false) {
|
|
||||||
$(Selector.CONTROL_SIDEBAR).css('top', heights.header - positions.top)
|
|
||||||
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header - positions.top))
|
|
||||||
} else {
|
|
||||||
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
|
||||||
}
|
|
||||||
} else if (navbarFixed === false) {
|
|
||||||
$(Selector.CONTROL_SIDEBAR).css('top', 0)
|
|
||||||
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window)
|
|
||||||
} else {
|
} else {
|
||||||
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
||||||
}
|
}
|
||||||
|
} else if (navbarFixed === false) {
|
||||||
|
$(Selector.CONTROL_SIDEBAR).css('top', 0)
|
||||||
|
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window)
|
||||||
|
} else {
|
||||||
|
$(Selector.CONTROL_SIDEBAR).css('top', heights.header)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_fixHeight() {
|
_fixHeight() {
|
||||||
|
if (!$('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const heights = {
|
const heights = {
|
||||||
window: $(window).height(),
|
window: $(window).height(),
|
||||||
header: $(Selector.HEADER).outerHeight(),
|
header: $(Selector.HEADER).outerHeight(),
|
||||||
footer: $(Selector.FOOTER).outerHeight()
|
footer: $(Selector.FOOTER).outerHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
let sidebarHeight = heights.window - heights.header
|
||||||
let sidebarHeight = heights.window - heights.header
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$('body').hasClass(ClassName.FOOTER_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_SM_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_SM_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_MD_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_MD_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_LG_FIXED) ||
|
$('body').hasClass(ClassName.FOOTER_LG_FIXED) ||
|
||||||
$('body').hasClass(ClassName.FOOTER_XL_FIXED)
|
$('body').hasClass(ClassName.FOOTER_XL_FIXED)
|
||||||
) {
|
) {
|
||||||
if ($(Selector.FOOTER).css('position') === 'fixed') {
|
if ($(Selector.FOOTER).css('position') === 'fixed') {
|
||||||
sidebarHeight = heights.window - heights.header - heights.footer
|
sidebarHeight = heights.window - heights.header - heights.footer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', sidebarHeight)
|
||||||
|
|
||||||
|
if (typeof $.fn.overlayScrollbars !== 'undefined') {
|
||||||
|
$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).overlayScrollbars({
|
||||||
|
className: this._config.scrollbarTheme,
|
||||||
|
sizeAutoCapable: true,
|
||||||
|
scrollbars: {
|
||||||
|
autoHide: this._config.scrollbarAutoHide,
|
||||||
|
clickScrolling: true
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', sidebarHeight)
|
|
||||||
|
|
||||||
if (typeof $.fn.overlayScrollbars !== 'undefined') {
|
|
||||||
$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).overlayScrollbars({
|
|
||||||
className: this._config.scrollbarTheme,
|
|
||||||
sizeAutoCapable: true,
|
|
||||||
scrollbars: {
|
|
||||||
autoHide: this._config.scrollbarAutoHide,
|
|
||||||
clickScrolling: true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,21 +93,23 @@ const Layout = ($ => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
if (!$('body').hasClass(ClassName.LAYOUT_FIXED)) {
|
||||||
if (offset !== false) {
|
return
|
||||||
$(Selector.CONTENT).css('min-height', (max + offset) - heights.header - heights.footer)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof $.fn.overlayScrollbars !== 'undefined') {
|
if (offset !== false) {
|
||||||
$(Selector.SIDEBAR).overlayScrollbars({
|
$(Selector.CONTENT).css('min-height', (max + offset) - heights.header - heights.footer)
|
||||||
className: this._config.scrollbarTheme,
|
}
|
||||||
sizeAutoCapable: true,
|
|
||||||
scrollbars: {
|
if (typeof $.fn.overlayScrollbars !== 'undefined') {
|
||||||
autoHide: this._config.scrollbarAutoHide,
|
$(Selector.SIDEBAR).overlayScrollbars({
|
||||||
clickScrolling: true
|
className: this._config.scrollbarTheme,
|
||||||
}
|
sizeAutoCapable: true,
|
||||||
})
|
scrollbars: {
|
||||||
}
|
autoHide: this._config.scrollbarAutoHide,
|
||||||
|
clickScrolling: true
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,41 +102,45 @@ const PushMenu = ($ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
autoCollapse(resize = false) {
|
autoCollapse(resize = false) {
|
||||||
if (this._options.autoCollapseSize) {
|
if (!this._options.autoCollapseSize) {
|
||||||
if ($(window).width() <= this._options.autoCollapseSize) {
|
return
|
||||||
if (!$(Selector.BODY).hasClass(ClassName.OPEN)) {
|
}
|
||||||
this.collapse()
|
|
||||||
}
|
if ($(window).width() <= this._options.autoCollapseSize) {
|
||||||
} else if (resize === true) {
|
if (!$(Selector.BODY).hasClass(ClassName.OPEN)) {
|
||||||
if ($(Selector.BODY).hasClass(ClassName.OPEN)) {
|
this.collapse()
|
||||||
$(Selector.BODY).removeClass(ClassName.OPEN)
|
}
|
||||||
} else if ($(Selector.BODY).hasClass(ClassName.CLOSED)) {
|
} else if (resize === true) {
|
||||||
this.expand()
|
if ($(Selector.BODY).hasClass(ClassName.OPEN)) {
|
||||||
}
|
$(Selector.BODY).removeClass(ClassName.OPEN)
|
||||||
|
} else if ($(Selector.BODY).hasClass(ClassName.CLOSED)) {
|
||||||
|
this.expand()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remember() {
|
remember() {
|
||||||
if (this._options.enableRemember) {
|
if (!this._options.enableRemember) {
|
||||||
const toggleState = localStorage.getItem(`remember${EVENT_KEY}`)
|
return
|
||||||
if (toggleState === ClassName.COLLAPSED) {
|
}
|
||||||
if (this._options.noTransitionAfterReload) {
|
|
||||||
$('body').addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function () {
|
const toggleState = localStorage.getItem(`remember${EVENT_KEY}`)
|
||||||
$(this).removeClass('hold-transition')
|
if (toggleState === ClassName.COLLAPSED) {
|
||||||
$(this).dequeue()
|
if (this._options.noTransitionAfterReload) {
|
||||||
})
|
$('body').addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function () {
|
||||||
} else {
|
|
||||||
$('body').addClass(ClassName.COLLAPSED)
|
|
||||||
}
|
|
||||||
} else if (this._options.noTransitionAfterReload) {
|
|
||||||
$('body').addClass('hold-transition').removeClass(ClassName.COLLAPSED).delay(50).queue(function () {
|
|
||||||
$(this).removeClass('hold-transition')
|
$(this).removeClass('hold-transition')
|
||||||
$(this).dequeue()
|
$(this).dequeue()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
$('body').removeClass(ClassName.COLLAPSED)
|
$('body').addClass(ClassName.COLLAPSED)
|
||||||
}
|
}
|
||||||
|
} else if (this._options.noTransitionAfterReload) {
|
||||||
|
$('body').addClass('hold-transition').removeClass(ClassName.COLLAPSED).delay(50).queue(function () {
|
||||||
|
$(this).removeClass('hold-transition')
|
||||||
|
$(this).dequeue()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
$('body').removeClass(ClassName.COLLAPSED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue