From 8acdde3e87f8cabd179a068c54fe5b78fa38e40d Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 5 Apr 2012 22:54:53 -0700 Subject: - using Montage TextField component to handle any edits like keyup, paste, cut. - optimized Enter and Esc key handling Signed-off-by: Ananya Sen --- .../new-file-options-navigator.js | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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 35c3b28e..552e8f6f 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 @@ -145,6 +145,9 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C } }, true); + this.eventManager.addEventListener("enterKey", this, false); + this.eventManager.addEventListener("escKey", this, false); + } }, @@ -326,32 +329,36 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C handleNewFileDirectorySet:{ value:function(evt){ - if(evt.keyCode === 13){ - if(!this.okButton.hasAttribute("disabled")) this.handleOkButtonAction(evt); - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); - } - else{ - this.newFileDirectory = evt._event.newFileDirectory; - if(this.isValidUri(this.newFileDirectory)){ - this.enableOk(); - } + this.newFileDirectory = evt._event.newFileDirectory; + if(this.isValidUri(this.newFileDirectory)){ + this.enableOk(); } } }, handleNewFileNameSet:{ value:function(evt){ - if((evt.keyCode === 13) && !this.okButton.hasAttribute("disabled")){ - this.handleOkButtonAction(evt); - }else if(evt.keyCode === 27){ - this.handleCancelButtonAction(evt); + this.newFileName = evt._event.newFileName; + if(this.isValidFileName(this.newFileName)){ + this.enableOk(); } - else{ - this.newFileName = evt._event.newFileName; - if(this.isValidFileName(this.newFileName)){ - this.enableOk(); - } + } + }, + + handleEnterKey:{ + value: function(evt){ + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.okButton.hasAttribute("disabled")){ + + this.handleOkButtonAction(evt); + } + } + }, + + handleEscKey:{ + value: function(evt){ + if(this.application.ninja.newFileController.newFileOptionsNav !== null){ + this.handleCancelButtonAction(evt); } } }, -- cgit v1.2.3 From efe18b4c8e52667683727139e9f9e28f66381164 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Fri, 6 Apr 2012 15:31:43 -0700 Subject: block filenames and directories with all space Signed-off-by: Ananya Sen --- .../new-file-options-navigator.reel/new-file-options-navigator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/io/ui/new-file-dialog/new-file-options-navigator.reel/new-file-options-navigator.js') 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 552e8f6f..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 @@ -493,6 +493,7 @@ var NewFileOptionsNavigator = exports.NewFileOptionsNavigator = Montage.create(C var status = false; if((fileName !== null) && (fileName !== "")){ fileName = fileName.replace(/^\s+|\s+$/g,""); + if(fileName === ""){return false;} status = !(/[/\\]/g.test(fileName)); if(status && navigator.userAgent.indexOf("Macintosh") != -1){//for Mac files beginning with . are hidden status = !(/^\./g.test(fileName)); -- cgit v1.2.3