mirror of https://github.com/ColorlibHQ/AdminLTE
feat(control-sidebar): add ability to toggle between multiple control-sidebars
- instead of collapse and show (2 clicks)pull/4058/head
parent
adc28b9dae
commit
a936e220f6
|
@ -66,7 +66,6 @@ class ControlSidebar {
|
||||||
collapse() {
|
collapse() {
|
||||||
const $body = $('body')
|
const $body = $('body')
|
||||||
const $html = $('html')
|
const $html = $('html')
|
||||||
const { target } = this._config
|
|
||||||
|
|
||||||
// Show the control sidebar
|
// Show the control sidebar
|
||||||
if (this._config.controlsidebarSlide) {
|
if (this._config.controlsidebarSlide) {
|
||||||
|
@ -87,10 +86,14 @@ class ControlSidebar {
|
||||||
}, this._config.animationSpeed)
|
}, this._config.animationSpeed)
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {
|
show(toggle = false) {
|
||||||
const $body = $('body')
|
const $body = $('body')
|
||||||
const $html = $('html')
|
const $html = $('html')
|
||||||
|
|
||||||
|
if (toggle) {
|
||||||
|
$(SELECTOR_CONTROL_SIDEBAR).hide()
|
||||||
|
}
|
||||||
|
|
||||||
// Collapse the control sidebar
|
// Collapse the control sidebar
|
||||||
if (this._config.controlsidebarSlide) {
|
if (this._config.controlsidebarSlide) {
|
||||||
$html.addClass(CLASS_NAME_CONTROL_SIDEBAR_ANIMATE)
|
$html.addClass(CLASS_NAME_CONTROL_SIDEBAR_ANIMATE)
|
||||||
|
@ -113,15 +116,20 @@ class ControlSidebar {
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
const $body = $('body')
|
const $body = $('body')
|
||||||
const shouldClose = $body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_OPEN) ||
|
const { target } = this._config
|
||||||
$body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_SLIDE)
|
|
||||||
|
|
||||||
if (shouldClose) {
|
const notVisible = !$(target).is(':visible')
|
||||||
|
const shouldClose = ($body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_OPEN) ||
|
||||||
|
$body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_SLIDE))
|
||||||
|
const shouldToggle = notVisible && ($body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_OPEN) ||
|
||||||
|
$body.hasClass(CLASS_NAME_CONTROL_SIDEBAR_SLIDE))
|
||||||
|
|
||||||
|
if (notVisible || shouldToggle) {
|
||||||
|
// Open the control sidebar
|
||||||
|
this.show(notVisible)
|
||||||
|
} else if (shouldClose) {
|
||||||
// Close the control sidebar
|
// Close the control sidebar
|
||||||
this.collapse()
|
this.collapse()
|
||||||
} else {
|
|
||||||
// Open the control sidebar
|
|
||||||
this.show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue