mirror of https://github.com/ColorlibHQ/AdminLTE
add allowReload option for IFrame plugin
parent
86fe0f2704
commit
4a2c52d962
|
@ -53,6 +53,7 @@ const Default = {
|
||||||
autoShowNewTab: true,
|
autoShowNewTab: true,
|
||||||
autoDarkMode: false,
|
autoDarkMode: false,
|
||||||
allowDuplicates: false,
|
allowDuplicates: false,
|
||||||
|
allowReload: true,
|
||||||
loadingScreen: true,
|
loadingScreen: true,
|
||||||
useNavbarItems: true,
|
useNavbarItems: true,
|
||||||
scrollOffset: 40,
|
scrollOffset: 40,
|
||||||
|
@ -146,7 +147,7 @@ class IFrame {
|
||||||
const navId = `tab-${uniqueName}`
|
const navId = `tab-${uniqueName}`
|
||||||
|
|
||||||
if (!this._config.allowDuplicates && $(`#${navId}`).length > 0) {
|
if (!this._config.allowDuplicates && $(`#${navId}`).length > 0) {
|
||||||
return this.switchTab(`#${navId}`)
|
return this.switchTab(`#${navId}`, this._config.allowReload)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!this._config.allowDuplicates && $(`#${navId}`).length === 0) || this._config.allowDuplicates) {
|
if ((!this._config.allowDuplicates && $(`#${navId}`).length === 0) || this._config.allowDuplicates) {
|
||||||
|
@ -154,12 +155,35 @@ class IFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switchTab(item) {
|
switchTab(item, reload = false) {
|
||||||
const $item = $(item)
|
const $item = $(item)
|
||||||
const tabId = $item.attr('href')
|
const tabId = $item.attr('href')
|
||||||
|
|
||||||
$(SELECTOR_TAB_EMPTY).hide()
|
$(SELECTOR_TAB_EMPTY).hide()
|
||||||
|
|
||||||
|
if (reload) {
|
||||||
|
const $loadingScreen = $(SELECTOR_TAB_LOADING)
|
||||||
|
if (this._config.loadingScreen) {
|
||||||
|
$loadingScreen.show(0, () => {
|
||||||
|
$(`${tabId} iframe`).attr('src', $(`${tabId} iframe`).attr('src')).ready(() => {
|
||||||
|
if (this._config.loadingScreen) {
|
||||||
|
if (typeof this._config.loadingScreen === 'number') {
|
||||||
|
setTimeout(() => {
|
||||||
|
$loadingScreen.fadeOut()
|
||||||
|
}, this._config.loadingScreen)
|
||||||
|
} else {
|
||||||
|
$loadingScreen.fadeOut()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
$(`${tabId} iframe`).attr('src', $(`${tabId} iframe`).attr('src'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$(`${SELECTOR_TAB_NAVBAR_NAV} .active`).tab('dispose').removeClass('active')
|
$(`${SELECTOR_TAB_NAVBAR_NAV} .active`).tab('dispose').removeClass('active')
|
||||||
|
|
||||||
this._fixHeight()
|
this._fixHeight()
|
||||||
|
|
||||||
$item.tab('show')
|
$item.tab('show')
|
||||||
|
|
Loading…
Reference in New Issue