diff options
author | Valerio Virgillito | 2012-02-21 22:37:36 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-21 22:37:36 -0800 |
commit | a8f5dcd8e85af6600f2e2b6a4536f05fd0c9916d (patch) | |
tree | dfcc68e2f6f646e335d9be047ef16988d69b0910 /js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | |
parent | 067ebae166ff82ae113a91517dfa59e7de5ae3d3 (diff) | |
download | ninja-a8f5dcd8e85af6600f2e2b6a4536f05fd0c9916d.tar.gz |
Adding the default folder by default when opening a new file dialog.
Adding the default folder name in the new file dialog input field. Also some more cleanup.
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js')
-rwxr-xr-x | js/io/ui/new-file-dialog/new-file-location.reel/new-file-location.js | 57 |
1 files changed, 33 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..ee2847ca 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,55 @@ 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 | prepareForDraw: { |
24 | enumerable: false, | 22 | value: function() { |
25 | value: function() {} | 23 | // Populate the file input field by using the session storage or the default user folder |
26 | }, | 24 | var defaultSaveDirectory; |
25 | |||
26 | if(window.sessionStorage) { | ||
27 | var storedFolder = window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection"); | ||
28 | if(storedFolder) defaultSaveDirectory = decodeURI(window.sessionStorage.getItem("lastOpenedFolderURI_folderSelection")); | ||
29 | } | ||
30 | |||
31 | if(!defaultSaveDirectory) { | ||
32 | var driveData = this.application.ninja.coreIoApi.getDirectoryContents({uri:"", recursive:false, returnType:"all"}); | ||
33 | if(driveData.success){ | ||
34 | var topLevelDirectories = (JSON.parse(driveData.content)).children; | ||
35 | defaultSaveDirectory = topLevelDirectories[0].uri; | ||
36 | } else { | ||
37 | console.log("** Error ** Cannot get directory listing"); | ||
38 | defaultSaveDirectory = ""; | ||
39 | } | ||
40 | } | ||
27 | 41 | ||
28 | draw: { | 42 | this.fileInputField.newFileDirectory.value = defaultSaveDirectory; |
29 | enumerable: false, | 43 | } |
30 | value: function() {} | ||
31 | }, | 44 | }, |
32 | 45 | ||
33 | didDraw: { | 46 | didDraw: { |
34 | enumerable: false, | ||
35 | value: function() { | 47 | value: function() { |
36 | var that=this; | ||
37 | |||
38 | this.fileInputField.selectDirectory = true; | 48 | this.fileInputField.selectDirectory = true; |
39 | 49 | ||
40 | this.newFileName.addEventListener("keyup", function(evt){that.handleNewFileNameOnkeyup(evt);}, false); | 50 | this.newFileName.addEventListener("keyup", this, false); |
41 | } | 51 | } |
42 | |||
43 | }, | 52 | }, |
44 | 53 | ||
45 | handleNewFileNameOnkeyup:{ | 54 | handleKeyup:{ |
46 | value:function(evt){ | 55 | value:function(evt){ |
47 | if(this.newFileName.value !== ""){ | 56 | if(this.newFileName.value !== "") { |
48 | var newFileNameSetEvent = document.createEvent("Events"); | 57 | var newFileNameSetEvent = document.createEvent("Events"); |
49 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); | 58 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); |
50 | newFileNameSetEvent.newFileName = this.newFileName.value; | 59 | newFileNameSetEvent.newFileName = this.newFileName.value; |
51 | this.eventManager.dispatchEvent(newFileNameSetEvent); | 60 | this.eventManager.dispatchEvent(newFileNameSetEvent); |
52 | } | 61 | } |
53 | } | 62 | } |
54 | } | 63 | } |
55 | 64 | ||
56 | }); \ No newline at end of file | 65 | }); \ No newline at end of file |