diff options
author | Jose Antonio Marquez | 2012-03-28 13:58:06 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-03-28 13:58:06 -0700 |
commit | 95249b524ada7d20abf24408a857cccec8aea19a (patch) | |
tree | 88c96e3f87729a873af7fc88379f4935e83306ed /js/io/ui/new-file-dialog | |
parent | 57696598cd39d4aa31b5106cba29dd2b6d02c6d9 (diff) | |
parent | 3fd2cdb59027b3f973b9165db9db4fdd22026941 (diff) | |
download | ninja-95249b524ada7d20abf24408a857cccec8aea19a.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/io/ui/new-file-dialog')
3 files changed, 74 insertions, 23 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 0e1e09a4..fac4c488 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 | |||
@@ -23,6 +23,8 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { | |||
23 | this.fileInputField.selectDirectory = true; | 23 | this.fileInputField.selectDirectory = true; |
24 | 24 | ||
25 | this.newFileName.addEventListener("keyup", this, false); | 25 | this.newFileName.addEventListener("keyup", this, false); |
26 | this.newFileName.focus(); | ||
27 | this.newFileName.select(); | ||
26 | } | 28 | } |
27 | }, | 29 | }, |
28 | 30 | ||
@@ -32,6 +34,7 @@ var NewFileLocation = exports.NewFileLocation = Montage.create(Component, { | |||
32 | var newFileNameSetEvent = document.createEvent("Events"); | 34 | var newFileNameSetEvent = document.createEvent("Events"); |
33 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); | 35 | newFileNameSetEvent.initEvent("newFileNameSet", false, false); |
34 | newFileNameSetEvent.newFileName = this.newFileName.value; | 36 | newFileNameSetEvent.newFileName = this.newFileName.value; |
37 | newFileNameSetEvent.keyCode = evt.keyCode; | ||
35 | this.eventManager.dispatchEvent(newFileNameSetEvent); | 38 | this.eventManager.dispatchEvent(newFileNameSetEvent); |
36 | } | 39 | } |
37 | } | 40 | } |
diff --git a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js index aaf39005..18556bc5 100644 --- a/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js +++ b/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js | |||
@@ -98,14 +98,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
98 | 98 | ||
99 | this.addIdentifiers(); | 99 | this.addIdentifiers(); |
100 | 100 | ||
101 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | ||
102 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | ||
103 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); | ||
104 | this.eventManager.addEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); | ||
105 | |||
106 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); | ||
107 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); | ||
108 | |||
109 | if(!!this.newFileModel.defaultProjectType){ | 101 | if(!!this.newFileModel.defaultProjectType){ |
110 | var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); | 102 | var templates = this.newFileModel.prepareContents(this.newFileModel.defaultProjectType); |
111 | this.templateList = iconsListModule.IconsList.create(); | 103 | this.templateList = iconsListModule.IconsList.create(); |
@@ -116,7 +108,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
116 | this.templateList.element = this.templateIcons; | 108 | this.templateList.element = this.templateIcons; |
117 | this.templateList.needsDraw = true; | 109 | this.templateList.needsDraw = true; |
118 | 110 | ||
119 | |||
120 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; | 111 | this.selectedProjectType = {"uri":this.newFileModel.defaultProjectType, "element":null}; |
121 | } | 112 | } |
122 | 113 | ||
@@ -127,6 +118,33 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
127 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; | 118 | fileExtensionEl.innerHTML = ""+this.newFileModel.projectTypeData[this.newFileModel.defaultProjectType].fileExtension; |
128 | } | 119 | } |
129 | } | 120 | } |
121 | |||
122 | this.element.addEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | ||
123 | this.element.addEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | ||
124 | this.eventManager.addEventListener("newFileDirectorySet", function(evt){ | ||
125 | that.handleNewFileDirectorySet(evt); | ||
126 | }, false); | ||
127 | this.eventManager.addEventListener("newFileNameSet", function(evt){ | ||
128 | that.handleNewFileNameSet(evt); | ||
129 | }, false); | ||
130 | |||
131 | this.okButton.addEventListener("click", function(evt){that.handleOkButtonAction(evt);}, false); | ||
132 | this.cancelButton.addEventListener("click", function(evt){that.handleCancelButtonAction(evt);}, false); | ||
133 | |||
134 | this.element.addEventListener("keyup", function(evt){ | ||
135 | if(evt.keyCode == 27) {//ESC key | ||
136 | if(that.application.ninja.newFileController.newFileOptionsNav !== null){ | ||
137 | that.handleCancelButtonAction(); | ||
138 | } | ||
139 | }else if((evt.keyCode == 13) && !(evt.ctrlKey || evt.metaKey)){//ENTER key | ||
140 | if((that.application.ninja.newFileController.newFileOptionsNav !== null) | ||
141 | && !that.okButton.hasAttribute("disabled")){ | ||
142 | |||
143 | that.handleOkButtonAction(); | ||
144 | } | ||
145 | } | ||
146 | }, true); | ||
147 | |||
130 | } | 148 | } |
131 | 149 | ||
132 | }, | 150 | }, |
@@ -291,10 +309,16 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
291 | }else{ | 309 | }else{ |
292 | if(this.error.innerHTML === ""){ | 310 | if(this.error.innerHTML === ""){ |
293 | this.showError("! Project Template, Name and Directory should be valid."); | 311 | this.showError("! Project Template, Name and Directory should be valid."); |
294 | } | 312 | //disable ok |
295 | //disable ok | 313 | if(!this.okButton.hasAttribute("disabled")){ |
296 | if(!this.okButton.hasAttribute("disabled")){ | 314 | this.okButton.setAttribute("disabled", "true"); |
297 | this.okButton.setAttribute("disabled", "true"); | 315 | } |
316 | }else if(!this.selectedProjectType || !this.selectedTemplate){ | ||
317 | this.showError("! Project Template should be selected."); | ||
318 | //disable ok | ||
319 | if(!this.okButton.hasAttribute("disabled")){ | ||
320 | this.okButton.setAttribute("disabled", "true"); | ||
321 | } | ||
298 | } | 322 | } |
299 | } | 323 | } |
300 | } | 324 | } |
@@ -302,7 +326,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
302 | 326 | ||
303 | handleNewFileDirectorySet:{ | 327 | handleNewFileDirectorySet:{ |
304 | value:function(evt){ | 328 | value:function(evt){ |
305 | if(!!evt._event.newFileDirectory){ | 329 | if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ |
330 | this.handleOkButtonAction(evt); | ||
331 | }else if(evt.keyCode === 27){ | ||
332 | this.handleCancelButtonAction(evt); | ||
333 | } | ||
334 | else if(!!evt._event.newFileDirectory){ | ||
306 | this.newFileDirectory = evt._event.newFileDirectory; | 335 | this.newFileDirectory = evt._event.newFileDirectory; |
307 | if(this.isValidUri(this.newFileDirectory)){ | 336 | if(this.isValidUri(this.newFileDirectory)){ |
308 | this.enableOk(); | 337 | this.enableOk(); |
@@ -313,7 +342,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
313 | 342 | ||
314 | handleNewFileNameSet:{ | 343 | handleNewFileNameSet:{ |
315 | value:function(evt){ | 344 | value:function(evt){ |
316 | if(!!evt._event.newFileName){ | 345 | if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ |
346 | this.handleOkButtonAction(evt); | ||
347 | }else if(evt.keyCode === 27){ | ||
348 | this.handleCancelButtonAction(evt); | ||
349 | } | ||
350 | else if(!!evt._event.newFileName){ | ||
317 | this.newFileName = evt._event.newFileName; | 351 | this.newFileName = evt._event.newFileName; |
318 | if(this.isValidFileName(this.newFileName)){ | 352 | if(this.isValidFileName(this.newFileName)){ |
319 | this.enableOk(); | 353 | this.enableOk(); |
@@ -374,14 +408,14 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
374 | 408 | ||
375 | this.newFileName = ""; | 409 | this.newFileName = ""; |
376 | this.newFileDirectory = ""; | 410 | this.newFileDirectory = ""; |
377 | this.selectedProjectType = null; | ||
378 | this.selectedTemplate = null; | ||
379 | 411 | ||
380 | //remove event listeners | 412 | //remove event listeners |
381 | this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); | 413 | this.element.removeEventListener("drawTree", function(evt){that.handleNewFileNavDrawTree(evt);}, false); |
382 | this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only | 414 | this.element.removeEventListener("selectedItem", function(evt){that.handleNewFileNavSelectedItem(evt);}, false);//for single selection only |
383 | this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); | 415 | this.eventManager.removeEventListener("newFileDirectorySet", function(evt){that.handleNewFileDirectorySet(evt);}, false); |
384 | this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); | 416 | this.eventManager.removeEventListener("newFileNameSet", function(evt){that.handleNewFileNameSet(evt);}, false); |
417 | |||
418 | this.application.ninja.newFileController.newFileOptionsNav = null; | ||
385 | } | 419 | } |
386 | }, | 420 | }, |
387 | 421 | ||
@@ -391,6 +425,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C | |||
391 | if(uri !== ""){ | 425 | if(uri !== ""){ |
392 | if(!status){ | 426 | if(!status){ |
393 | this.showError("! Invalid directory."); | 427 | this.showError("! Invalid directory."); |
428 | //disable |