Sidebar.Settings.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Sidebar.Settings = function ( editor ) {
  5. var config = editor.config;
  6. var signals = editor.signals;
  7. var strings = editor.strings;
  8. var container = new UI.Panel();
  9. container.setBorderTop( '0' );
  10. container.setPaddingTop( '20px' );
  11. container.setPaddingBottom( '20px' );
  12. // language
  13. var options = {
  14. 'en': 'English',
  15. 'zh': '中文'
  16. };
  17. var languageRow = new UI.Row();
  18. var language = new UI.Select().setWidth( '150px' );
  19. language.setOptions( options );
  20. if ( config.getKey( 'language' ) !== undefined ) {
  21. language.setValue( config.getKey( 'language' ) );
  22. }
  23. language.onChange( function () {
  24. var value = this.getValue();
  25. editor.config.setKey( 'language', value );
  26. } );
  27. languageRow.add( new UI.Text( strings.getKey( 'sidebar/settings/language' ) ).setWidth( '90px' ) );
  28. languageRow.add( language );
  29. container.add( languageRow );
  30. // theme
  31. var options = {
  32. 'css/light.css': strings.getKey( 'sidebar/settings/theme/light' ),
  33. 'css/dark.css': strings.getKey( 'sidebar/settings/theme/dark' )
  34. };
  35. var themeRow = new UI.Row();
  36. var theme = new UI.Select().setWidth( '150px' );
  37. theme.setOptions( options );
  38. if ( config.getKey( 'theme' ) !== undefined ) {
  39. theme.setValue( config.getKey( 'theme' ) );
  40. }
  41. theme.onChange( function () {
  42. var value = this.getValue();
  43. editor.setTheme( value );
  44. editor.config.setKey( 'theme', value );
  45. } );
  46. themeRow.add( new UI.Text( strings.getKey( 'sidebar/settings/theme' ) ).setWidth( '90px' ) );
  47. themeRow.add( theme );
  48. container.add( themeRow );
  49. container.add( new Sidebar.Settings.Shortcuts( editor ) );
  50. container.add( new Sidebar.Settings.Viewport( editor ) );
  51. return container;
  52. };