diff options
author | Jose Antonio Marquez Russo | 2012-02-21 23:31:37 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-21 23:31:37 -0800 |
commit | 9f87a6bb4d37a1e7201dd9452bcb91940733f07d (patch) | |
tree | bdd7f0f4f8851652bf188fbad249ea1fe7c33666 /js/io/ui/new-file-dialog/new-file-location.reel | |
parent | e17fb41feca768d746f89d90cef28192fa60c621 (diff) | |
parent | 69983b800d0179fcccd5b61b64ed22c02e22b93a (diff) | |
download | ninja-9f87a6bb4d37a1e7201dd9452bcb91940733f07d.tar.gz |
Merge pull request #14 from mencio/file-io
File io - Code cleanup and added default folder to the file new dialog.
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-location.reel')
-rwxr-xr-x | js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js index fae8f9c7..849c665c 100755 --- a/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js +++ b/js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | |||
@@ -11,46 +11,58 @@ var newFileWorkflowControllerModule = require("js/io/ui/new-file-dialog/new-file | |||
11 | var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { | 11 | var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { |
12 | 12 | ||
13 | templateHeight:{ | 13 | templateHeight:{ |
14 | enumerable: true, | ||
15 | value:"25 px" | 14 | value:"25 px" |
16 | }, | 15 | }, |
17 | 16 | ||
18 | templateWidth:{ | 17 | templateWidth:{ |
19 | enumerable: true, | ||
20 | value:"25 px" | 18 | value:"25 px" |
21 | }, | 19 | }, |
22 | 20 | ||
23 | willDraw: { | 21 | // Populating the directory input field with the default save location or the last stored location. |
24 | enumerable: false, | 22 | prepareForDraw: { |
25 | value: function() {} | 23 | value: function() { |
26 | }, | 24 | var defaultSaveDirectory; |
25 | |||
26 | // Using session storage location | ||
27 | if(window.sessionStorage) { | ||
28 | var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); | ||
29 | if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); | ||
30 | } | ||
31 | |||
32 | // Use default if none found in session storage | ||
33 | if(!defaultSaveDirectory) { | ||
34 | var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); | ||
35 | if(driveData.success){ | ||
36 | var topLevelDirectories = (JSON.parse(driveData.content)).children; | ||
37 | defaultSaveDirectory = topLevelDirectories[0].uri; | ||
38 | } else { | ||
39 | console.log("** Error ** Cannot get directory listing"); | ||
40 | defaultSaveDirectory = ""; | ||
41 | } | ||
42 | } | ||
27 | 43 | ||
28 | draw: { | 44 | // Set the input field to the correct directory |
29 | enumerable: false, | 45 | this.fileInputField.newFileDirectory.value = defaultSaveDirectory; |
30 | value: function() {} | 46 | } |
31 | }, | 47 | }, |
32 | 48 | ||
33 | didDraw: { | 49 | didDraw: { |
34 | enumerable: false, | ||
35 | value: function() { | 50 | value: function() { |
36 | var that=this; | ||
37 | |||
38 | this.fileInputField.selectDirectory = true; | 51 | this.fileInputField.selectDirectory = true; |
39 | 52 | ||
40 | this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); | 53 | this.newFileName.addEventListener("keyup", this, false); |
41 | } | 54 | } |
42 | |||
43 | }, | 55 | }, |
44 | 56 | ||
45 | handleNewFileNameOnkeyup:{ | 57 | handleKeyup:{ |
46 | value:function(evt){ | 58 | value:function(evt){ |
47 | if(this.newFileName.value !== ""){ | 59 | if(this.newFileName.value !== "") { |
48 | var newFileNameSetEvent = document.createEvent("Events"); | 60 | var newFileNameSetEvent = document.createEvent("Events"); |
49 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); | 61 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); |
50 | newFileNameSetEvent.newFileName = this.newFileName.value; | 62 | newFileNameSetEvent.newFileName = this.newFileName.value; |
51 | this.eventManager.dispatchEvent(newFileNameSetEvent); | 63 | this.eventManager.dispatchEvent(newFileNameSetEvent); |
52 | } | 64 | } |
53 | } | 65 | } |
54 | } | 66 | } |
55 | 67 | ||
56 | }); \ No newline at end of file | 68 | }); \ No newline at end of file |