aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js')
-rw-r--r--js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js80
1 files changed, 59 insertions, 21 deletions
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..c98955ca 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){
330 if(!this.okButton.hasAttribute("disabled")) 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 ok
429 if(!this.okButton.hasAttribute("disabled")){
430 this.okButton.setAttribute("disabled", "true");
431 }
394 } 432 }
395 } 433 }
396 return status; 434 return status;
@@ -402,6 +440,10 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
402 if(fileName !== ""){ 440 if(fileName !== ""){
403 if(!status){ 441 if(!status){
404 this.showError("! Invalid file name."); 442 this.showError("! Invalid file name.");
443 //disable ok
444 if(!this.okButton.hasAttribute("disabled")){
445 this.okButton.setAttribute("disabled", "true");
446 }
405 } 447 }
406 } 448 }
407 return status; 449 return status;
@@ -437,10 +479,6 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
437 value:function(errorString){ 479 value:function(errorString){
438 this.error.innerHTML = ""; 480 this.error.innerHTML = "";
439 this.error.innerHTML=errorString; 481 this.error.innerHTML=errorString;
440 //disable ok