Return early.

This commit is contained in:
XhmikosR
2020-05-31 16:45:54 +03:00
parent 3528b6c1f8
commit 187a01a8ee
3 changed files with 111 additions and 101 deletions

View File

@@ -102,41 +102,45 @@ const PushMenu = ($ => {
}
autoCollapse(resize = false) {
if (this._options.autoCollapseSize) {
if ($(window).width() <= this._options.autoCollapseSize) {
if (!$(Selector.BODY).hasClass(ClassName.OPEN)) {
this.collapse()
}
} else if (resize === true) {
if ($(Selector.BODY).hasClass(ClassName.OPEN)) {
$(Selector.BODY).removeClass(ClassName.OPEN)
} else if ($(Selector.BODY).hasClass(ClassName.CLOSED)) {
this.expand()
}
if (!this._options.autoCollapseSize) {
return
}
if ($(window).width() <= this._options.autoCollapseSize) {
if (!$(Selector.BODY).hasClass(ClassName.OPEN)) {
this.collapse()
}
} else if (resize === true) {
if ($(Selector.BODY).hasClass(ClassName.OPEN)) {
$(Selector.BODY).removeClass(ClassName.OPEN)
} else if ($(Selector.BODY).hasClass(ClassName.CLOSED)) {
this.expand()
}
}
}
remember() {
if (this._options.enableRemember) {
const toggleState = localStorage.getItem(`remember${EVENT_KEY}`)
if (toggleState === ClassName.COLLAPSED) {
if (this._options.noTransitionAfterReload) {
$('body').addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function () {
$(this).removeClass('hold-transition')
$(this).dequeue()
})
} else {
$('body').addClass(ClassName.COLLAPSED)
}
} else if (this._options.noTransitionAfterReload) {
$('body').addClass('hold-transition').removeClass(ClassName.COLLAPSED).delay(50).queue(function () {
if (!this._options.enableRemember) {
return
}
const toggleState = localStorage.getItem(`remember${EVENT_KEY}`)
if (toggleState === ClassName.COLLAPSED) {
if (this._options.noTransitionAfterReload) {
$('body').addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function () {
$(this).removeClass('hold-transition')
$(this).dequeue()
})
} 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)
}
}