TimeTrex/interface/html5/dist/wizard-user_photo-UserPhotoWizardController.bundle.js

1 line
87 KiB
JavaScript
Raw Permalink Normal View History

2022-12-13 07:10:06 +01:00
(self.webpackChunktimetrex=self.webpackChunktimetrex||[]).push([["wizard-user_photo-UserPhotoWizardController","filebrowser-CameraBrowser","filebrowser-TImage","filebrowser-TImageAdvBrowser","filebrowser-TImageBrowser","filebrowser-TImageCutArea"],{8128:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("/* provided dependency */ var jQuery = __webpack_require__(9755);\n( function( $ ) {\n\n\t$.fn.CameraBrowser = function( options ) {\n\n\t\tGlobal.addCss( 'global/widgets/filebrowser/TImageBrowser.css' );\n\t\tvar opts = $.extend( {}, $.fn.CameraBrowser.defaults, options );\n\n\t\tvar $this = this;\n\t\tvar field;\n\n\t\tvar enabled = true;\n\t\tvar video = null;\n\t\tvar canvas = null;\n\n\t\tvar local_stream = null;\n\n\t\tthis.stopCamera = function() {\n\n\t\t\tif ( local_stream ) {\n\t\t\t\tif ( local_stream.stop ) {\n\t\t\t\t\t// This is the legacy method to stop video.\n\t\t\t\t\tlocal_stream.stop();\n\t\t\t\t} else if ( local_stream.getTracks ) {\n\t\t\t\t\t// This is the modern approach for stopping the video. https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/stop\n\t\t\t\t\tlocal_stream.getTracks().forEach( track => track.stop() );\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.showCamera = function() {\n\n\t\t\t// check for getUserMedia support\n\t\t\tnavigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;\n\t\t\tif ( navigator.mediaDevices && navigator.mediaDevices.getUserMedia ) {\n\t\t\t\t// Most up to date as of May 2020 (Aside from using async and await) https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia\n\n\t\t\t\t// get webcam feed if available\n\t\t\t\tnavigator.mediaDevices.getUserMedia( { video: true } )\n\t\t\t\t\t.then(function(stream) {\n\t\t\t\t\t\tif ('srcObject' in video) {\n\t\t\t\t\t\t\tvideo.srcObject = stream;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// Fallback for older browsers. https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject#Supporting_fallback_to_the_src_property\n\t\t\t\t\t\t\tvideo.src = URL.createObjectURL( stream );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tvideo.play();\n\t\t\t\t\t\tlocal_stream = stream;\n\t\t\t\t\t})\n\t\t\t\t\t.catch(function(err) {\n\t\t\t\t\t\terrorBack();\n\t\t\t\t\t});\n\t\t\t} else if ( navigator.getUserMedia ) {\n\t\t\t\t// Semi-deprecated, legacy, but still works. https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia\n\n\t\t\t\t// get webcam feed if available\n\t\t\t\tnavigator.getUserMedia( { video: true }, function( stream ) {\n\t\t\t\t\tif ('srcObject' in video) {\n\t\t\t\t\t\tvideo.srcObject = stream;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback for older browsers. https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/srcObject#Supporting_fallback_to_the_src_property\n\t\t\t\t\t\tvideo.src = URL.createObjectURL( stream );\n\t\t\t\t\t}\n\t\t\t\t\tvideo.play();\n\t\t\t\t\tlocal_stream = stream;\n\t\t\t\t}, errorBack );\n\t\t\t} else if ( navigator.webkitGetUserMedia ) { // WebKit-prefixed\n\t\t\t\tnavigator.webkitGetUserMedia( { video: true }, function( stream ) {\n\t\t\t\t\tvideo.src = window.webkitURL.createObjectURL( stream );\n\t\t\t\t\tvideo.play();\n\t\t\t\t\tlocal_stream = stream;\n\t\t\t\t}, errorBack );\n\t\t\t} else if ( navigator.mozGetUserMedia ) { // Firefox-prefixed\n\t\t\t\tnavigator.mozGetUserMedia( { video: true }, function( stream ) {\n\t\t\t\t\tvideo.src = window.URL.createObjectURL( stream );\n\t\t\t\t\tvideo.play();\n\t\t\t\t\tlocal_stream = stream;\n\t\t\t\t}, errorBack );\n\t\t\t} else {\n\t\t\t\terrorBack();\n\t\t\t}\n\n\t\t\tfunction errorBack() {\n\t\t\t\tTAlertManager.showAlert( $.i18n._( 'Unable to access Camera.<br><br>Please check your camera connections, permissions, and ensure you are using HTTPS. Alternatively, use the File upload method instead.' ) );\n\t\t\t}\n\t\t};\n\n\t\tthis.setEnable = function( val ) {\n\t\t\tenabled = val;\n\n\t\t\tvar btn = this.children().eq( 1 );\n\n\t\t\tif ( !val ) {\n\t\t\t\tbtn.attr