mirror of https://github.com/ColorlibHQ/AdminLTE
enhanced Layout.js with options for login auto height with interval ability
parent
533a5917f5
commit
b7efadbbca
|
@ -54,7 +54,8 @@ const Layout = (($) => {
|
|||
|
||||
const Default = {
|
||||
scrollbarTheme : 'os-theme-light',
|
||||
scrollbarAutoHide: 'l'
|
||||
scrollbarAutoHide: 'l',
|
||||
loginRegisterAutoHeight: true,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,11 +114,30 @@ const Layout = (($) => {
|
|||
}
|
||||
}
|
||||
|
||||
fixLoginRegisterHeight() {
|
||||
if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
|
||||
$('body, html').css('height', 'auto')
|
||||
} else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
|
||||
let box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height()
|
||||
|
||||
if ($('body').css('min-height') !== box_height) {
|
||||
$('body').css('min-height', box_height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Private
|
||||
|
||||
_init() {
|
||||
// Activate layout height watcher
|
||||
this.fixLayoutHeight()
|
||||
|
||||
if (this._config.loginRegisterAutoHeight === true) {
|
||||
this.fixLoginRegisterHeight()
|
||||
} else if (Number.isInteger(this._config.loginRegisterAutoHeight)) {
|
||||
setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight);
|
||||
}
|
||||
|
||||
$(Selector.SIDEBAR)
|
||||
.on('collapsed.lte.treeview expanded.lte.treeview', () => {
|
||||
this.fixLayoutHeight()
|
||||
|
@ -140,14 +160,6 @@ const Layout = (($) => {
|
|||
this.fixLayoutHeight()
|
||||
})
|
||||
|
||||
if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
|
||||
$('body, html').css('height', 'auto')
|
||||
} else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
|
||||
let box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height()
|
||||
|
||||
$('body').css('min-height', box_height);
|
||||
}
|
||||
|
||||
$('body.hold-transition').removeClass('hold-transition')
|
||||
}
|
||||
|
||||
|
@ -178,6 +190,8 @@ const Layout = (($) => {
|
|||
|
||||
if (config === 'init' || config === '') {
|
||||
data['_init']()
|
||||
} else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') {
|
||||
data[config]()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -326,7 +326,8 @@
|
|||
};
|
||||
var Default = {
|
||||
scrollbarTheme: 'os-theme-light',
|
||||
scrollbarAutoHide: 'l'
|
||||
scrollbarAutoHide: 'l',
|
||||
loginRegisterAutoHeight: true
|
||||
};
|
||||
/**
|
||||
* Class Definition
|
||||
|
@ -389,6 +390,18 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
_proto.fixLoginRegisterHeight = function fixLoginRegisterHeight() {
|
||||
if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
|
||||
$('body, html').css('height', 'auto');
|
||||
} else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
|
||||
var box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height();
|
||||
|
||||
if ($('body').css('min-height') !== box_height) {
|
||||
$('body').css('min-height', box_height);
|
||||
}
|
||||
}
|
||||
} // Private
|
||||
;
|
||||
|
||||
|
@ -397,6 +410,13 @@
|
|||
|
||||
// Activate layout height watcher
|
||||
this.fixLayoutHeight();
|
||||
|
||||
if (this._config.loginRegisterAutoHeight === true) {
|
||||
this.fixLoginRegisterHeight();
|
||||
} else if (Number.isInteger(this._config.loginRegisterAutoHeight)) {
|
||||
setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight);
|
||||
}
|
||||
|
||||
$(Selector.SIDEBAR).on('collapsed.lte.treeview expanded.lte.treeview', function () {
|
||||
_this.fixLayoutHeight();
|
||||
});
|
||||
|
@ -411,14 +431,6 @@
|
|||
$(window).resize(function () {
|
||||
_this.fixLayoutHeight();
|
||||
});
|
||||
|
||||
if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) {
|
||||
$('body, html').css('height', 'auto');
|
||||
} else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) {
|
||||
var box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height();
|
||||
$('body').css('min-height', box_height);
|
||||
}
|
||||
|
||||
$('body.hold-transition').removeClass('hold-transition');
|
||||
};
|
||||
|
||||
|
@ -451,6 +463,8 @@
|
|||
|
||||
if (config === 'init' || config === '') {
|
||||
data['_init']();
|
||||
} else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') {
|
||||
data[config]();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,6 +16,7 @@ This plugin is activated automatically upon window load.
|
|||
|-|-|-|-
|
||||
|scrollbarTheme | Boolean | `os-theme-light` | Scrollbar Theme used while SideBar Fixed
|
||||
|scrollbarAutoHide | Boolean | `l` | Scrollbar auto-hide trigger
|
||||
|loginRegisterAutoHeight | Boolean|Integer | true | Login & Register Height Correction
|
||||
|---
|
||||
{: .table .table-bordered .bg-light}
|
||||
|
||||
|
@ -33,6 +34,7 @@ This plugin is activated automatically upon window load.
|
|||
| Method | Description
|
||||
|-|-
|
||||
|fixLayoutHeight | Fix the content / control sidebar height and activates OverlayScrollbars for sidebar / control sidebar
|
||||
|fixLoginRegisterHeight | Fix the login & register body height
|
||||
{: .table .table-bordered .bg-light}
|
||||
|
||||
Example: `$('body').Layout('fixLayoutHeight')`
|
||||
|
|
Loading…
Reference in New Issue