{"version":3,"file":"fullscreen.min.js","sources":["https:\/\/moodle.sonsbeekmedia.nl\/caie_39\/mod\/teachingtools\/amd\/src\/fullscreen.js"],"sourcesContent":["\/\/ This file is part of Moodle - http:\/\/moodle.org\/\n\/\/\n\/\/ Moodle is free software: you can redistribute it and\/or modify\n\/\/ it under the terms of the GNU General Public License as published by\n\/\/ the Free Software Foundation, either version 3 of the License, or\n\/\/ (at your option) any later version.\n\/\/\n\/\/ Moodle is distributed in the hope that it will be useful,\n\/\/ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\/\/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\/\/ GNU General Public License for more details.\n\/\/\n\/\/ You should have received a copy of the GNU General Public License\n\/\/ along with Moodle. If not, see .\n\n\/**\n * Fullscreen option for the teaching tools.\n *\n * @module mod_teachingtools\/fullscreen\n * @copyright 2023 Sonsbeekmedia\n * @author Bas Brands \n * @license http:\/\/www.gnu.org\/copyleft\/gpl.html GNU GPL v3 or later\n *\/\n\nimport $ from 'jquery';\nimport {get_string as getString} from 'core\/str';\n\nconst fullScreenToggler = (fullscreenButton) => {\n const cmid = fullscreenButton.dataset.cmid;\n document.dispatchEvent(new CustomEvent('AppFullscreenChangeStart', {\n detail: {\n cmid: cmid,\n },\n }));\n const goFullscreen = fullscreenButton.querySelector('.go-fullscreen');\n const exitFullscreen = fullscreenButton.querySelector('.exit-fullscreen');\n const app = document.querySelector('[data-type=\"app\"][data-cmid=\"' + cmid + '\"]');\n const docEl = document.documentElement;\n if (document.fullscreenElement || document.webkitFullscreenElement) {\n const exitFullScreen = document.exitFullscreen || document.mozCancelFullScreen || document.webkitExitFullscreen ||\n document.msExitFullscreen;\n app.classList.remove('fullscreen-app');\n exitFullScreen.call(document);\n goFullscreen.classList.remove('d-none');\n exitFullscreen.classList.add('d-none');\n document.body.classList.remove('fullscreen');\n } else {\n const requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullscreen ||\n docEl.msRequestFullscreen;\n requestFullScreen.call(docEl);\n app.classList.add('fullscreen-app');\n goFullscreen.classList.add('d-none');\n exitFullscreen.classList.remove('d-none');\n document.body.classList.add('fullscreen');\n }\n \/\/ Fire the AppFullscreen change event.\n setTimeout(() => {\n document.dispatchEvent(new CustomEvent('AppFullscreenChange', {\n detail: {\n cmid: cmid,\n },\n }));\n }, 500);\n};\n\n\/**\n * Show the teaching tool full screen.\n *\n *\n *\/\nconst init = async() => {\n const toolWrapper = document.querySelector('[data-region=\"toolwrapper\"]');\n if (!toolWrapper) {\n return;\n }\n if (toolWrapper.dataset.fullscreenInitialised) {\n return;\n }\n const fullScreen = await getString('fullscreen', 'teachingtools');\n const exitFullScreen = await getString('exitfullscreen', 'teachingtools');\n\n const fullScreenButton = toolWrapper.querySelector('[data-action=\"fullscreen\"]');\n fullScreenButton.addEventListener('click', (e) => {\n if (e.target.closest('[data-action=\"fullscreen\"]')) {\n fullScreenToggler(e.target.closest('[data-action=\"fullscreen\"]'));\n }\n });\n\n fullScreenButton.addEventListener('focus', () => {\n if (document.fullscreenElement || document.webkitFullscreenElement) {\n $(fullScreenButton).tooltip({\n title: exitFullScreen,\n placement: 'bottom',\n });\n return;\n } else {\n $(fullScreenButton).tooltip({\n title: fullScreen,\n placement: 'bottom',\n });\n }\n $(fullScreenButton).tooltip('show');\n });\n\n fullScreenButton.addEventListener('blur', () => {\n $(fullScreenButton).tooltip('hide');\n });\n\n \/\/ Trigger a appFullscreenChange event when the drawer toggle is clicked.\n const drawerToggle = document.querySelector('[data-action=\"toggle\"][data-target=\"theme_boost-drawers-courseindex\"]');\n const closeDrawer = document.querySelector('[data-action=\"closedrawer\"][data-target=\"theme_boost-drawers-courseindex\"]');\n if (drawerToggle) {\n if (drawerToggle.dataset.fullscreenInitialised) {\n return;\n }\n drawerToggle.addEventListener('click', () => {\n setTimeout(() => {\n document.dispatchEvent(new CustomEvent('AppFullscreenChange', {\n detail: {\n cmid: fullScreenButton.dataset.cmid,\n },\n }));\n }, 1000);\n });\n drawerToggle.dataset.fullscreenInitialised = true;\n }\n if (closeDrawer) {\n if (closeDrawer.dataset.fullscreenInitialised) {\n return;\n }\n closeDrawer.addEventListener('click', () => {\n setTimeout(() => {\n document.dispatchEvent(new CustomEvent('AppFullscreenChange', {\n detail: {\n cmid: fullScreenButton.dataset.cmid,\n },\n }));\n }, 1000);\n });\n closeDrawer.dataset.fullscreenInitialised = true;\n }\n\n document.addEventListener('fullscreenchange', () => {\n const goFullscreen = document.querySelector('.go-fullscreen');\n const exitFullscreen = document.querySelector('.exit-fullscreen');\n const app = document.querySelectorAll('[data-type=\"app\"]');\n if (!document.fullscreenElement) {\n app.classList.remove('fullscreen-app');\n goFullscreen.classList.remove('d-none');\n exitFullscreen.classList.add('d-none');\n }\n });\n};\n\nexport default {\n init: init\n};\n"],"names":["init","async","toolWrapper","document","querySelector","dataset","fullscreenInitialised","fullScreen","exitFullScreen","fullScreenButton","addEventListener","e","target","closest","fullscreenButton","cmid","dispatchEvent","CustomEvent","detail","goFullscreen","exitFullscreen","app","docEl","documentElement","fullscreenElement","webkitFullscreenElement","mozCancelFullScreen","webkitExitFullscreen","msExitFullscreen","classList","remove","call","add","body","requestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","msRequestFullscreen","setTimeout","fullScreenToggler","tooltip","title","placement","drawerToggle","closeDrawer","querySelectorAll"],"mappings":";;;;;;;;0JA0Je,CACXA,KArFSC,gBACHC,YAAcC,SAASC,cAAc,mCACtCF,sBAGDA,YAAYG,QAAQC,mCAGlBC,iBAAmB,mBAAU,aAAc,iBAC3CC,qBAAuB,mBAAU,iBAAkB,iBAEnDC,iBAAmBP,YAAYE,cAAc,8BACnDK,iBAAiBC,iBAAiB,SAAUC,IACpCA,EAAEC,OAAOC,QAAQ,+BAxDFC,CAAAA,yBACjBC,KAAOD,iBAAiBT,QAAQU,KACtCZ,SAASa,cAAc,IAAIC,YAAY,2BAA4B,CAC\/DC,OAAQ,CACJH,KAAMA,eAGRI,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