Menubar.View.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { UIPanel, UIRow } from './libs/ui.js';
  2. function MenubarView( editor ) {
  3. var strings = editor.strings;
  4. var container = new UIPanel();
  5. container.setClass( 'menu' );
  6. var title = new UIPanel();
  7. title.setClass( 'title' );
  8. title.setTextContent( strings.getKey( 'menubar/view' ) );
  9. container.add( title );
  10. var options = new UIPanel();
  11. options.setClass( 'options' );
  12. container.add( options );
  13. // Fullscreen
  14. var option = new UIRow();
  15. option.setClass( 'option' );
  16. option.setTextContent( strings.getKey( 'menubar/view/fullscreen' ) );
  17. option.onClick( function () {
  18. if ( document.fullscreenElement === null ) {
  19. document.documentElement.requestFullscreen();
  20. } else if ( document.exitFullscreen ) {
  21. document.exitFullscreen();
  22. }
  23. // Safari
  24. if ( document.webkitFullscreenElement === null ) {
  25. document.documentElement.webkitRequestFullscreen();
  26. } else if ( document.webkitExitFullscreen ) {
  27. document.webkitExitFullscreen();
  28. }
  29. } );
  30. options.add( option );
  31. // VR (Work in progress)
  32. if ( 'xr' in navigator ) {
  33. navigator.xr.isSessionSupported( 'immersive-vr' )
  34. .then( function ( supported ) {
  35. if ( supported ) {
  36. var option = new UIRow();
  37. option.setClass( 'option' );
  38. option.setTextContent( 'VR' );
  39. option.onClick( function () {
  40. editor.signals.toggleVR.dispatch();
  41. } );
  42. options.add( option );
  43. }
  44. } );
  45. }
  46. return container;
  47. }
  48. export { MenubarView };