aboutsummaryrefslogtreecommitdiff
path: root/js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
diff options
context:
space:
mode:
authorAnanya Sen2012-04-17 18:11:55 -0700
committerAnanya Sen2012-04-17 18:11:55 -0700
commit35abad196cc9feb76ef50c1b63032a38233a6d51 (patch)
tree914689c66d4ab6c6e088b571eade0a0e35082916 /js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js
parent1f891c58bad0b7746659aa4138001b5ee76d9a0e (diff)
parent616a8532099fec2a15855eac97cd85cb60c4451c (diff)
downloadninja-35abad196cc9feb76ef50c1b63032a38233a6d51.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into Codeview-improvements
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.js60
1 files changed, 32 insertions, 28 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 c98955ca..1a26c99c 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
@@ -30,12 +30,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
30 newFileName:{ 30 newFileName:{
31 writable:true, 31 writable:true,
32 enumerable:false, 32 enumerable:false,
33 value:"" 33 value:null
34 }, 34 },
35 newFileDirectory:{ 35 newFileDirectory:{
36 writable:true, 36 writable:true,
37 enumerable:false, 37 enumerable:false,
38 value:"" 38 value:null
39 }, 39 },
40 templateWidth:{ 40 templateWidth:{
41 writable:true, 41 writable:true,
@@ -145,6 +145,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
145 } 145 }
146 }, true); 146 }, true);
147 147
148 this.eventManager.addEventListener("enterKey", this, false);
149 this.eventManager.addEventListener("escKey", this, false);
150
148 } 151 }
149 152
150 }, 153 },
@@ -326,32 +329,36 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
326 329
327 handleNewFileDirectorySet:{ 330 handleNewFileDirectorySet:{
328 value:function(evt){ 331 value:function(evt){
329 if(evt.keyCode === 13){ 332 this.newFileDirectory = evt._event.newFileDirectory;
330 if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); 333 if(this.isValidUri(this.newFileDirectory)){
331 }else if(evt.keyCode === 27){ 334 this.enableOk();
332 this.handleCancelButtonAction(evt);
333 }
334 else if(!!evt._event.newFileDirectory){
335 this.newFileDirectory = evt._event.newFileDirectory;
336 if(this.isValidUri(this.newFileDirectory)){
337 this.enableOk();
338 }
339 } 335 }
340 } 336 }
341 }, 337 },
342 338
343 handleNewFileNameSet:{ 339 handleNewFileNameSet:{
344 value:function(evt){ 340 value:function(evt){
345 if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ 341 this.newFileName = evt._event.newFileName;
346 this.handleOkButtonAction(evt); 342 if(this.isValidFileName(this.newFileName)){
347 }else if(evt.keyCode === 27){ 343 this.enableOk();
348 this.handleCancelButtonAction(evt);
349 } 344 }
350 else if(!!evt._event.newFileName){ 345 }
351 this.newFileName = evt._event.newFileName; 346 },
352 if(this.isValidFileName(this.newFileName)){ 347
353 this.enableOk(); 348 handleEnterKey:{
354 } 349 value: function(evt){
350 if((this.application.ninja.newFileController.newFileOptionsNav !== null)
351 && !this.okButton.hasAttribute("disabled")){
352
353 this.handleOkButtonAction(evt);
354 }
355 }
356 },
357
358 handleEscKey:{
359 value: function(evt){
360 if(this.application.ninja.newFileController.newFileOptionsNav !== null){
361 this.handleCancelButtonAction(evt);
355 } 362 }
356 } 363 }
357 }, 364 },
@@ -422,14 +429,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
422 isValidUri:{ 429 isValidUri:{
423 value: function(uri){ 430 value: function(uri){
424 var status= this.application.ninja.coreIoApi.isValidUri(uri); 431 var status= this.application.ninja.coreIoApi.isValidUri(uri);
425 if(uri !== ""){ 432 if((uri !== null) && !status){
426 if(!status){
427 this.showError("! Invalid directory."); 433 this.showError("! Invalid directory.");
428 //disable ok 434 //disable ok
429 if(!this.okButton.hasAttribute("disabled")){ 435 if(!this.okButton.hasAttribute("disabled")){
430 this.okButton.setAttribute("disabled", "true"); 436 this.okButton.setAttribute("disabled", "true");
431 } 437 }
432 }
433 } 438 }
434 return status; 439 return status;
435 } 440 }
@@ -437,14 +442,12 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
437 isValidFileName:{ 442 isValidFileName:{
438 value: function(fileName){ 443 value: function(fileName){
439 var status = this.validateFileName(fileName); 444 var status = this.validateFileName(fileName);
440 if(fileName !== ""){ 445 if((fileName !== null ) && !status){
441 if(!status){
442 this.showError("! Invalid file name."); 446 this.showError("! Invalid file name.");
443 //disable ok 447 //disable ok
444 if(!this.okButton.hasAttribute("disabled")){ 448 if(!this.okButton.hasAttribute("disabled")){
445 this.okButton.setAttribute("disabled", "true"); 449 this.okButton.setAttribute("disabled", "true");
446 } 450 }
447 }
448 } 451 }
449 return status; 452 return status;
450 } 453 }
@@ -488,8 +491,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C
488 validateFileName:{ 491 validateFileName:{
489 value: function(fileName){ 492 value: function(fileName){
490 var status = false; 493 var status = false;
491 if(fileName !== ""){ 494 if((fileName !== null) && (fileName !== "")){
492 fileName = fileName.replace(/^\s+|\s+$/g,""); 495 fileName = fileName.replace(/^\s+|\s+$/g,"");
496 if(fileName === ""){return false;}
493 status = !(/[/\\]/g.test(fileName)); 497 status = !(/[/\\]/g.test(fileName));
494 if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden 498 if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden
495 status = !(/^\./g.test(fileName)); 499 status = !(/^\./g.test(fileName));