{"version":3,"file":"lg-fullscreen.umd.js","sources":["../../../src/plugins/fullscreen/lg-fullscreen-settings.ts","../../../src/plugins/fullscreen/lg-fullscreen.ts"],"sourcesContent":["export interface FullscreenStrings {\n    toggleFullscreen: string;\n}\nexport interface FullscreenSettings {\n    /**\n     * Enable/Disable fullscreen option\n     */\n    fullScreen: boolean;\n\n    /**\n     * Custom translation strings for aria-labels\n     */\n    fullscreenPluginStrings: FullscreenStrings;\n}\n\nexport const fullscreenSettings: FullscreenSettings = {\n    fullScreen: true,\n    fullscreenPluginStrings: {\n        toggleFullscreen: 'Toggle Fullscreen',\n    } as FullscreenStrings,\n};\n","import { LgQuery } from '../../lgQuery';\nimport { LightGallery } from '../../lightgallery';\nimport {\n    FullscreenSettings,\n    fullscreenSettings,\n} from './lg-fullscreen-settings';\n\ndeclare let document: any;\n\nexport default class FullScreen {\n    core: LightGallery;\n    settings: FullscreenSettings;\n    private $LG!: LgQuery;\n    constructor(instance: LightGallery, $LG: LgQuery) {\n        // get lightGallery core plugin instance\n        this.core = instance;\n        this.$LG = $LG;\n\n        // extend module default settings with lightGallery core settings\n        this.settings = { ...fullscreenSettings, ...this.core.settings };\n\n        return this;\n    }\n\n    public init(): void {\n        let fullScreen = '';\n        if (this.settings.fullScreen) {\n            // check for fullscreen browser support\n            if (\n                !document.fullscreenEnabled &&\n                !document.webkitFullscreenEnabled &&\n                !document.mozFullScreenEnabled &&\n                !document.msFullscreenEnabled\n            ) {\n                return;\n            } else {\n                fullScreen = `<button type=\"button\" aria-label=\"${this.settings.fullscreenPluginStrings['toggleFullscreen']}\" class=\"lg-fullscreen lg-icon\"></button>`;\n                this.core.$toolbar.append(fullScreen);\n                this.fullScreen();\n            }\n        }\n    }\n\n    private isFullScreen(): boolean {\n        return (\n            document.fullscreenElement ||\n            document.mozFullScreenElement ||\n            document.webkitFullscreenElement ||\n            document.msFullscreenElement\n        );\n    }\n\n    private requestFullscreen(): void {\n        const el = document.documentElement;\n        if (el.requestFullscreen) {\n            el.requestFullscreen();\n        } else if (el.msRequestFullscreen) {\n            el.msRequestFullscreen();\n        } else if (el.mozRequestFullScreen) {\n            el.mozRequestFullScreen();\n        } else if (el.webkitRequestFullscreen) {\n            el.webkitRequestFullscreen();\n        }\n    }\n\n    private exitFullscreen(): void {\n        if (document.exitFullscreen) {\n            document.exitFullscreen();\n        } else if (document.msExitFullscreen) {\n            document.msExitFullscreen();\n        } else if (document.mozCancelFullScreen) {\n            document.mozCancelFullScreen();\n        } else if (document.webkitExitFullscreen) {\n            document.webkitExitFullscreen();\n        }\n    }\n\n    // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode\n    private fullScreen(): void {\n        this.$LG(document).on(\n            `fullscreenchange.lg.global${this.core.lgId} \n            webkitfullscreenchange.lg.global${this.core.lgId} \n            mozfullscreenchange.lg.global${this.core.lgId} \n            MSFullscreenChange.lg.global${this.core.lgId}`,\n            () => {\n                if (!this.core.lgOpened) return;\n                this.core.outer.toggleClass('lg-fullscreen-on');\n            },\n        );\n\n        this.core.outer\n            .find('.lg-fullscreen')\n            .first()\n            .on('click.lg', () => {\n                if (this.isFullScreen()) {\n                    this.exitFullscreen();\n                } else {\n                    this.requestFullscreen();\n                }\n            });\n    }\n\n    closeGallery(): void {\n        // exit from fullscreen if activated\n        if (this.isFullScreen()) {\n            this.exitFullscreen();\n        }\n    }\n\n    destroy(): void {\n        this.$LG(document).off(\n            `fullscreenchange.lg.global${this.core.lgId} \n            webkitfullscreenchange.lg.global${this.core.lgId} \n            mozfullscreenchange.lg.global${this.core.lgId} \n            MSFullscreenChange.lg.global${this.core.lgId}`,\n        );\n    }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAeO,IAAM,kBAAkB,GAAuB;QAClD,UAAU,EAAE,IAAI;QAChB,uBAAuB,EAAE;YACrB,gBAAgB,EAAE,mBAAmB;SACnB;KACzB;;;QCPG,oBAAY,QAAsB,EAAE,GAAY;;Y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