diff options
author | Jose Antonio Marquez | 2012-04-10 11:24:35 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-10 11:24:35 -0700 |
commit | e663e336ee7e832b5059a82748061506b414cb04 (patch) | |
tree | a09d932319365067f437780e90aeab4ef19f74b4 /js/io/ui/save-as-dialog.reel/save-as-dialog.js | |
parent | c3022de5ba2e24737184dba7454233b165da0a20 (diff) | |
parent | bd43ce383b050d03b0f92cc923c517febc66ca28 (diff) | |
download | ninja-e663e336ee7e832b5059a82748061506b414cb04.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into Document
Diffstat (limited to 'js/io/ui/save-as-dialog.reel/save-as-dialog.js')
-rw-r--r-- | js/io/ui/save-as-dialog.reel/save-as-dialog.js | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/js/io/ui/save-as-dialog.reel/save-as-dialog.js b/js/io/ui/save-as-dialog.reel/save-as-dialog.js index c5ed8d33..e2f50ff5 100644 --- a/js/io/ui/save-as-dialog.reel/save-as-dialog.js +++ b/js/io/ui/save-as-dialog.reel/save-as-dialog.js | |||
@@ -16,13 +16,13 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
16 | fileName : { | 16 | fileName : { |
17 | enumerable: true, | 17 | enumerable: true, |
18 | writable: true, | 18 | writable: true, |
19 | value: "" | 19 | value: null |
20 | }, | 20 | }, |
21 | 21 | ||
22 | folderUri:{ | 22 | folderUri:{ |
23 | enumerable: true, | 23 | enumerable: true, |
24 | writable: true, | 24 | writable: true, |
25 | value: "" | 25 | value: null |
26 | }, | 26 | }, |
27 | 27 | ||
28 | callback : { | 28 | callback : { |
@@ -36,7 +36,12 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
36 | writable: true, | 36 | writable: true, |
37 | value: null | 37 | value: null |
38 | }, | 38 | }, |
39 | 39 | prepareForDraw: { | |
40 | value: function() { | ||
41 | this.newFileName.value = this.fileName; | ||
42 | this.fileInputField.newFileDirectory.value = this.folderUri; | ||
43 | } | ||
44 | }, | ||
40 | willDraw: { | 45 | willDraw: { |
41 | enumerable: false, | 46 | enumerable: false, |
42 | value: function() {} | 47 | value: function() {} |
@@ -51,18 +56,16 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
51 | var self = this; | 56 | var self = this; |
52 | this.fileInputField.selectDirectory = true; | 57 | this.fileInputField.selectDirectory = true; |
53 | this.fileInputField.pickerName = "saveAsDirectoryPicker"; | 58 | this.fileInputField.pickerName = "saveAsDirectoryPicker"; |
54 | this.newFileName.value = this.fileName; | ||
55 | this.fileInputField.newFileDirectory.value = this.folderUri; | ||
56 | 59 | ||
57 | this.newFileName.addEventListener("keyup", function(evt){self.handleNewFileNameOnkeyup(evt);}, false); | 60 | this.addEventListener("change@newFileName.value", this.handleNewFileNameChange, false); |
58 | this.newFileName.addEventListener("paste", this, false); | 61 | this.newFileName.element.addEventListener("keyup", this, false); |
59 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); | 62 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){self.handleNewFileDirectorySet(evt);}, false); |
60 | |||
61 | this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); | 63 | this.okButton.addEventListener("click", function(evt){self.handleOkButtonAction(evt);}, false); |
62 | this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); | 64 | this.cancelButton.addEventListener("click", function(evt){self.handleCancelButtonAction(evt);}, false); |
63 | 65 | ||
64 | this.newFileName.focus(); | 66 | this.eventManager.addEventListener("enterKey", this, false); |
65 | this.newFileName.select(); | 67 | this.eventManager.addEventListener("escKey", this, false); |
68 | |||
66 | 69 | ||
67 | this.enableOk(); | 70 | this.enableOk(); |
68 | 71 | ||
@@ -80,51 +83,59 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
80 | } | 83 | } |
81 | }, true); | 84 | }, true); |
82 | 85 | ||
86 | this.newFileName.element.focus(); | ||
87 | this.newFileName.element.select(); | ||
88 | |||
83 | } | 89 | } |
84 | }, | 90 | }, |
85 | 91 | ||
86 | handleNewFileDirectorySet:{ | 92 | handleNewFileDirectorySet:{ |
87 | value:function(evt){ | 93 | value:function(evt){ |
88 | if(evt.keyCode === 13){ | 94 | this.folderUri = evt._event.newFileDirectory; |
89 | if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); | 95 | if(this.isValidUri(this.folderUri)){ |
90 | }else if(evt.keyCode === 27){ | 96 | this.enableOk(); |
91 | this.handleCancelButtonAction(evt); | ||
92 | } | ||
93 | else if(!!evt._event.newFileDirectory){ | ||
94 | this.folderUri = evt._event.newFileDirectory; | ||
95 | if(this.isValidUri(this.folderUri)){ | ||
96 | this.enableOk(); | ||
97 | } | ||
98 | } | 97 | } |
99 | } | 98 | } |
100 | }, | 99 | }, |
101 | 100 | ||
102 | handlePaste:{ | 101 | handleNewFileNameChange:{ |
103 | value:function(evt){ | ||
104 | evt.preventDefault(); | ||
105 | evt.target.value = evt.clipboardData.getData("Text"); | ||
106 | this.handleNewFileNameOnkeyup(evt); | ||
107 | } | ||
108 | }, | ||
109 | |||
110 | handleNewFileNameOnkeyup:{ | ||
111 | value:function(evt){ | 102 | value:function(evt){ |
112 | this.fileName = this.newFileName.value; | 103 | this.fileName = this.newFileName.value; |
113 | if(this.fileName !== ""){ | 104 | if(this.isValidFileName(this.fileName)){ |
114 | if(this.isValidFileName(this.fileName)){ | ||
115 | this.enableOk(); | 105 | this.enableOk(); |
116 | } | ||
117 | } | 106 | } |
118 | if(evt.keyCode === 13){ | 107 | } |
119 | if(!this.okButton.hasAttribute("disabled")){ | 108 | }, |
109 | |||
110 | handleKeyup:{ | ||
111 | value: function(evt){ | ||
112 | if(evt.keyCode === 13){ | ||
113 | if(!this.okButton.hasAttribute("disabled")){ | ||
120 | this.handleOkButtonAction(evt); | 114 | this.handleOkButtonAction(evt); |
121 | } | 115 | } |
122 | }else if(evt.keyCode === 27){ | 116 | }else if(evt.keyCode === 27){ |
123 | this.handleCancelButtonAction(evt); | 117 | this.handleCancelButtonAction(evt); |
118 | } | ||
119 | } | ||
120 | }, | ||
121 | |||
122 | handleEnterKey:{ | ||
123 | value: function(evt){ | ||
124 | if((this.application.ninja.newFileController.saveAsDialog !== null) | ||
125 | && !this.okButton.hasAttribute("disabled")){ | ||
126 | |||
127 | this.handleOkButtonAction(evt); | ||
124 | } | 128 | } |
125 | } | 129 | } |
126 | }, | 130 | }, |
127 | 131 | ||
132 | handleEscKey:{ | ||
133 | value: function(evt){ | ||
134 | if(this.application.ninja.newFileController.saveAsDialog !== null){ | ||
135 | this.handleCancelButtonAction(evt); | ||
136 | } | ||
137 | } | ||
138 | }, | ||
128 | 139 | ||
129 | enableOk:{ | 140 | enableOk:{ |
130 | value: function(){ | 141 | value: function(){ |
@@ -194,10 +205,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
194 | isValidUri:{ | 205 | isValidUri:{ |
195 | value: function(uri){ | 206 | value: function(uri){ |
196 | var status= this.application.ninja.coreIoApi.isValidUri(uri); | 207 | var status= this.application.ninja.coreIoApi.isValidUri(uri); |
197 | if(uri !== ""){ | 208 | if((uri !== null) && !status){ |
198 | if(!status){ | ||
199 | this.showError("! Invalid directory."); | 209 | this.showError("! Invalid directory."); |
200 | } | ||
201 | } | 210 | } |
202 | return status; | 211 | return status; |
203 | } | 212 | } |
@@ -205,10 +214,8 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
205 | isValidFileName:{ | 214 | isValidFileName:{ |
206 | value: function(fileName){ | 215 | value: function(fileName){ |
207 | var status = this.validateFileName(fileName); | 216 | var status = this.validateFileName(fileName); |
208 | if(fileName !== ""){ | 217 | if((fileName !== null) && !status){ |
209 | if(!status){ | ||
210 | this.showError("! Invalid file name."); | 218 | this.showError("! Invalid file name."); |
211 | } | ||
212 | } | 219 | } |
213 | return status; | 220 | return status; |
214 | } | 221 | } |
@@ -257,8 +264,9 @@ var SaveAsDialog = exports.SaveAsDialog = Montage.create(Component, { | |||
257 | validateFileName:{ | 264 | validateFileName:{ |
258 | value: function(fileName){ | 265 | value: function(fileName){ |
259 | var status = false; | 266 | var status = false; |
260 | if(fileName !== ""){ | 267 | if((fileName !== null) && (fileName !== "")){ |
261 | fileName = fileName.replace(/^\s+|\s+$/g,""); | 268 | fileName = fileName.replace(/^\s+|\s+$/g,""); |
269 | if(fileName === ""){return false;} | ||
262 | status = !(/[/\\]/g.test(fileName)); | 270 | status = !(/[/\\]/g.test(fileName)); |
263 | if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden | 271 | if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden |
264 | status = !(/^\./g.test(fileName)); | 272 | status = !(/^\./g.test(fileName)); |