FileManager.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. SC.loadPackage({ 'FileManager': {
  2. comment: 'I am the FileManager.',
  3. methods: {
  4. init: {
  5. comment: 'I init the fileManager',
  6. code: function(){
  7. }
  8. },
  9. open: {
  10. comment: 'I open myWindow for simple file browsing.',
  11. code: function(){
  12. SuperGlue.get('windowManager').do('createWindow', {
  13. class: 'FileManagerWindow',
  14. top: 100,
  15. left: 100,
  16. width: 400,
  17. height: 410,
  18. hasOKandCancelButton: false,
  19. });
  20. }
  21. },
  22. chooseFile: {
  23. comment: 'I open myWindow as a file chooser dialog.',
  24. code: function(options){
  25. SuperGlue.get('windowManager').do('createWindow', {
  26. class: 'FileManagerWindow',
  27. context: 'chooseFile',
  28. top: 100,
  29. left: 100,
  30. width: 400,
  31. height: 410,
  32. hasOKandCancelButton: true,
  33. selectPath: options.oldPath,
  34. callback: function() {
  35. options.callback.call(this, this.path);
  36. }
  37. });
  38. }
  39. },
  40. saveAs: {
  41. comment: 'I open myWindow as a saveAs dialog.',
  42. code: function(callback){
  43. SuperGlue.get('windowManager').do('createWindow', {
  44. class: 'FileManagerWindow',
  45. context: 'saveAs',
  46. top: 100,
  47. left: 100,
  48. width: 400,
  49. height: 410,
  50. hasOKandCancelButton: true,
  51. originalFileName: document.location.pathname.split('/').slice(-1).join(),
  52. callback: function() {
  53. callback.call(this, this.path);
  54. }
  55. });
  56. }
  57. }
  58. }
  59. }});