mirror of https://github.com/ColorlibHQ/AdminLTE
Merge pull request #3639 from Shidersz/fix_fullscreen_mode
commit
1f9e35f5db
|
@ -19,6 +19,8 @@ const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||||
const SELECTOR_DATA_WIDGET = '[data-widget="fullscreen"]'
|
const SELECTOR_DATA_WIDGET = '[data-widget="fullscreen"]'
|
||||||
const SELECTOR_ICON = `${SELECTOR_DATA_WIDGET} i`
|
const SELECTOR_ICON = `${SELECTOR_DATA_WIDGET} i`
|
||||||
|
|
||||||
|
const EVENT_FULLSCREEN_CHANGE = 'webkitfullscreenchange mozfullscreenchange fullscreenchange MSFullscreenChange'
|
||||||
|
|
||||||
const Default = {
|
const Default = {
|
||||||
minimizeIcon: 'fa-compress-arrows-alt',
|
minimizeIcon: 'fa-compress-arrows-alt',
|
||||||
maximizeIcon: 'fa-expand-arrows-alt'
|
maximizeIcon: 'fa-expand-arrows-alt'
|
||||||
|
@ -48,6 +50,17 @@ class Fullscreen {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleIcon() {
|
||||||
|
if (document.fullscreenElement ||
|
||||||
|
document.mozFullScreenElement ||
|
||||||
|
document.webkitFullscreenElement ||
|
||||||
|
document.msFullscreenElement) {
|
||||||
|
$(SELECTOR_ICON).removeClass(this.options.maximizeIcon).addClass(this.options.minimizeIcon)
|
||||||
|
} else {
|
||||||
|
$(SELECTOR_ICON).removeClass(this.options.minimizeIcon).addClass(this.options.maximizeIcon)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fullscreen() {
|
fullscreen() {
|
||||||
if (document.documentElement.requestFullscreen) {
|
if (document.documentElement.requestFullscreen) {
|
||||||
document.documentElement.requestFullscreen()
|
document.documentElement.requestFullscreen()
|
||||||
|
@ -56,8 +69,6 @@ class Fullscreen {
|
||||||
} else if (document.documentElement.msRequestFullscreen) {
|
} else if (document.documentElement.msRequestFullscreen) {
|
||||||
document.documentElement.msRequestFullscreen()
|
document.documentElement.msRequestFullscreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
$(SELECTOR_ICON).removeClass(this.options.maximizeIcon).addClass(this.options.minimizeIcon)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
windowed() {
|
windowed() {
|
||||||
|
@ -68,8 +79,6 @@ class Fullscreen {
|
||||||
} else if (document.msExitFullscreen) {
|
} else if (document.msExitFullscreen) {
|
||||||
document.msExitFullscreen()
|
document.msExitFullscreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
$(SELECTOR_ICON).removeClass(this.options.minimizeIcon).addClass(this.options.maximizeIcon)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
@ -86,7 +95,7 @@ class Fullscreen {
|
||||||
|
|
||||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
||||||
|
|
||||||
if (typeof config === 'string' && /toggle|fullscreen|windowed/.test(config)) {
|
if (typeof config === 'string' && /toggle|toggleIcon|fullscreen|windowed/.test(config)) {
|
||||||
plugin[config]()
|
plugin[config]()
|
||||||
} else {
|
} else {
|
||||||
plugin.init()
|
plugin.init()
|
||||||
|
@ -102,6 +111,10 @@ $(document).on('click', SELECTOR_DATA_WIDGET, function () {
|
||||||
Fullscreen._jQueryInterface.call($(this), 'toggle')
|
Fullscreen._jQueryInterface.call($(this), 'toggle')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
$(document).on(EVENT_FULLSCREEN_CHANGE, () => {
|
||||||
|
Fullscreen._jQueryInterface.call($(SELECTOR_DATA_WIDGET), 'toggleIcon')
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* jQuery API
|
* jQuery API
|
||||||
* ====================================================
|
* ====================================================
|
||||||
|
|
Loading…
Reference in New Issue