enhanced Layout.js with options for login auto height with interval ability

This commit is contained in:
REJack
2020-02-25 14:25:05 +01:00
parent 533a5917f5
commit b7efadbbca
6 changed files with 51 additions and 21 deletions

View File

@@ -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]()
}
})
}