diff options
author | Jose Antonio Marquez | 2012-04-10 11:24:21 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-04-10 11:24:21 -0700 |
commit | d14f78b06d37aa469885f2ecf84419bcb7e3e613 (patch) | |
tree | 91b95c6c9aef779a743b710105546a8ae74bff12 /js/io/ui/new-file-dialog/new-file-options-navigator.reel | |
parent | a9bcc403df76ad2cb7c31ff7fdd42a85c35cf424 (diff) | |
parent | bd43ce383b050d03b0f92cc923c517febc66ca28 (diff) | |
download | ninja-d14f78b06d37aa469885f2ecf84419bcb7e3e613.tar.gz |
Merge branch 'refs/heads/Ninja-Internal' into FileIO
Diffstat (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel')
-rw-r--r-- | js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js | 60 |
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)); |